• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GameMaker Load ini problem

R

Raff

Guest
Hello !!

I'm trying to read room name info from an ini file. Using room_goto(name) next error happen:
"room_goto argument 1 incorrect type (string) expecting a Number (YYGI32)
at gml_Script_sc_load (line 16) - room_goto(name);" but if i try to convert this string to a number then this error happen:
"unable to convert string "room1_1" to number
at gml_Script_sc_load (line 16) - room_goto(real(name))"; ini file just can read string or real. So how can i do to load the room, because if i put room_goto(room1_1) of course, it works, but i wat to use the saved file. Thanks.
 
H

Homunculus

Guest
You should output the value of the saved room to the console, or directly open the ini file in a text editor.

You are probably saving the room name (as a string) to the file, therefore you can’t convert it to an actual room id (numeric value) using real, nor use it as it is since you probably don’t expect something lile room_goto(“room1_1”) to work either.

The solution to that is what frostycat suggested, convert the room name to an index using asset_get_index
 
R

Raff

Guest
Yes, it works, i can load the room now, thank you, but the player is appearing in the initial position insted the saved one, using the same way:
var px = ini_read_real("player", "x", 0);
.
.
.


if(instance_exists(ob_player))
{
ob_player.x = px;
.
.
.
}
what am i doing wrong here ?
 
H

Homunculus

Guest
In that piece of code, nothing. Have you checked the actual value in the ini file by opening ot? Have you made sure the if condition is entred by using a show_debig_message or something similar?
 
R

Raff

Guest
Solved, thank you.

Yes, Catan, the information is correctly saved and loaded. The solution i found is to load the room when selects continue in the menu and take in a global variable the menu option value. If the value is 0, that correspond to continue, then replace the player, if not, then the player appears at the initial place. If i try to load the room and reposition the player from the same place, it loads the room, but the player is not repositioned. may be not the best way but it works by now. Thanks everybody.
 
Top