Frequently asked questions about the new scripting engine
There are quite a few common questions about the new scripting engine, and it's syntax, which I hope to answer here for those new to the new engine.
There is a starting guide to the new engine, which you can find here. If you still have unanswered questions, take a look in this thread. Do I have the new engine enabled on my server? You can test to see if the new engine is enabled on your server by using a basic script like this: PHP Code:
Does the old engine scripting still work on a server where the new engine is enabled? Yes. However, you may notice a couple of differences. Mostly, they are:
Is it okay to mix new script engine code and old script engine code? Preferably not. Even though the code will work, it is generally encouraged that a script uses only the new or the old engine. From using the old scripting engine, I have been using #s, #v and #I to access variables. How do I do it in the new engine? Old gscript was not able to tell the difference between strings, numeric variables and "string lists" (arrays), so these message codes were used to get the contents of these variables. However, in the new engine, the variable are "variant", which means that the engine already knows what type of data is being stored. Therefore, you can store variables like this: PHP Code:
PHP Code:
In the new engine, there are new objects for the player, the NPC, etc. Here are some examples on how to set the player's attributes: PHP Code:
PHP Code:
Yes! There is a list on the GraalBible. You can find it here. How do I join together values? There are a set of operators for this. They are called "string concatenation" operators. They work like this: PHP Code:
PHP Code:
There is a new command in the new engine for setting a timeout. It works like this: PHP Code:
They are findplayer(), findnpc(), findweapon(), findweaponnpc(). Except, there is now new functionality that allows you to do this: PHP Code:
PHP Code:
They absolutely do! Function parameters work in one of two ways. If you define the function with variables, then this is how it will work: PHP Code:
PHP Code:
Can functions return values to wherever the function was called? Yes! The return; function is used for this, and this is how it is done: PHP Code:
Are there any more reference materials on the new engine? Yes! You can find them on the GraalBible, at http://wiki.graal.net/Creation/Dev/GScript. Opinions/suggestions? Please post them! Only constructive criticism, opinions or suggestions are welcome, though. Others will be deleted! |
Nice!
|
Great work Skyld, thumbs up!
|
Is there/will there be a new commands.txt for gscript2 which explains this kind of stuff?
If not it would be really nice to have a convert commands.txt. For example, one that shows the old way, then shows the new way. It would be extremely useful. |
Quote:
Or you can run Graal4 with the -listscriptfunctions command line option. This will generate a file called docu_scriptfunctionslatest.txt or something along those lines. |
Very cool Skyld, you should write a little something about the findnpc() too.
|
Curious, is there any difference between \n and NL, besides personal preference?
|
Quote:
Quote:
|
Quote:
PHP Code:
|
Skyld I take it you mean concatenation and i'd have just said "string connecting operator"
|
I'd look into TAB again skyld, doesn't work...
|
Quote:
|
Err then how come
temp.test = "This" TAB "Tabs"; echo(temp.test); Didn't create a tab, it delimited it fine... But no tab |
1 Attachment(s)
I don't see a problem with it.
It could be that the client F2 window and RC are just not showing tabspaces, but they are being inserted. See the textlist attached. |
Quote:
|
Err ah doesn't work clientside I believe
player.chat = "Tab" TAB "Testing"; |
Tab works in GUI controls, but not in anything else as far as I know.
When using the TAB operator, it's probably best if you define 'column.' I haven't tried without giving the tab widths, so I'm not sure if it will work if you don't define the 'column' string. |
TABs are working fine. When displaying chat or chatting in RC then control characters are removed though.
|
Quote:
|
what's the gs2 version of the function "indexof(partstr,str)"?
|
str.index(partstr)
|
Quote:
str.index(partstr) returns where 'partstr' appears in an array |
Quote:
Quote:
|
thankyou, is there a list where I can find these functions sitting next to their old gs1 functions?
Also I have a question. Let's say i make a list using string.add(string), how do i check a specific string in the list, like for example if i wanted like the third thing in the list, what would i use? |
string[2] is the third object in the list.
|
Quote:
http://wiki.graal.net/index.php/Crea...ject_functions ^^ |
All times are GMT +2. The time now is 07:49 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.