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

Discussion in 'Legacy GameMaker Community Tech Support' started by Schmittez, Jan 8, 2019.

  1. Schmittez

    Schmittez Member

    Joined:
    Jan 8, 2019
    Posts:
    4
    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.
     
  2. IndianaBones

    IndianaBones Member

    Joined:
    Jul 5, 2016
    Posts:
    1,930
    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.
     
  3. Schmittez

    Schmittez Member

    Joined:
    Jan 8, 2019
    Posts:
    4
    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.
     
  4. IndianaBones

    IndianaBones Member

    Joined:
    Jul 5, 2016
    Posts:
    1,930
    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"?
     
  5. Schmittez

    Schmittez Member

    Joined:
    Jan 8, 2019
    Posts:
    4

    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: Jan 9, 2019
  6. IndianaBones

    IndianaBones Member

    Joined:
    Jul 5, 2016
    Posts:
    1,930
    Obvious question, but are you closing the ini file after writing to it?
     
  7. Schmittez

    Schmittez Member

    Joined:
    Jan 8, 2019
    Posts:
    4
    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: Jan 9, 2019
    IndianaBones likes this.
  8. IndianaBones

    IndianaBones Member

    Joined:
    Jul 5, 2016
    Posts:
    1,930
    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.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice