Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   text files (https://forums.graalonline.com/forums/showthread.php?t=69687)

Chompy 10-26-2006 08:14 PM

text files
 
I wondered on something, how do I load an text file
with like for exmaple: obj.loadvars("path"); and
edit one member of the file?

obj = {"foo", "bar"};
obj.savelines("path", 0);

saves like all the members of the array into the file,
but how to edit one single member?

xAndrewx 10-26-2006 08:47 PM

Use
obj.replace(index, replacewith) [I think]
or to delete
obj.delete(index)

Chompy 10-26-2006 08:49 PM

will that work on files like an .txt file in levels/blah/blah/?

I'll try it though :]

xAndrewx 10-26-2006 08:57 PM

Should do =D

Chompy 10-26-2006 09:06 PM

darn, didn't work :[

Rapidwolve 10-26-2006 11:54 PM

Ohhh thats how to do it
PHP Code:

 obj.replace() 

I was trying to figure it out too...

Quote:

Originally Posted by Chompy
darn, didn't work :[

X_X guess I shouldnt try

xAndrewx 10-27-2006 08:03 AM

Hm, paste what you're doing exactly? I'm sure it should work o_O

Chompy 10-27-2006 03:18 PM

I tried

PHP Code:

temp.obj.loadvars("levels/testfiles/objects.txt");
temp.obj.replace(0"test");
sendtorc("/refreshfilelist"); 

the first var/member of the file is "testing",
but when I open it, its still "testing" when its suppose to be "test"

but isn't obj.replace(index, string); for arrays?

btw, anyone knows?

xAndrewx 10-27-2006 09:15 PM

Quote:

Originally Posted by Chompy (Post 1236642)
I tried

PHP Code:

temp.obj.loadvars("levels/testfiles/objects.txt");
temp.obj.replace(0"test");
sendtorc("/refreshfilelist"); 

the first var/member of the file is "testing",
but when I open it, its still "testing" when its suppose to be "test"

but isn't obj.replace(index, string); for arrays?

btw, anyone knows?

Ok, now paste the var's inside of the file.

Chompy 10-27-2006 09:35 PM

I found an method by searching for "savelines" :O
btw, Yen posted about this in that thread I found :]

PHP Code:

temp.obj = new TStaticVar();
with (temp.obj)
  
this.player_money "test";
temp.obj.savevars("levels/options/playermoney/.txt"0); 
sendtorc("/refreshfilelist"); 

works, but it adds all this:
HTML Code:

joinedclasses=
player_money=test
scriptlogmissingfunctions=false
timeout=0

will that change anything to it (when adding more, editing it, using it in a script)?

xAndrewx 10-27-2006 09:40 PM

Quote:

Originally Posted by Chompy (Post 1236731)
I found an method by searching for "savelines" :O
btw, Yen posted about this in that thread I found :]

PHP Code:

temp.obj = new TStaticVar();
with (temp.obj)
  
this.player_money="test"

works, but it adds all this:
HTML Code:

joinedclasses=
player_money=test
scriptlogmissingfunctions=false
timeout=0

will that change anything to it?

Get dynamic vars, can use to find each individual one

Chompy 10-27-2006 09:47 PM

Quote:

Originally Posted by xAndrewx (Post 1236734)
Get dynamic vars, can use to find each individual one

got an example I can use/learn from?

xAndrewx 10-27-2006 09:49 PM

Should do
player_money = temp.fileLoaded.player_money;
player_money = "new test";
saveStuff? (I think...)


All times are GMT +2. The time now is 02:51 AM.

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