View Single Post
  #6  
Old 09-12-2006, 09:15 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
Yay for wasting my post.

I don't know what you mean by 'directly accessing a file.'
It's possible to load the file as raw text, the way it would appear in wordpad, by using loadlines() and savelines().

All of the 'save<whatever>' functions require a full path. The syntax is save<whatever>(path,append?)
If you want to save text to a file 'zomg.txt' in levels/, you need to do object.savelines("levels/zomg.txt",false);

In the case of savelines, it expects the object to be an array. Each array member is one line.
PHP Code:
temp.lines = {"Hi","how","are","you"};
temp.lines.savelines("levels/test.txt",false);
// Output will look like:
// Hi
// how
// are
// you 
In the case of savevars, it expects an object (normally a TStaticVar)
PHP Code:
temp.myobject = new TStaticVar();
with (temp.myobject) {
  
this.zomg "Hello";
  
this.cat "dog";
  
this.moo 123;
}
temp.myobject.savevars("levels/test.txt",0);
//Output will look like:
//zomg=Hello
//cat=dog
//moo=123 
You don't need to define the TStaticVar in most cases, you could just do temp.myobject.zomg = "Hello"; and so on.

Finally, savestring is pretty much the same thing as savelines but it saves the text in a single line. The object it expects is just a string, float, integer, ect.
PHP Code:
temp.mystring "Hello, how are you today?";
temp.mystring.savestring("levels/test.txt",0);
// Output will look like:
// Hello, how are you today? 
Reply With Quote