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 10-26-2006, 08:14 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
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?
__________________
Reply With Quote
  #2  
Old 10-26-2006, 08:47 PM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
Use
obj.replace(index, replacewith) [I think]
or to delete
obj.delete(index)
__________________
Reply With Quote
  #3  
Old 10-26-2006, 08:49 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
will that work on files like an .txt file in levels/blah/blah/?

I'll try it though :]
__________________
Reply With Quote
  #4  
Old 10-26-2006, 08:57 PM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
Should do =D
__________________
Reply With Quote
  #5  
Old 10-26-2006, 09:06 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
darn, didn't work :[
__________________
Reply With Quote
  #6  
Old 10-26-2006, 11:54 PM
Rapidwolve Rapidwolve is offline
Registered User
Join Date: Jul 2006
Posts: 1,241
Rapidwolve is an unknown quantity at this point
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
Reply With Quote
  #7  
Old 10-27-2006, 08:03 AM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
Hm, paste what you're doing exactly? I'm sure it should work o_O
__________________
Reply With Quote
  #8  
Old 10-27-2006, 03:18 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
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?
__________________

Last edited by Chompy; 10-27-2006 at 05:34 PM..
Reply With Quote
  #9  
Old 10-27-2006, 09:15 PM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
Quote:
Originally Posted by Chompy View Post
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.
__________________
Reply With Quote
  #10  
Old 10-27-2006, 09:35 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
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)?
__________________

Last edited by Chompy; 10-27-2006 at 09:46 PM..
Reply With Quote
  #11  
Old 10-27-2006, 09:40 PM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
Quote:
Originally Posted by Chompy View Post
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
__________________
Reply With Quote
  #12  
Old 10-27-2006, 09:47 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Quote:
Originally Posted by xAndrewx View Post
Get dynamic vars, can use to find each individual one
got an example I can use/learn from?
__________________
Reply With Quote
  #13  
Old 10-27-2006, 09:49 PM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
Should do
player_money = temp.fileLoaded.player_money;
player_money = "new test";
saveStuff? (I think...)
__________________
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 05:09 PM.


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