GameMaker Reading off an ini file

S

Sardec Xavier

Guest
Can someone help me with this? I am getting a problem where I am trying to save controls to an ini file and load them back in so I can have custom control schemes. This is what I have so far:
Code:
//Set up player controls lists
var buttonTotal = 12;
global.controlList = array_create(4)
global.controlList[0] = array_create(buttonTotal);
global.controlList[1] = array_create(buttonTotal);
global.controlList[2] = array_create(buttonTotal);
global.controlList[3] = array_create(buttonTotal);
controlNames = script_execute( scr_control_names, buttonTotal );
//Check for a load file for previously saved controls
ini_open("control.sav");
//For every player...
for ( var controlId = 0; controlId < 4; controlId++ )
{
    //Go through every button
    for( var loc = 0; loc < buttonTotal; loc++ )
    {
        // Read in the right controls from the button ID off the save file, if they don't exist, it will give the value of the buttone from a default conrol scheme
        var buttonId = controlNames[loc];
        var readButton = ini_read_real( "Player: " + string(controlId), buttonId, scr_default_controls( loc ) )
        // show_debug_message( string(readButton) +" : " + string(loc) );
        global.controlList[controlId][loc] = readButton;
        ini_write_real( "Player:" + string(controlId), buttonId, global.controlList[controlId][loc] );
    }
}
//Glose the save file that is open
ini_close();
//Goto the main menu room
room_goto( rm_title_screen );
scr_default_controls
Code:
///Default control scheme for the game
var defaultList = array_create(12);
defaultList[0] = gp_shoulderrb;        // Shoot = RT
defaultList[1] = gp_shoulderr;        // LedgeHang = RB 
defaultList[2] = gp_face4;            // Toggle = Y
defaultList[3] = gp_face3;            // Interact = X
defaultList[4] = gp_face1;            // Jump = A
defaultList[5] = gp_axislh;            // Move Left = LS
defaultList[6] = gp_axislh;            // Move Right = LS
defaultList[7] = gp_axislv;            // Aim Up = LS
defaultList[8] = gp_axislv;            // Aim Down = LS
defaultList[9] = gp_stickl;            // Sprint = LSB
defaultList[10] = gp_shoulderl;        // Aim Diup = LT
defaultList[11] = gp_shoulderlb;    // Aim Didown = LB
//Set Controls
return defaultList[ argument0 ];
I am getting an error at Line 25 that says two things
  1. Assignment operator expected
  2. Malformed Assignment statement
Any ideas as to why this occuring or how I could fix this? Thanks
 

FrostyCat

Redemption Seeker
Chained accessors are not supported yet, so this part is invalid:
Code:
global.controlList[controlId][loc] = readButton;
ini_write_real( "Player:" + string(controlId), buttonId, global.controlList[controlId][loc] );
You should store the first level in a local variable first, then use that to get at the second level.
Code:
//For every player...
for ( var controlId = 0; controlId < 4; controlId++ )
{
   var _controlList = global.controlList[controlId];
   //Go through every button
   for( var loc = 0; loc < buttonTotal; loc++ )
   {
       // Read in the right controls from the button ID off the save file, if they don't exist, it will give the value of the buttone from a default conrol scheme
       var buttonId = controlNames[loc];
       var readButton = ini_read_real( "Player: " + string(controlId), buttonId, scr_default_controls( loc ) )
       // show_debug_message( string(readButton) +" : " + string(loc) );
       _controlList[@ loc] = readButton;
       ini_write_real( "Player:" + string(controlId), buttonId, readButton );
   }
}
 
Top