Current and proposed practice
In my mind a scripting language should be simple to both understand and use. You should not need to be a C++/Lua hacker to be able to create a dialogue menu where some replies depends on certain circumstances. Here follows a few suggestions how the tmwserv Lua scripting could look.
NPC dialogue
Currently on eAthena:
// A comment! mes "[Maji Chan]"; mes "\"How do you do my dear quester?\""; next;
Currently on tmwserv:
-- A comment! do_message(npc, char, "“How do you do my dear quester?â€")
Which is quite unwieldy. When scripting you most often only have the NPC say something to the player, so this could be simplified a fair bit to something like:
-- A comment! message("“How do you do my dear quester?â€")
I would actually propose to gettext-ize it:
-- A comment! message(_("“How do you do my dear quester?â€"))
Using variables
Currently on eAthena:
set @variable_1 = 42; // numeral variable for the local script set @variable_2$ = "Bottle of Sand"; // string variable for the local script mes "\"Did you bring " + @variable_1 + " [" + @variable_2$ + "]?\"";
Currently on tmwserv:
...
Displaying dialogue options
Currently on eAthena:
mes "It seems Maji Chan is waiting for an answer..."; next; menu "I'm fine!, thanks for asking.", L_a_good_option, "...", -, // Continue after the menu "Quite well, and you?", L_another_good_option; mes "[Maji Chan]"; mes "\"\You could at least say something!\""; close;
Currently on tmwserv:
...
Variable dialogue options
Currently on eAthena (easy but quickly unwieldy solution):
set @variable = 108; if (@variable < 100) menu "Ye olde dialogue option.", L_usual_option, "Good bye!", -; if (@variable >= 100) menu "Ye olde dialogue option.", L_usual_option, "A new exciting option!", L_ohhhh, "Good bye!", -; close;
Currently on eAthena (more complex solution):
...
Currently on tmwserv:
...
Starting a script from scratch
...
See also
- Script bindings — things we currently can access through scripts
- Script bindings to do — things we should be able to access through scripts... in time
- Current tmwserv script example
- eAthena scripting standards — scripting on the old eA server software