Hello Guest, please login or register.
Did you miss your activation email?
Login with username, password and session length.

Pages: [1]   Go Down

Author Topic: Small INI issue.  (Read 3598 times)

0 Members and 1 Guest are viewing this topic.
Small INI issue.
« on: February 05, 2014, 02:16:19 am »
  • *
  • Reputation: +2/-0
  • Offline Offline
  • Gender: Male
  • Posts: 269
Hello all. I am designing a small little game to take a break from FOH and get a bit better at coding in general, and i have gotten to a point where i need to start saving a little bit of data(just max health, money, upgrades, etc. its like a temple run type game.) and i have never worked with these for saving. i understand how to write them and how to read them with code, but i have one issue. creating it and putting starting data in it. is there an easy way to say like
if the INI doesnt exist/is blank/whatever or if this global.maxhp is undefined then global.maxhp = 1 or whatever?

or is there a better way to get save data of just a few variables into the game? I am thinking of porting this game to HTML or something, maybe IPhone if i spend enough time on it. is there a way of saving that would work no matter the system? or atleast works with regular gm and then the in web browser version?
Logged

Jeod

Team Dekunutz, Doubleteam
Re: Small INI issue.
« Reply #1 on: February 05, 2014, 03:20:12 am »
  • *
  • Reputation: +3/-0
  • Offline Offline
  • Gender: Male
  • Posts: 1675
You would either ship the ini file with your executable and encrypt it, or you would need to write the ini file from GM as if it were a text document, save it with the .ini extension, and then read from it.
Logged
"You should challenge your fates. When all else fails, you can still die fighting." ~Yune
___________________________________

Zelda GBC+ Engine for Multimedia Fusion 2
  • Doubleteam Project Page
Re: Small INI issue.
« Reply #2 on: February 05, 2014, 01:00:48 pm »
  • Doesn't afraid of anything
  • *
  • Reputation: +42/-0
  • Offline Offline
  • Gender: Male
  • Posts: 7002
Encrypting it would be silly.  I see the purpose, but it's not like a game is a high security environment.  Plus it will slow down loading.

Otherwise, it's simple enough like Jeod said to just write it as a text file from GM or whatever language you're using.
Logged



i love big weenies and i cannot lie
Re: Small INI issue.
« Reply #3 on: February 05, 2014, 03:15:51 pm »
  • *
  • Reputation: +12/-2
  • Offline Offline
  • Gender: Male
  • Posts: 4849
What I usually do:


Code: [Select]
if file_exists("gameData.ini")
{
      //do all my loading here - I will call my global loading of the ini here as well usually on the title/start screen
     global.saveFile = ini_open("gameData.ini");
     //finish loading each variable or you could just have the game load from the ini on the fly instead of loading into global variables
}
else
{
     //Game Maker 8.1 and older
     temp = file_open_write("gameData.ini");
      file_close(temp);
      global.saveFile = ini_open("gameData.ini");
     //Game Maker Studio
    ini_open("gameData.ini");
      //note that GMS only creates the ini if you write data to it so you should have your keys created after you open the ini
}








That code isn't perfect as I haven't used it in a while and I no longer have GM 8 installed to check it.  GM Studio changed the file system and it seems a bit wonky.  You should look into the manual if you are using GMS as it already includes many levels of encryption standard now from base64 upto SHA-1.
Logged
  • Super Fan Gamers!
Re: Small INI issue.
« Reply #4 on: February 08, 2014, 05:03:55 am »
  • *
  • Reputation: +2/-0
  • Offline Offline
  • Gender: Male
  • Posts: 269
Thank you both, i will try those suggestions. I am in Game Maker 8 but wish to transfer over to GMS, so i may as well do that sooner or later. thank you both for the replies!
Logged
Pages: [1]   Go Up

 


Contact Us | Legal | Advertise Here
2013 © ZFGC, All Rights Reserved



Page created in 0.061 seconds with 45 queries.