PDA

View Full Version : loadlines


Andy0687
04-23-2006, 10:33 PM
Is it possible to use loadlines to read from say a key in an ini file?
Having a little trouble figuring out how if it is possible, this is what im talking about.


[Move]
up=w
down=s
left=a
right=d
[Strafe]
left=q
right=e


An Example.
Then i wanted to load the contents of the file, and only get the values under [Move].

I tried loading the lines and searching for "[Move]' then just isolating the contents under that, trying to find the = signs, and hunt the stuff on each side, but I discovered I am doing that either, wrong, or too complicated.

Can GS2 do this easier?

Yen
04-23-2006, 11:05 PM
loadvars() dumps them into an object as variables.

keyconfig.loadvars("file");

keyconfig.up=w
keyconfig.down=s
And so on

I heard from someone that the [] labels have some effect on how it loads, but I haven't tried.

Ajira
04-24-2006, 04:38 AM
I heard from someone that the [] labels have some effect on how it loads, but I haven't tried.
Just do like [MOVE]=1 [STRAFE]=1
Just add a value to it and it should be fine

Andy0687
04-24-2006, 06:35 AM
loadvars() dumps them into an object as variables.

keyconfig.loadvars("file");

keyconfig.up=w
keyconfig.down=s
And so on

I heard from someone that the [] labels have some effect on how it loads, but I haven't tried.

Thanks but the [] labels were what i was thinking I had to use to keep them togather, using your method i was hoping to get something like

keyconfig.movement.up=w

Although now I guess I see the way I can do it is much easier then what i was thinking in the first place, thanks.

xXziroXx
04-25-2006, 08:39 PM
IŽll give you another example.

Say that the file looks like this:


up=w
left=a
down=s
right=d



for onActionServerSide( action)
{
if ( action == "GetDataFromFile" ) {
this.data.loadlines("levels/keyconfig.txt");
clientr.keysettings = this.data;
}
}


Although you maybe dont need yet another example, here you go! :]

Skyld
04-25-2006, 08:43 PM
IŽll give you another example.

Say that the file looks like this:

...

Although you maybe dont need yet another example, here you go! :]
So essentially, loadvars.

ApothiX
04-26-2006, 05:40 PM
What you can do is use loadlines to search for the [Move], and then isolate all things under move by doing a check for another [ or so (or perhaps even doign something like: [Move] {
crap here
} and checking for '}') and put that stuff into another array using temp.blah.add(temp.lines[i]); or so. You can then use var.loadvarsfromarray(temp.blah) to convert all of the = lines into members of the object.

xXziroXx
04-26-2006, 05:46 PM
So essentially, loadvars.

Yes, but still :p