Space Engineers

Space Engineers

Not enough ratings
JavaScript Programmable Block (experimental)
   
Award
Favorite
Favorited
Unfavorite
Type: Mod
Mod category: Block
File Size
Posted
Updated
301.202 KB
13 Oct, 2018 @ 3:59am
14 Oct, 2018 @ 10:28pm
5 Change Notes ( view )

Subscribe to download
JavaScript Programmable Block (experimental)

Description
A JavaScript Programmable Block replacement mod for Space Engineers.

This mod is currently experimental and should NOT be used on live servers or games you don't want to lose. There are likely memory leaks and other game crashing bugs in the current version. You have been warned.

Documentation and Examples[github.com]


Why JavaScript?

People love to hate JavaScript, but it is one of the most popular programming languages: https://insights.stackoverflow.com/survey/2017#technology-programming-languages Just about every dynamic website on the planet is powered by JavaScript. It's easy to learn and has similar syntax to more powerful languages such as C, C++, C#, PHP, etc.

Atwood's Law[blog.codinghorror.com]
Originally posted by Jeff Atwood:
Any application that can be written in JavaScript, will eventually be written in JavaScript.

Features

* Still works with in-game scripts disabled.
* Scripts can go into an infinite loop and/or run forever and never cause any complexity errors or slow down the server.
* Smart throttle that prevents more then a set amount of statements from getting executed across ALL programmable blocks. Tested by running an infinite while loop on 64 programmable blocks at the same time with no performance loss. Each block just ran slower: https://youtu.be/qgLJvDc4Zq0
* Events can "interrupt" the execution of a script. No more needing to write state machines to avoid complexity errors.

Example Code

function playSound() { var soundBlock = Blocks.get("Sound Block"); if(soundBlock === null) console.log("Sound block not found"); else soundBlock.applyAction("PlaySound"); } Event.onAction("TriggerAlarm", playSound);

Credits

This mod uses a heavily modified version of esprima-dotnet and jint by Sebastien Ros:
https://github.com/sebastienros/esprima-dotnet
https://github.com/sebastienros/jint

The thumbnail is from logo.js by voodootikigod:
https://github.com/voodootikigod/logo.js
13 Comments
Vex 31 Mar, 2024 @ 10:53pm 
Is this planned to be revived?
Maybe a Typescript Port as an Add on would be a great feature too.
Rusted Droid 7 May, 2022 @ 10:29am 
LOL haha instant Subscribed
Kuntish 28 Nov, 2020 @ 4:20pm 
Seems like this mod is dead as much as it is useless in its current state.
NeoNexus DeMortis 17 Sep, 2019 @ 10:04pm 
Please tell me this mod isn't dead! I just found SE, and can't stand M$ languages; really good with JS though!
rockyjvec  [author] 14 Jan, 2019 @ 5:56pm 
Unfortunately no, :steamsad:
夜露死苦 12 Jan, 2019 @ 10:15am 
xhr call?
rockyjvec  [author] 29 Oct, 2018 @ 2:13pm 
@jarhead, actually, the description is a little misleading. This does function as a addon. The vanilla version can run side by side.
jarhead 29 Oct, 2018 @ 10:52am 
I was hoping for an addon version of this instead of replacment.
This would allow us to have both the vanilla version and this at the same time.
DartTimeTime 16 Oct, 2018 @ 3:10pm 
OOOOOH!!!
Stollie 16 Oct, 2018 @ 12:20pm 
This looks really interesting and I can imagine you put a lot of work into it.

I think you need some more examples of what it can do that people can download and highlight what advantages over using the normal language used in the PB's for people to want to utilise it though :D