Jump to content


Photo

ini_write_real error message


  • Please log in to reply
2 replies to this topic

#1 snuffysam

snuffysam

    GMC Member

  • GMC Member
  • 132 posts
  • Version:GM7

Posted 09 June 2012 - 10:25 PM

So I'm making a game with multiple game modes, and each mode has a high score list, and each high score list will be (well, should be) stored in an ini file.
Basically, at the end of the mode, the player is taken to a room with a door. The player goes through the door to the score room, where the player can access all his high scores from all the modes. Since the door is an object that is only in that one room, and doesn't have any other actions, I figured I could use it to record what high scores the player got at the end of the mode.

The code for recording the score is as follows:
a=0 

while a<5 
    {
    if game_score>ds_grid_get(score_grid,0,a)
        {
        b=4
        
        while b>=a
            {
            ds_grid_set(score_grid,0,b,ds_grid_get(score_grid,0,b-1))
            b-=1
            if b=0
                break;
            }
        ds_grid_set(score_grid,0,a,game_score)
        break;
        }
    a+=1
    }
ini_open("challenge1.ini")
score1=ini_write_real('highscores','score1',ds_grid_get(score_grid,0,0))
score2=ini_write_real('highscores','score2',ds_grid_get(score_grid,0,1))
score3=ini_write_real('highscores','score3',ds_grid_get(score_grid,0,2))
score4=ini_write_real('highscores','score4',ds_grid_get(score_grid,0,3))
score5=ini_write_real('highscores','score5',ds_grid_get(score_grid,0,4))
ini_close()

And this is the error message that pops up as soon as I run the game:
FATAL ERROR in
action number 1
of Create Event
for object door01:

COMPILATION ERROR in code action.
Error in code at line 24:
   score1=ini_write_real('highscores','score1',ds_grid_get(score_grid,0,0))

at position 7: Variable name expected.

So where was I supposed to put this alleged "Variable name"? Is there something I'm not getting about ini files?

If there's anything you need to see to help me, like the ini file in question, just ask and I will deliver.
  • 0

#2 TsukaYuriko

TsukaYuriko

    GMC Member

  • GMC Member
  • 510 posts
  • Version:GM:Studio

Posted 09 June 2012 - 11:02 PM

score1=ini_write_real('highscores','score1',ds_grid_get(score_grid,0,0))


You are assigning a function which doesn't return anything to a variable. What do you want this line of code to do, exactly? If you just want to save those five variables to the ini file, remove the "score[n]=" parts.

Edited by TsukaYuriko, 09 June 2012 - 11:05 PM.

  • 0

#3 snuffysam

snuffysam

    GMC Member

  • GMC Member
  • 132 posts
  • Version:GM7

Posted 09 June 2012 - 11:08 PM

score1=ini_write_real('highscores','score1',ds_grid_get(score_grid,0,0))


You are assigning a function which doesn't return anything to a variable. What do you want this line of code to do, exactly? If you just want to save those five variables to the ini file, remove the "score[n]=" parts.

That was the problem! Thanks!
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users