• 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!
  • Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Legacy GM SOLVED INI file just will not generate if I run the same script from a different place

S

Schmittez

Guest
So I have a script to save some information and using a input from the user. If I run the exact same piece of code in one location say the step event of one object if works exactly how expected, but if I run it from a different objects step event it runs the script fine but doesn't generate the ini file.

I have both an mouse_pressed event and a enter released even for this if I click the mouse and it doesn't save the ini file. if I change nothing not even move the mouse and just pressed enter so all variables are exactly the same it saves the ini file fine.

the only difference is which objects step even it occurs in.

I want to to run the the second objects step even so because that same "button" does different things depending on the room so I am trying to put in all with in the code for the "button" in the same place.
 
How do you know the script is running in the second object if the ini file is not being generated.

Perhaps post your code as well so it can be checked.
 
S

Schmittez

Guest
How do you know the script is running in the second object if the ini file is not being generated.

Perhaps post your code as well so it can be checked.
because it starts showing the variables created by the script.


if mouse_x < (room_width/2 + 70) && mouse_x > (room_width/2 - 70) && mouse_y < (room_height/2 + 64) && mouse_y > (room_height/2 + 32) && mouse_check_button_pressed(mb_left)
{

if (room_get_name(room) == "rm_levelCreator")
{
if (global.saving == 1 && global.holeExists == 1 && global.startExists == 1)
{
scr_saver();
}
else
{
message = 1;
}
}

---------------------------- not this part-------------------------------------------
if (room_get_name(room) == "rm_mainMenu")
{
if (file_exists(global.userString + ".ini"))
{
global.newRoom = room_duplicate(rm_blank);
room_goto(global.newRoom);
}
else
{
message = 1;
}
}
----------------------------------------------------------------------------------------
}
thats the code where it doesnt work. its in the step event of an object also the second if statement works perfectly fine.


this is the code where it works. it is in the step event of a different object.

if mouse_x < (room_width/2 + 70) && mouse_x > (room_width/2 - 70) && mouse_y < (room_height/2 + 64) && mouse_y > (room_height/2 + 32) && mouse_check_button_pressed(mb_left)
{
if (room_get_name(room) == "rm_levelCreator")
{
if (global.saving == 1 && global.holeExists == 1 && global.startExists == 1)
{
scr_saver();
}
else
{
message = 1;
}
}
}

it is literally the same code copy and pasted to a different object step event.
 
I would use the debugger and step through the code to make sure its working. Put breakpoints where you are checking if the room name is rm_levelCreator.

Other things to try if you don't use the debugger : put show_debug_message() functions (with appropriate messages) before and after all the if() statements, find out if they are all printing out or not, it will give you a clue what is happening.

What is the code for scr_saver() - maybe there is something in there that causes issues.

I assume that these two objects are both being used in the same room called "rm_levelCreator"?
 
S

Schmittez

Guest
I would use the debugger and step through the code to make sure its working. Put breakpoints where you are checking if the room name is rm_levelCreator.

Other things to try if you don't use the debugger : put show_debug_message() functions (with appropriate messages) before and after all the if() statements, find out if they are all printing out or not, it will give you a clue what is happening.

What is the code for scr_saver() - maybe there is something in there that causes issues.

I assume that these two objects are both being used in the same room called "rm_levelCreator"?

I have been using the debugger that's how I know the script is definitely running, it creates and change all the variables associated with the script, the scr_saver() script runs perfectly fine if I use other methods to start it.

and like I said if I run the identical code in a different objects step even it works perfectly fine.

Yes both objects are in the same room. (rm_levelCreator) one of the objects creates the other, but as far as I can tell that has nothing to do with the problem.

Its hard to explain in text exactly what the problem is, I might make a quick video to better show the problem.

-------------------------------------------------------------------
Well I think I have found the problem, it was because one object had a collision mask where as the other didnt so when it ran the script in one object when it check for a collision it had no mask to check with so it always return no collision where as the other object did have a collision mask so it would return != noone when a collision occured

Thanks for trying to help anyway. I haven't actually tested this yet but I'm about 97.36% sure that's what the problem is
 
Last edited by a moderator:
S

Schmittez

Guest
I just tested it with my fix and it works now, thanks for trying to help tho.
-----------------------------------------------------------------------------------
Not trying to help, you did actually help. Not buy giving me a solution, but by making me think about things I never would of considered before. I have been trying to get this to work like this for a days now on and off.
 
Last edited by a moderator:
You're welcome. Sometimes just writing the problem down or sharing it with someone results in a solution appearing. Glad to hear you managed to solve it.
 
Top