Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > New Scripting Engine (GS2)
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 04-23-2006, 09:33 PM
Andy0687 Andy0687 is offline
Enigma
Join Date: Feb 2002
Posts: 1,072
Andy0687 is on a distinguished road
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?
Reply With Quote
  #2  
Old 04-23-2006, 10:05 PM
Yen Yen is offline
Banned
Yen's Avatar
Join Date: Oct 2005
Location: Nova Scotia, Canada
Posts: 1,085
Yen is an unknown quantity at this point
Send a message via AIM to Yen Send a message via MSN to 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.
Reply With Quote
  #3  
Old 04-24-2006, 03:38 AM
Ajira Ajira is offline
Poont.
Join Date: Oct 2004
Location: NY, USA
Posts: 477
Ajira is on a distinguished road
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
__________________
Liek omigosh.

Reply With Quote
  #4  
Old 04-24-2006, 05:35 AM
Andy0687 Andy0687 is offline
Enigma
Join Date: Feb 2002
Posts: 1,072
Andy0687 is on a distinguished road
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.
Reply With Quote
  #5  
Old 04-25-2006, 07:39 PM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
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! :]
__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
Reply With Quote
  #6  
Old 04-25-2006, 07:43 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
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.
__________________
Skyld
Reply With Quote
  #7  
Old 04-26-2006, 04:40 PM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
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.
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
Reply With Quote
  #8  
Old 04-26-2006, 04:46 PM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
Quote:
Originally Posted by Skyld
So essentially, loadvars.
Yes, but still
__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 01:17 PM.


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