Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 02-09-2005, 10:54 AM
Arkan1k Arkan1k is offline
Delph
Join Date: Feb 2004
Location: Melbourne, Australia
Posts: 35
Arkan1k is on a distinguished road
Send a message via AIM to Arkan1k Send a message via MSN to Arkan1k
gscript2: requestText

I am currently trying to figure out ways that I can read from or save to a text file either on the server or the client's computer.
I have been experimenting with "requestText(str, str)" for a while, but I can't really figure out at all how you would be able to read a specific file with it.

Currently I have:
NPC Code:
requestText(str, str):
- weapon [weaponname]
- weaponlist
- class [classname]
- classlist
- options
- serverflags
- folders
- folder [path]

- document [path=docu/docu_textfile.txt]
I'm not positive about that last one as I am not able to test it.



I am sure there's a few more. But I am unable to test.

Some other functions I have found are these. Yet I have no clue on how they work and am requesting any help in figuring them out.

NPC Code:
  loadfolder(str, int)
loadlines(str)
loadstring(str)
loadvars(str)

savelines(str, int)
savestring(str, int)
I have seen the RC weapon use it as:
text.savestring("rclog.txt",1);
But again, I am not able to test. I just presume that it saves a string to the specified text file in the logs folder.
savevars(str, int)



I would appreciate any help.

I have also attached something I slapped together, rather messily (is that a word? It is now.).
It is sort of based on command prompt. Something I've been using to test the above commands and to teach myself gscrip2.
I didn't really need to make them all "/commands" but, what's the dif?
Included is a small formatText function which basically is used like:
NPC Code:
formatText("[r]This is red,[/r] and [y]This is yellow[/y]")


And it basically swaps the [r] tags and any other tags you may add into the function with their respective <font color=#color></font> tags.
I didn't put much effort into it, but I'm sure we can improve on it.

And if you call weaponlist or any other kind of thing through "/request" you can add either "-e" or "-l" to open the requested text in a editable text box or a list.

Perhaps even we can start up a few community projects that we can all work on together.

Anyway, again, I would love any help from anyone, and enjoy my little cmd script.
Attached Files
File Type: txt weaponCmd.txt (7.7 KB, 146 views)
__________________
[ Delph ]
Reply With Quote
  #2  
Old 02-09-2005, 12:15 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
Quote:
Originally Posted by Arkan1k
I am currently trying to figure out ways that I can read from or save to a text file either on the server or the client's computer. I have been experimenting with "requestText(str, str)" for a while, but I can't really figure out at all how you would be able to read a specific file with it.
NPC Code:
requesttext("document", "docu/docu_graalscript.txt");



This does not appear to return anything on Rudora (and yes, the file does exist).
However, Stefan helped me with trying to read a file serverside which worked:

NPC Code:
  lines = "";
lines.loadlines("");
this.line = "";
for (i=0; i<lines.size(); i++)
this.line @= lines[i]@"\n";
this.line @= "";



The only problem I have found with this is download times for large documents, but I am yet to look into that.

Quote:
Originally Posted by Arkan1k
Some other functions I have found are these. Yet I have no clue on how they work and am requesting any help in figuring them out.
I am assuming that loadlines and loadstring are very similar; loadlines downloads the file into an array, each value being a line, and loadstring loads the entire file into a string, seperating lines by \n, although I'm not sure.

I am yet to look at saving to files, so I cannot help you there.
Edit Found this in the scripted RC, so I hope it will give you some insight.
text.savestring("rclog.txt",1);
It would save the string "text" to "rclog.txt", obviously. I do not know what the last parameter is for, though.

Quote:
Originally Posted by Arkan1k
I have also attached something I slapped together, rather messily (is that a word? It is now.). It is sort of based on command prompt. Something I've been using to test the above commands and to teach myself gscrip2.
I shall have a look at it sometime; its still on Rudora. :P
__________________
Skyld

Last edited by Skyld; 02-09-2005 at 12:35 PM..
Reply With Quote
  #3  
Old 02-09-2005, 10:52 PM
Ajira Ajira is offline
Poont.
Join Date: Oct 2004
Location: NY, USA
Posts: 477
Ajira is on a distinguished road
For the last parameter, 0=overwite, and 1=append. Hope that helps.

As for Delph, I don't believe you can do requesttext("document", "docu/docu_graalscript.txt");. You need to do a loadlines/string serverside.
Reply With Quote
  #4  
Old 02-09-2005, 11:24 PM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
Quote:
Originally Posted by Ajira
For the last parameter, 0=overwite, and 1=append. Hope that helps.

As for Delph, I don't believe you can do requesttext("document", "docu/docu_graalscript.txt");. You need to do a loadlines/string serverside.
I can add that though, because some people have requested it.
Reply With Quote
  #5  
Old 03-06-2005, 04:40 PM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
[QUOTE=SkyldThe only problem I have found with this is download times for large documents, but I am yet to look into that.[/QUOTE]

To fix that put it into a function, functions make scripts run smoother and faster. Which is proubably why GS2 is mostly in a function like format for everything.
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote
  #6  
Old 03-11-2005, 12:16 AM
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
A tutorial for Gscript2 (Just a quick one) would truly help everyone.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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:46 PM.


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