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 09-12-2006, 11:10 AM
projectigi projectigi is offline
Registered User
Join Date: Jan 2004
Posts: 403
projectigi is an unknown quantity at this point
Hooking and file accessing

Hi,
  1. are there any functions to directly access files?(that means not, savevars or whatever)
  2. why doesnt savevars saves into levels/ and all subfolders of levels/ but the graal.wiki.net example of savevars uses levels/ ?
  3. how to hook things?
    i talked to someone and said something like "it would be nice if you could execute a script everytime a weapon is saved / so like i could make a mysql class and every weapon that gets saved gets added a join('mysql_class') at the serverside and clientside end"
    he said: "that possible"
    i asked "how?"
    he said: "with hooks, my system uses them"
    but he was working so how do i make these hooks?
Reply With Quote
  #2  
Old 09-12-2006, 01:19 PM
KuJi KuJi is offline
Banned
Join Date: Apr 2004
Location: Staten Island, New York
Posts: 2,202
KuJi will become famous soon enough
Send a message via ICQ to KuJi Send a message via AIM to KuJi Send a message via MSN to KuJi Send a message via Yahoo to KuJi
Savestring + Loadstring might be what you want:

http://wiki.graal.net/index.php/Crea...Output_Methods
Reply With Quote
  #3  
Old 09-12-2006, 01:31 PM
projectigi projectigi is offline
Registered User
Join Date: Jan 2004
Posts: 403
projectigi is an unknown quantity at this point
No, i search direct file access functions, so i can save things into levels/ and the subfolders of levels/
that doesnt seem to work with savestring or savevars

edit:
OT: btw is graal.net down?
doesnt load for me lol
Reply With Quote
  #4  
Old 09-12-2006, 02:27 PM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
I'm pretty sure there is no traditional hooking in gscript. but the onCreated() event is called when a weapon is saved serverside.
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
Reply With Quote
  #5  
Old 09-12-2006, 03:02 PM
projectigi projectigi is offline
Registered User
Join Date: Jan 2004
Posts: 403
projectigi is an unknown quantity at this point
for every weapon? i guess only the weapon that got saved or? xD
Reply With Quote
  #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
  #7  
Old 09-12-2006, 10:01 PM
KuJi KuJi is offline
Banned
Join Date: Apr 2004
Location: Staten Island, New York
Posts: 2,202
KuJi will become famous soon enough
Send a message via ICQ to KuJi Send a message via AIM to KuJi Send a message via MSN to KuJi Send a message via Yahoo to KuJi
Quote:
Originally Posted by 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 
Ahh, thats what I ment** My bad =(
Reply With Quote
  #8  
Old 09-13-2006, 01:51 PM
projectigi projectigi is offline
Registered User
Join Date: Jan 2004
Posts: 403
projectigi is an unknown quantity at this point
well i found out that it actually saved, but didn't show up on the File Browse until doing /refreshfilelist ¬_¬
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 09:16 PM.


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