cubex2 / customstuff4

A Minecraft mod for adding content
https://minecraft.curseforge.com/projects/custom-stuff-4
GNU General Public License v3.0
25 stars 14 forks source link

[Feature Request]: Scripts (like CS2) #50

Open MorKazim opened 6 years ago

MorKazim commented 6 years ago

hello, can you give us the ability to use scripts like we had in CS2 example: "for(var i=0; i<height; i++) { for(var j=0; j<width; j++) { for(var k=0; k<width; k++) { world.setBlockIdAndMetadata(position, block, blockmeta); z++; } z -= width; x++; } x -= width; y++; } y -= height;" thank you.

Frontrider commented 6 years ago

No promises, but I might look into this. I know a secure javascript sandbox which could serve it really well. Performance should be able to compete with java code as well. It really looks like that this feature would also be able to solve #59 #46 #45 #39 #18 #55 #61.

The reason why I think scripts should be preferred over injecting actual java code (as far as I can tell, it would be possible), because that way we can edit scripts at runtime, plus we can handle restrictions and other security stuff in a more sane way.

Frontrider commented 6 years ago

I think now I'm onto something-. No promises, I'll try to get the pr for the first iteration this week. It will be limited and incomplete, but good enough for trials. Bugs guaranteed (Have to figure how to test it reliably, and the error margin is high), but not supposed to crash your game.

Will be disabled by default, there will be a config option to turn it on.