Anuken / Mindustry-Suggestions

Repository for Mindustry suggestions and feedback
130 stars 58 forks source link

LUA / Javascript /etc.-based scripting #3270

Closed ynvaser closed 2 years ago

ynvaser commented 2 years ago

Describe the content or mechanics you are proposing.

Allow for a different kind of processor - one which takes text input and is parsed as code.

Describe how you think this content will improve the game. If you're proposing new content, mention how it may add more gameplay options or how it will fill a new niche.

The built-in logic language is too simplistic, and needs a significant time investment to get anything complex done.

Adding a fully-fledged scripting language to the game could give people with developer skills a new tool to play around with (with less invested effort required), and it'd introduce players without such a background to proper programming.

Implementation could be done via Nashorn (or a ScriptEngine implementation of your choice), and could be done with relatively minor effort given that scripting support already exists in some form. Default methods could be provided that provide existing functionality in the current logic language (e.g: Radar, Sensor, etc.).

Before making this issue, check the boxes below to confirm that you have acknowledged them.

Bottinator22 commented 2 years ago

The game already has Javascript support for mods

This is also a harder system to use than regular logic, and is far more powerful. Probably gonna be OP

itcannotbe commented 2 years ago

A few things you shouldn't suggest

These have been proposed many times already, and I won't be adding them.
  • Any sort of string manipulation in logic (reading from message blocks, reading characters, splitting strings, etc)
Bottinator22 commented 2 years ago
  • [x] I have not read README.md to make sure my idea is not listed under the "A few things you shouldn't suggest" category.

A few things you shouldn't suggest

These have been proposed many times already, and I won't be adding them.
  • Any sort of string manipulation in logic (reading from message blocks, reading characters, splitting strings, etc)

This isn't quite that

end-me-please commented 2 years ago

If you install devmode you can enter whatever JavaScript you want in the console

itcannotbe commented 2 years ago
  • [x] I have not read README.md to make sure my idea is not listed under the "A few things you shouldn't suggest" category.

A few things you shouldn't suggest

These have been proposed many times already, and I won't be adding them.
  • Any sort of string manipulation in logic (reading from message blocks, reading characters, splitting strings, etc)

This isn't quite that

Allow for a different kind of processor - one which takes text input and is parsed as code.

Yes, it clearly isn't....................

ynvaser commented 2 years ago
  • [x] I have not read README.md to make sure my idea is not listed under the "A few things you shouldn't suggest" category.

A few things you shouldn't suggest

These have been proposed many times already, and I won't be adding them.
  • Any sort of string manipulation in logic (reading from message blocks, reading characters, splitting strings, etc)

This isn't quite that

Allow for a different kind of processor - one which takes text input and is parsed as code.

Yes, it clearly isn't....................

I've read the readme and understood that as being different from my suggestion.

ynvaser commented 2 years ago

If you install devmode you can enter whatever JavaScript you want in the console

The game already has Javascript support for mods

This is also a harder system to use than regular logic, and is far more powerful. Probably gonna be OP

I'd like this to be a part of the vanilla game, so I can pop the block into a schematic and have it work on unmodded multiplayer servers.

Bottinator22 commented 2 years ago

Already there's a bit of a problem of people who are good with logic or having logic schematics gaining an advantage This would just make that problem worse, and bring the possibility of RCE exploits as well

On Fri, Dec 31, 2021, 1:36 AM Dávid Bangó, @.***> wrote:

If you install devmode you can enter whatever JavaScript you want in the console

The game already has Javascript support for mods

This is also a harder system to use than regular logic, and is far more powerful. Probably gonna be OP

I'd like this to be a part of the vanilla game, so I can pop the block into a schematic and have it work on unmodded multiplayer servers.

— Reply to this email directly, view it on GitHub https://github.com/Anuken/Mindustry-Suggestions/issues/3270#issuecomment-1003324058, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOJVLNEXEFN3JO74D55AT53UTV2TRANCNFSM5LAVCAIA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you commented.Message ID: @.***>

itcannotbe commented 2 years ago

Already there's a bit of a problem of people who are good with logic or having logic schematics gaining an advantage This would just make that problem worse, and bring the possibility of RCE exploits as well

Exactly why string manipulation with logic is on the do not suggest list...

Bottinator22 commented 2 years ago

This isn't specifically string manipulation. Writing Javascript code is not manipulating a string with code

On Fri, Dec 31, 2021, 1:46 AM itcannotbe, @.***> wrote:

Already there's a bit of a problem of people who are good with logic or having logic schematics gaining an advantage This would just make that problem worse, and bring the possibility of RCE exploits as well

Exactly why string manipulation with logic is on the do not suggest list...

— Reply to this email directly, view it on GitHub https://github.com/Anuken/Mindustry-Suggestions/issues/3270#issuecomment-1003326059, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOJVLNHWLJLYWOYWMXICV33UTV3W7ANCNFSM5LAVCAIA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you commented.Message ID: @.***>

itcannotbe commented 2 years ago

This isn't specifically string manipulation. Writing Javascript code is not manipulating a string with code

But the code is a bunch of characters parsed as a string right???

ynvaser commented 2 years ago

Exactly why string manipulation with logic is on the do not suggest list...

Let's just go with the assumption that it's different, since otherwise the whole discussion is moot. Repeating the same thing over and over isn't constructive.

Already there's a bit of a problem of people who are good with logic or having logic schematics gaining an advantage This would just make that problem worse, and bring the possibility of RCE exploits as well

RCE is a valid concern,, but I believe the language choice and selective limitation of it's functionality could help circumvent this. For example, I spent some time in the past breaking Together Java's JShell Discord bot, and by limiting the available packages that can be used during code execution, all the exploits I've found have been rendered impossible. Java is way too powerful to give to players imo, so I'd probably choose JS or Lua anyway.
For LUA, risky libs can be disabled.
I'm less familiar with Javascript, and my search doesn't turn up meaningful results.

Bottinator22 commented 2 years ago

This isn't specifically string manipulation. Writing Javascript code is not manipulating a string with code

But the code is a bunch of characters parsed as a string right???

The print instruction contains a bunch of characters parsed as a string

String MANIPULATION is CHANGING a string, not having a string exist at all

MrDuck557 commented 2 years ago

In short: you want to be able to code logic with js limiting the effects to only the standard logic set would prevent it from being cheaty how would you suggest limiting the speed of execution?

ynvaser commented 2 years ago

In short: you want to be able to code logic with js limiting the effects to only the standard logic set would prevent it from being cheaty how would you suggest limiting the speed of execution?

Well, I see three ways of going about it:

Edit: Either way, the thread running provided code would need to be interrupted after a set amount of time to avoid players messing with infinite loops and such. Only invoke a predefined method with a predefined signature as an entry point for execution. That method has to finish under a set amount of time, if not, provide some error message on the ingame block. Memory blocks could be used as a persistence layer between executions.

itcannotbe commented 2 years ago

Upon asking the developer, he said that the logic syatem was made with the following in mind:

It must not allocate, it must be easy to learn, parse and understand, and it must not encourage complex O(n) operations like string manipulation.

SMOLKEYS commented 2 years ago

Can someone simplify what this suggestion is aiming for?

ynvaser commented 2 years ago

Can someone simplify what this suggestion is aiming for?

Allowing logic to be done in an established scripting language as well as the existing one, for example in Lua or Javascript.

SMOLKEYS commented 2 years ago

Can someone simplify what this suggestion is aiming for?

Allowing logic to be done in an established scripting language as well as the existing one, for example in Lua or Javascript.

That is a massive risk (Especially if it can be ran on all players on a server). Mindustry has an Arc class that lets you execute shell commands, meaning, unless made to be inaccessible, someone can completely wipe out someone's hard drive (entire storage in mobile).

(If the stuff runnable in JavaScript is very limited, the risk above can be completely ignored)

Bottinator22 commented 2 years ago

That's entirely what a scripting language is

A language meant to be run with restrictions

Also, I have seen even Java be restricted before, in Robocode

On Fri, Dec 31, 2021, 11:20 AM smol, @.***> wrote:

Can someone simplify what this suggestion is aiming for?

Allowing logic to be done in an established scripting language as well as the existing one, for example in Lua or Javascript.

That is a massive risk (Especially if it can be ran on all players on a server). Mindustry has an Arc class that lets you execute shell commands, meaning, unless made to be inaccessible, someone can completely wipe out someone's hard drive (entire storage in mobile).

(If the stuff runnable in JavaScript is very limited, the risk above can be completely ignored)

— Reply to this email directly, view it on GitHub https://github.com/Anuken/Mindustry-Suggestions/issues/3270#issuecomment-1003439225, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOJVLNHY7SQFN5EYN2MAOZLUTX7BJANCNFSM5LAVCAIA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you commented.Message ID: @.***>

github-actions[bot] commented 2 years ago

This suggestion is now stale, and will be automatically closed.