0
,這裏是我用於顯示自定義的高評分系統全碼:定製高分的系統不寫入INI正確
// instance vars
var buffer = 0
var trigger = 0
// display setup
draw_set_font(fnt_highscores)
draw_set_color(c_white)
draw_set_halign(fa_left)
draw_set_valign(fa_middle)
// open save
ini_open("highscores.sav")
// reads file into 2d array
for (var i=0; i<10; i++)
{
scores[0,i] = ini_read_string(string(i+1), "place", 0)
scores[1,i] = ini_read_string(string(i+1), "name", 0)
scores[2,i] = ini_read_string(string(i+1), "score", 0)
}
// cycles through array to look for new high score
for (var i=0; i<10; i++)
{
// found one, run once.
if (global.points >= int64(scores[2,i]) && trigger == 0)
{
// starting from bottom, move value from number above to current
for (var j=9; j>i; j--)
{
scores[0,j] = scores[0,j-1]
scores[1,j] = scores[1,j-1]
scores[2,j] = scores[2,j-1]
}
// new high score
var initials = "beef"
scores[0,i] = string(i+1)
scores[1,i] = initials
scores[2,i] = global.points
trigger++
}
// display score
var j = i + 1
draw_text(global.centerw - 150, global.centerh - 220 + buffer, string(j) + ".")
draw_text(global.centerw - 100, global.centerh - 220 + buffer, scores[1,i])
draw_text(global.centerw + 20, global.centerh - 220 + buffer, scores[2,i])
buffer += 40
}
// write to file - NOT WORKING!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
for (var i=0; i<10; i++)
{
ini_write_string(string(i+1), "place", scores[0,i])
ini_write_string(string(i+1), "name", scores[1,i])
ini_write_string(string(i+1), "score", string(scores[2,i]))
}
// close save
ini_close()
// draws flashing text
scr_flash_alpha(300)
draw_text(50,room_height - 50, "Start or R Key to Restart. Q to quit")
draw_set_alpha(1)
的「寫入文件」線路(靠近BUTTOM)引起的問題。 這裏是它在做什麼,當我打了很高的分數:
有趣的是,如果我註釋掉寫INI線,一切完美的預期(只是信息不會保存到INI,顯然)
所以,我所有的循環是否正常工作,只是當它寫入INI沒有正確書面方式的值。 任何提示?我已經重新寫了幾個小時,並沒有得到什麼笑
非常感謝你提前! (編輯:這是我的highscores.sav - 請注意,條目10和9是完全相同的,直到「地點」值。另外有趣的是,它從10開始,工作到1的方式。當我寫了默認的撲救,我數點1-10)
[10]
score="2500"
name="beef"
place="9"
[9]
score="2500"
name="beef"
place="9"
[8]
score="3000"
name="ASS"
place="8"
[7]
score="3800"
name="MAL"
place="7"
[6]
score="4600"
name="ADO"
place="6"
[5]
score="5500"
name="DSK"
place="5"
[4]
score="5500"
name="DIS"
place="4"
[3]
score="5900"
name="PPS"
place="3"
[2]
score="6100"
name="DSK"
place="2"
[1]
score="6800"
name="PSF"
place="1"
(邊注:我知道有一個在代碼的一些草率的事情在這裏和那裏,將清理這一切,一旦這工作)
。