[Support] EventScript - Sharing events for the future

Author Topic: [Support] EventScript - Sharing events for the future  (Read 9854 times)

EventScript
For years people have used Duplicator or manual copying to transfer events from bricks and builds to other bricks and builds. Sharing events to others is also a hassle. Handling a huge amount of events have always become tedious and problematic. However, there is a solution for this.

This mod introduces the ability to script your events, through the new scripting language EventScript. It removes the hurdle of sharing. It reduces the problem with huge amounts of events. It completely obliterates copying issues.

Download. Install. Set your shortcuts of copy/paste/editor. Start scripting.


Copies the left code into the event system and then copies the event system into readable script.

Details
After installing the add-on, go to Options to set the shortcuts for copying and pasting events. Keep in mind that anything that relates to ctrl+c, alt+c, ctrl+v and alt+v will not work as expected. When this is done, one could easily just join a server and go into eventing mode. While there, just copy the events with previously mentioned shortcut. This will place the script in the clipboard, ready to be pasted in any text editor of choice. If a script already is within the clipboard, it can be pasted in the same manner with the other shortcut.

Any errors will halt the script and let the user know, giving brief explanation of why it could not parse the script. Keep in mind that pasting will always overwrite your current events, unless an error occurs.

It is also possible to paste the script on the server, if the add-on is enabled.
Code: [Select]
$script = EventScriptServer_save(_myBrick);
EventScriptServer_load(_myBrick, $script);
First function saves the events to a string.
Second function loads the string onto the brick.

Key bindings
When no binding is set, these are the default:
Code: (Windows) [Select]
ctrl+shift+c  Copy
ctrl+shift+v  Paste
ctrl+shift+e  Editor
Code: (Mac) [Select]
cmd+shift+c   Copy
cmd+shift+v   Paste
cmd+shift+e   Editor

Script Example
Script provided by Platypi.
Code: [Select]
# Author: Platypi / SadBlobfish
# Makes a brick change colors on a loop when toggled

# Start color changing (start with events enabled)
start: [x][0]onActivate->Self->playSound("Beep_Checkout.wav")
[x][33]onActivate->Self->fireRelay

# Stop color changing (start with events disabled)
[ ][0]onActivate->Self->playSound("Beep_Denied.wav")
end: [ ][0]onActivate->Self->cancelEvents

# Alternate between starting and stopping color changing
[x][0]onActivate->Self->toggleEventEnabled([start:end])

# Change colors
[x][0]onRelay->Self->setColor("0.898039 0.000000 0.000000 1.000000")
[x][500]onRelay->Self->setColor("0.898039 0.898039 0.000000 1.000000")
[x][1000]onRelay->Self->setColor("0.000000 0.498039 0.247059 1.000000")
[x][1500]onRelay->Self->setColor("0.200000 0.000000 0.800000 1.000000")

# Loop color changing
[2000]onRelay->Self->fireRelay

# Stop color changing when brick is blown up
onBlownUp->Self->cancelEvents

More in Tutorial thread.

Official support
MEGA (Up to v1.6)

Known issues
An unknown amount of Add-Ons wont work correctly with this mod as they are modifying the Event window in an evil manner.
It is known that people have their own suggestion for design, but surely this standard is already set and cannot be altered.
I cannot take your babies. It would be against the law and I see it more of a burden than a gift.

Download (aposoc.net)
Download (blocklandglass.com)

GitLab
Tutorial and Discussion
« Last Edit: November 03, 2018, 05:38:46 AM by mctwist »

Finally an easier way to event. Great work as always!

I DONT LIKE HOW THE ARROWS HAVE HYPHENS IN THEM ITS WEIRD

I DONT LIKE HOW THE ARROWS HAVE HYPHENS IN THEM ITS WEIRD

Breath... You will get used to it eventually.

Oh heck yes! this'll be good like BOOM event.

If we replace syntax such as the -> in the script file it should still work as intended right?

I feel like just having > would be nice simply because its one less character (not sure if its used anywhere else though)

Sweet addon, definitely something that I've never considered but is awesome to have!

I personally like the -> syntax because it's what I see virtually everywhere when people explain events. It's like we now have a standardized language for discussing events.

What's with everyone's obsession with having fewer characters?  The point of EventScript is representing events in a clear way that mimics the GUI.

-> looks more like an arrow than > does
> looks like it's supposed to be a greater-than symbol

If we replace syntax such as the -> in the script file it should still work as intended right?

I'm not sure what you mean here. If you modify the add-on to change the -> to anything else, then it'll only work for you, but everyone else that tries to use it will get errors.

I feel like just having > would be nice simply because its one less character (not sure if its used anywhere else though)

I've used that syntax before for my other event add-ons, but I only did that for laziness. I believe that this new syntax will make it easier to understand that it's a "pointer" that goes toward something instead of a "greater than". But to set a point I'll quote one of the known issues:
It is known that people have their own suggestion for design, but surely this standard is already set and cannot be altered.
The design is made this way to make it easier to understand events as well. I put the understanding of the event as first priority and then the functionality as second. However, the design made it possible for the functionality to be able to extend in the future with more functionality like "macros" and "named events". The arrow(->) is not crucial for functionality, but it plays a great part for the design to make the script easier to read.

No other language uses just a > for calling a function. C++ and C# use ->.

I understand for some of you want this to be easy but also understand it is considered a language, try to make it relate to others as much as possible so it makes sense.

No other language uses just a > for calling a function. C++ and C# use ->.

Don't forget PHP. XML and HTML uses < and > for tags.

When I copy events, it seems to only use Linux line ending (\n) and not Windows line ending (\r\n).

When I copy events, it seems to only use Linux line ending (\n) and not Windows line ending (\r\n).

TorqueEngine handles newlines in a weird way. It defaults to \n for NL and ignores \r completely when printed. The character is still there, but hidden. I've opened an issue to fix this, and probably will add more fixes as I go through the script.

Keep in mind, even without newlines, as long as you have an ending parenthesis or a newline before next event, it'll work just fine all on the same line.

Quote from: v1.1 changelog
Improved the parsing significantly.
Added an in-game editor for convenience and several other client improvements.
Many bugs fixed.

Download



Sadly, I doubt I'll be able to work any more on this in the next 3 weeks. But I do have plans for it, as mentioned in the discussion topic, so please do look forward while I improve this.

Quote from: v1.2 changelog
Added indexing

Download