ForgeEssentials

ForgeEssentials

339k Downloads

Improving scripting

spacebuilder2020 opened this issue ยท 8 comments

commented

So i have been talking with @olee, and we have been brainstorming ways to improve scripting while not making it significant complex, or go so far that it would be better to convert scripting to use a 3rd party language.

So far, we have been thinking variables, arithmetic operators, and goto based flow control.

See below for a simple draft olee came up while talking with me about this on irc for variables
https://docs.google.com/document/d/13M08_ojzjghvkZRRSsE--eyyYnulJtUbIvvyagetw7o

For flow control we would have goto statements, and labels.

Also, we might have if statements that would use labels to process.

So a syntax for an if statement would be if

similar statements might also use similar syntax.

I am planning to do the implementation of these features, but I want to get some feedback from users on how this should be refined.

commented

Then add proper scripting, not a band-aid to a simple command automation.
It'll be far more useful, and will let people do anything they could imagine, within the available hooks of course.

commented

Before answering the "how" question, can someone please shed some light on the the "why"?
What are the use cases of this movement?
Event triggers?

commented

#2046 is one use case for flow control statement. Also, the importance of flow control is to enable a program to continue running in a separate path based on a condition set, not just stop. I really don't want to create a bunch scripts to do something that could be done in a single script with flow control. As for variables and arithmetic operation, these are useful for simple calculations as needed.

As for another why, why not. I see scripting as the most powerful feature in forge essentials and I find that its 2 key limitation, lack of variables / operators, and lack of flow control very counter productive. I don't want to create a java mod everytime i want to add something complex.

commented

In my opinion, FE scripting has a special place in that it is simple, and adding support for a full system is planned, but even then, I think that lua scripts should only be ran from FE scripts. For example with the command lua <args...>. Keep the FE scripts to do what they do best, simple commands that do not require advanced features but might benefit from simple flow control.

That is why I am doing this extension because simple additions improves the scripting system while remaining in check its original purpose... Simple shell like scripting.

commented

You're thinking too narrow.
With a full featured scripting, you can assign scripts as event triggers.
For example, run a script, when a player enters the zone. Or leaves it. Et cetera.
Though, this is not related to the present issue.

commented

We have some event triggers already. Server login, server start, etc.

Event triggers are very easy to add with the current system.

As for a full featured system, well none of us have time to develop one so if and when we need one we will look at a third party solution.

commented

Really great all the work you put into scripting. Can I ask for a request? I'd like to see more extensive documentation and/or more examples with explanation because I find it very cryptic to understand.

The god.json example is quite different from the player and admin join scripts in format. Why is that? When should json formatting be used and when not?

Scripting is probably the strongest part of FE but not so easy to use if the examples are not well explained. I never got rewards for votes working for instance nor I have no idea how to extrapolate the site where the vote has been cast.

I am sure more examples will help the lot of us.

commented

I will work on overhauling the documentation one I finish up these new components.

As for the commands, only commands use json. The event scripts are far simpler and are just text files. As for votes, you put an event script in the servervotes folder.