Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   New Scripting Engine (GS2) (https://forums.graalonline.com/forums/forumdisplay.php?f=153)
-   -   loadlines (https://forums.graalonline.com/forums/showthread.php?t=65610)

Andy0687 04-23-2006 09:33 PM

loadlines
 
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.

Quote:

Originally Posted by File
[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 10: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 03:38 AM

Quote:

Originally Posted by Yen
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 05:35 AM

Quote:

Originally Posted by Yen
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 07:39 PM

IŽll give you another example.

Say that the file looks like this:

NPC Code:

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



NPC Code:

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 07:43 PM

Quote:

Originally Posted by xXziroXx
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 04: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 04:46 PM

Quote:

Originally Posted by Skyld
So essentially, loadvars.

Yes, but still :p


All times are GMT +2. The time now is 04:15 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.