Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 12-11-2005, 06:33 AM
jake13jake jake13jake is offline
Former Classic Staff
jake13jake's Avatar
Join Date: Dec 2002
Location: Northwest Vermont
Posts: 1,452
jake13jake will become famous soon enough
Reading from a txt file?

Is there any function that grabs strings from a text file? I've tried looking through the -RC script, but I don't quite grasp what's going on. I just really think that having a message system that can incorporate longer messages than the server vars can handle would be really useful.
Reply With Quote
  #2  
Old 12-11-2005, 06:58 AM
ZeLpH_MyStiK ZeLpH_MyStiK is offline
Scripter
ZeLpH_MyStiK's Avatar
Join Date: May 2003
Location: NYC
Posts: 553
ZeLpH_MyStiK is on a distinguished road
Send a message via MSN to ZeLpH_MyStiK Send a message via Yahoo to ZeLpH_MyStiK
There exists no known means of doing this in gs1.
__________________
Reply With Quote
  #3  
Old 12-11-2005, 08:24 AM
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
PHP Code:
object.loadvars(path); 
members.loadvars("levels/blah/something.txt");

--CONTENTS OF SOMETHING.TXT--
stuff=3
arf=8
hello="Hi there!"
omg=Yellow,Blue,Red

members.stuff would be 3
members.arf would be 8
members.hellow would be 'Hi there!'
members.omg would be an array containing 'Yellow,' 'Blue,' and 'Red.'

You can get the list of variables it loaded with object.getstringkeys("members");
I don't recall if you need a . after members or not. :/
Reply With Quote
  #4  
Old 12-11-2005, 08:34 AM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
Quote:
Originally Posted by Yen
PHP Code:
object.loadvars(path); 
members.loadvars("levels/blah/something.txt");

--CONTENTS OF SOMETHING.TXT--
stuff=3
arf=8
hello="Hi there!"
omg=Yellow,Blue,Red

members.stuff would be 3
members.arf would be 8
members.hellow would be 'Hi there!'
members.omg would be an array containing 'Yellow,' 'Blue,' and 'Red.'

You can get the list of variables it loaded with object.getstringkeys("members");
I don't recall if you need a . after members or not. :/
There's a way to load textfiles without blah=blah in it too, I just can't remember off the top of my head how to do it

This post should have been in the GScript2 sub-forum, though.
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
Reply With Quote
  #5  
Old 12-11-2005, 08:41 AM
jake13jake jake13jake is offline
Former Classic Staff
jake13jake's Avatar
Join Date: Dec 2002
Location: Northwest Vermont
Posts: 1,452
jake13jake will become famous soon enough
Quote:
Originally Posted by ApothiX
This post should have been in the GScript2 sub-forum, though.
I would have put it there if I had known that loading from a text file was specifically a gscript2 issue.
Reply With Quote
  #6  
Old 12-11-2005, 08:45 AM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
Quote:
Originally Posted by jake13jake
I would have put it there if I had known that loading from a text file was specifically a gscript2 issue.
It is, indeed.

I was looking through the wiki, and I think what you might be looking for is:

variable.loadlines("filename");

Graal doesn't work on my computer right now, but if memory serves me, it should be something like:
HTML Code:
--levels/test.txt--
Testing 123
Abcdefgh
PHP Code:
this.test.loadlines("levels/test.txt");
echo(
"Line 1: " this.test[0]);
echo(
"Line 2: " this.test[1]); 
Should output:
HTML Code:
Line 1: Testing 123
Line 2: Abcdefgh
(Someone please correct me if I'm wrong)
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
Reply With Quote
  #7  
Old 12-11-2005, 09:37 AM
jake13jake jake13jake is offline
Former Classic Staff
jake13jake's Avatar
Join Date: Dec 2002
Location: Northwest Vermont
Posts: 1,452
jake13jake will become famous soon enough
That indeed works. Thanks Apoth.
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 07:21 AM.


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