First time saving

Discussion in 'Programming' started by P4yin, Oct 10, 2019.

  1. P4yin

    P4yin Member

    Joined:
    Oct 10, 2019
    Posts:
    5
    Hello, I am new to gamemaker and community here. While trying to create an ini file for saving, i'm having issues with saving what room im in. Using a variable, and making it equal to room, it is saying that the equals sign is unexpected. What should i do?
     
  2. chamaeleon

    chamaeleon Member

    Joined:
    Jun 21, 2016
    Posts:
    976
    What you should do is post the code and error message so there is something concrete to analyze.
     
  3. P4yin

    P4yin Member

    Joined:
    Oct 10, 2019
    Posts:
    5
    sorry about that!
    Here it is:
    var SavedRoom = room;
    i was following the saving and loading ini files tutorial
    EDIT: the equals sign used here is the once referenced above
     
  4. chamaeleon

    chamaeleon Member

    Joined:
    Jun 21, 2016
    Posts:
    976
    That line in isolation will not yield an error. Something else is tripping you up.
     
  5. P4yin

    P4yin Member

    Joined:
    Oct 10, 2019
    Posts:
    5
    This is all i have

    if (file_exists("Raj.sav")) file_delete("Raj.sav");
    ini_open ("Raj.sav");
    var SavedRoom = room;
    ini_write_real ("Save1","room",SavedRoom);
    ini_close();
    Edit: The error says "ERROR at line 3 pos 16: Unexpected symbol in expression."
     
  6. chamaeleon

    chamaeleon Member

    Joined:
    Jun 21, 2016
    Posts:
    976
    Copy-pasting that ran fine, and reading in the room number using ini_read_real() returned the written number.
     
  7. P4yin

    P4yin Member

    Joined:
    Oct 10, 2019
    Posts:
    5
    so I should not need var SavedRoom = room; then?
     
  8. FrostyCat

    FrostyCat Member

    Joined:
    Jun 26, 2016
    Posts:
    4,556
    If your GM won't accept that syntax, split it into 2 lines. This is the required procedure for legacy versions of GM (8.1 and below).
    Code:
    var SavedRoom;
    SavedRoom = room;
    
    Though in your situation, there's no point for that line. You can just do this:
    Code:
    ini_write_real("Save1", "room", room);
    
    Please, if you're just starting out with GM, don't use ancient versions. Modern tutorials won't work on them, and you can't get help properly with them.
     
    IndianaBones likes this.
  9. IndianaBones

    IndianaBones Member

    Joined:
    Jul 5, 2016
    Posts:
    2,220
    What version of Game Maker are you using, I think some older versions didn't support assigning a value on the same line that you declared them.

    But yes, you could skip using SavedRoom and just use room directly in your ini_write_real() function.
     
  10. chamaeleon

    chamaeleon Member

    Joined:
    Jun 21, 2016
    Posts:
    976
    And needless to say, saving the room number would not be reliable between versions of games if you change the order, or add or remove rooms.
     
  11. P4yin

    P4yin Member

    Joined:
    Oct 10, 2019
    Posts:
    5
    Thanks for the help! Im still on GM 8.0 pro but am thinking of upgrading
     

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