[Rejected] Enhanced event scripting support

djkrose

New member
Jun 26, 2017
9
0
0
55
Hey!

I like where the new event system is heading, but I wish it would be much more flexible to the point where we can actually script komplex actions based on commands. For example, the event types right now take their parameters directly from chat. You cannot call ".TELEPORT" with a fixed destination name in script. And the alternative replies that are separated with "||" are just text replies; you cannot do other actions like with real if-else structures.

Since inventing and parsing a new script language is hard, why not support an existing one and expose existing event actions and other internal commands. For example: LUA, JavaScript, C#

Here is a good starting point on how to integrate such a scripting language:
Adding scripting functionality to .NET applications

What do I need that for?

Originally, I wanted to implement the simple /sethome and /home commands, which already isn't possible with current .TELEPORT, because it requires the desination name as chat parameter. Additionally I wanted to attach costs and timeouts to the commands. And on top I wanted to require peope to vote for the server before they can use that command.

Now wouldn't it be cool if we could just script that? Something like:

Code:
var hasVoted = RAT.checkVotes().Contains(RAT.player_name);
if (!hasVoted) {
  RAT.sendPM(RAT.player_name, "You can only teleport after voting! Go here: http://...");
  return;
}

if (RAT.teleportDestinations("home") = null) {
  RAT.sendPM(RAT.player_name, "You don't have a home point set. Use /sethome first!");
  return;
}

RAT.teleportTo(RAT.player_name, RAT.teleportDestinations("home"));

This is just some pseudo-code from the top of my head; I think it looks like JavaScript, but could be C# also. :)

Let me know what you think!
While I'm not of much help with VB.Net, I could help implementing this in C# .
Which brings me to my second suggestion: How about open-sourcing the project?

djkrose
 
No need for this since you took the ball and ran with it. =)

Although RAT "scripting" will continue to get updates, I won't be implementing a full scripting system such as this.
 
Lua is relatively easy to embed in existing systems and lightweight, and you're probably programming in C# already so wouldn't it be possible to write own event handlers in such a language, as a DLL extension or something?

The idea of a scripting language is really cool for this system, but I really think it should be an already existing one, since we really have enough of them, even really simple ones. Would really extend the possibilities since you could use already existing libraries, and simply do something like your Discord feature on your own (would outsource the development complex features for you automatically).
 
That was exactly my idea in the first place, and when I ran with the idea for my own mod, I confirmed what you said: Lua is quite easy to embed and integrate. You can just simply expose own C# methods, variables, and objects into the Lua world, and people can call and use them in their own control flow structure.

I assume the effort would've been less already than writing the proprietary parsing, and it certainly will be when control structures are added.

But ultimately that's Trekkan's decision, and maybe he already put too much time into his own parser so that abandoning it would just feel bad - which I could understand.