Space Engineers

Space Engineers

评价数不足
JavaScript Programmable Block (experimental)
   
奖励
收藏
已收藏
取消收藏
Type: Mod
Mod category: Block
文件大小
发表于
更新日期
301.202 KB
2018 年 10 月 13 日 上午 3:59
2018 年 10 月 14 日 下午 10:28
5 项改动说明 ( 查看 )

订阅以下载
JavaScript Programmable Block (experimental)

描述
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]
引用自 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 条留言
Vex 2024 年 3 月 31 日 下午 10:53 
Is this planned to be revived?
Maybe a Typescript Port as an Add on would be a great feature too.
Rusted Droid 2022 年 5 月 7 日 上午 10:29 
LOL haha instant Subscribed
Kuntish 2020 年 11 月 28 日 下午 4:20 
Seems like this mod is dead as much as it is useless in its current state.
NeoNexus DeMortis 2019 年 9 月 17 日 下午 10:04 
Please tell me this mod isn't dead! I just found SE, and can't stand M$ languages; really good with JS though!
rockyjvec  [作者] 2019 年 1 月 14 日 下午 5:56 
Unfortunately no, :steamsad:
夜露死苦 2019 年 1 月 12 日 上午 10:15 
xhr call?
rockyjvec  [作者] 2018 年 10 月 29 日 下午 2:13 
@jarhead, actually, the description is a little misleading. This does function as a addon. The vanilla version can run side by side.
jarhead 2018 年 10 月 29 日 上午 10:52 
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 2018 年 10 月 16 日 下午 3:10 
OOOOOH!!!
Stollie 2018 年 10 月 16 日 下午 12:20 
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