Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   gscript2: requestText (https://forums.graalonline.com/forums/showthread.php?t=57555)

Arkan1k 02-09-2005 10:54 AM

gscript2: requestText
 
1 Attachment(s)
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.

Skyld 02-09-2005 12:15 PM

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

Ajira 02-09-2005 10:52 PM

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.

Admins 02-09-2005 11:24 PM

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.

coreys 03-06-2005 04:40 PM

[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.

KuJi 03-11-2005 12:16 AM

A tutorial for Gscript2 (Just a quick one) would truly help everyone.


All times are GMT +2. The time now is 06:17 PM.

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