The online racing simulator
Array Problems
(4 posts, started , go to first unread)
Array Problems
Hello everyone!

I was working on a button that would open in different locations for different maps using GlobalVar.
But unfortunately, I could not get it to work either because of my mistakes or Lapper in general isn't able to do this.

Here's the source.

<?php 
    GlobalVar $ButtonPosition
;
    
$ButtonPosition["SO1X","GPS_Location1"] = "104,37,77,6,6,-1,128";
?>

That's the button's position, size, style etc..


<?php 
    
CASE "!btn123":
        
$Track GetLapperVar("ShortTrackName");
        
$GPS_Location GetPlayerVar($userName,"GPSLocation");
        
PrivMsg($ButtonPosition[$Track,$GPS_Location]); #Debug
        
OpenButton($userName,"btn_pos",$ButtonPosition[$Track,$GPS_Location],"^1Button!");
    BREAK;
?>

The PrivMsg obviously works, but the button shows me some incorrect number of parameters in the errorlog file.

I have tried many ways such as putting "". and ."" at the beginning and end of $ButtonPosition but came to no luck.

Your help is always appreciated.
** Best answer **
When an array-value is inserted, it is seen by Lapper as one value, instead of a bunch of several values, needed to form a button from.
To work around that, I've splitted that one value into several values using the SplitToArray function.
After that, I've inserted each of the splitted values and then the button is working.


<?php 
        
CASE "!btn123":
            
$Track GetLapperVar("ShortTrackName");
            
$GPS_Location GetPlayerVar($userName,"GPSLocation");
            
PrivMsg($ButtonPosition[$Track,$GPS_Location]); #Debug
            
            
$split SplitToArray(  $ButtonPosition[$Track,$GPS_Location],"," );

            
OpenButton($userName,"btn_pos",$split[0],$split[1],$split[2],$split[3],$split[4],$split[5],$split[6],"^1Button!");
        BREAK;
?>

Quote from Yisc[NL] :When an array-value is inserted, it is seen by Lapper as one value, instead of a bunch of several values, needed to form a button from.
To work around that, I've splitted that one value into several values using the SplitToArray function.
After that, I've inserted each of the splitted values and then the button is working.


<?php 
        
CASE "!btn123":
            
$Track GetLapperVar("ShortTrackName");
            
$GPS_Location GetPlayerVar($userName,"GPSLocation");
            
PrivMsg($ButtonPosition[$Track,$GPS_Location]); #Debug
            
            
$split SplitToArray(  $ButtonPosition[$Track,$GPS_Location],"," );

            
OpenButton($userName,"btn_pos",$split[0],$split[1],$split[2],$split[3],$split[4],$split[5],$split[6],"^1Button!");
        BREAK;
?>


Legend. thank you so much.
Moved the thread to 'Scripting Help' forum , as the other that Iceman121 has created.

Array Problems
(4 posts, started )
FGED GREDG RDFGDR GSFDG