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

GML any tips on how to improve my ini writing file for configs?

Discussion in 'Programming' started by jobjorgos, May 28, 2018.

  1. jobjorgos

    jobjorgos Member

    Joined:
    Jun 23, 2016
    Posts:
    147
    Hey I made a config.ini file for my game where players can store there configuration preferences and that keep them for next time when the player launch the application.
    Im afraid the text that gets written in the INI file is a bit too messy. Any tip to imrpove this?
    I also dont understand why there is no row of space after every section.
    And I didnot allow players to change the resolution to any size they want, because I only made specify resolution options.

    For this I use the following code:
    Code:
    ini_open("config.ini");  
        ini_write_string("0=+/- 1=I/O", "setzoom", 0);
        ini_write_string("0=enter", "setenterkey", 0);
        ini_write_string("0=mouse", "setmouse", 0);
        ini_write_string("0=shift", "setshiftkey", 0);
        ini_write_string("0=z", "setzkey", 0);
        ini_write_string("0=space", "setspacekey", 0);
        ini_write_string("0=arrow keys 1=W,A,S,D", "setkeys", 0);
        ini_write_string("0=OFF 1=letter gamepad 2=number gamepad", "setjoystick", 0);
        ini_write_string("0=100% 1=90% 2=80% 3=70% 4=60% 5=50% 6=40% 7=30% 8=20% 9=10% 10=0%", "setsfx", 0);
        ini_write_string("0=100% 1=90% 2=80% 3=70% 4=60% 5=50% 6=40% 7=30% 8=20% 9=10% 10=0%", "setmusic", 0);
        ini_write_string("0=celcius 1=fahrenheit", "settemperature", 0);
        ini_write_string("0=show XP on hover 1=show XP always", "setxp", 0);
        ini_write_string("0=show HP on hover 1=show HP always", "sethp", 1);
        ini_write_string("0=24hour clock 1=12hour clock", "clock", 0);
        ini_write_string("0=english", "language", 0);
        ini_write_string("1024x768 / 1280x800 / 1280x1024 / 1360x768 / 1366x768 / 1440x900 / 1536x864 / 1600x900 / 1680x1050 / 1920x1080","resolution", 1024768);
        ini_write_string("0=OFF 1=ON", "fullscreen", 1);  
    ini_close();
    And if I open the config.ini file it shows this:

    [0=OFF 1=ON]
    fullscreen="1"
    [1024x768 / 1280x800 / 1280x1024 / 1360x768 / 1366x768 / 1440x900 / 1536x864 / 1600x900 / 1680x1050 / 1920x1080]
    resolution="1024768"
    [0=english]
    language="0"
    [0=24hour clock 1=12hour clock]
    clock="0"
    [0=show HP on hover 1=show HP always]
    sethp="1"
    [0=show XP on hover 1=show XP always]
    setxp="0"
    [0=celcius 1=fahrenheit]
    settemperature="0"
    [0=100% 1=90% 2=80% 3=70% 4=60% 5=50% 6=40% 7=30% 8=20% 9=10% 10=0%]
    setmusic="0"
    setsfx="0"
    [0=OFF 1=letter gamepad 2=number gamepad]
    setjoystick="0"
    [0=arrow keys 1=W,A,S,D]
    setkeys="0"
    [0=space]
    setspacekey="0"
    [0=z]
    setzkey="0"
    [0=shift]
    setshiftkey="0"
    [0=mouse]
    setmouse="0"
    [0=enter]
    setenterkey="0"
    [0=+/- 1=I/O]
    setzoom="0"
     

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