1. Hey! Guest! The 34th GMC Jam will take place between August 22nd, 12:00 UTC (Thursday noon) and August 26th, 12:00 UTC (Monday noon). Why not join in! Click here to find out more!
    Dismiss Notice

Problems with reading "save.ini"

Discussion in 'Programming' started by Mihaugoku, Jan 24, 2018.

  1. Mihaugoku

    Mihaugoku Member

    Joined:
    Jan 10, 2018
    Posts:
    12
    I made a very simple test save/load system using a ".ini" file. Using "ini_write_real" and "ini_write_string" i wrote some simple variables, and they do work fine (screenshot 1, rmname being the saved room i'm in).

    [​IMG]

    However, when i try reading the written save, the room just restarts (if the file exists. If not, the game goes to rm_lv1 as stated in code).

    [​IMG]

    What am i doing wrong? Haven't been able to figure this out for a while now.
     
  2. obscene

    obscene Member

    Joined:
    Jun 21, 2016
    Posts:
    2,402
    What I think is happening is room_goto() expects a constant, not a string. If you're not familiar with the concept, rm_b2 and "rm_b2" are two different things. Because you have created a room called rm_b2 in your project, GM has automatically created a constant... rm_b2, which actually holds a variable like 5 or something. 5 would be the actual ID of the room. So when you say room_goto(rm_b2), GM actually reads that as room_goto(5).

    A string on the other hand is a word. room_goto("rm_b2") doesn't actually tell GM which number of room to go to and so I'm assuming it's restarting the room instead of throwing an error which would have been more helpful in this case.

    So you can fix this one of two ways. Save your room as an real number, or use asset_get_index(rmname) which would convert your string back into an ID.
     
  3. Mihaugoku

    Mihaugoku Member

    Joined:
    Jan 10, 2018
    Posts:
    12
    Thanks! I didn't know it expected the actual ID, so that's where it went wrong. It all works fine now!
     

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