Page 1 of 1

[MOD 0.18] Sandboxed LuaCombinator

Posted: Thu Jan 23, 2020 11:14 am
by IWTDU
I recently found mod named LuaCombinator2, and I liked it's idea but not implementation, so I 'improved' it (if I correctly understood CC BY-SA 4.0 license it is fine). So here it is:

Sandboxed LuaCombinator
https://mods.factorio.com/mod/SandboxedLuaCombinator
Adds combinators programmed with lua.

"Sandboxed" because that is main difference from original mod - each combinator's code works isolated from other's and from game api, so can only interact world with circuit network signals using special variables named: rednet, greennet, output, which are tables indexed by signal name (like 'signal-A'). rednet and greennet are read-only, to send signals write them to output table (like output['signal-A'] = 1 ). Also there is special variable delay: after executing code of combinator once, next execution will be after delay ticks passed, otherwise - on next tick. Don't place infinite (or too long) loops inside - it will hang the game. However, currently it is the only (known) way to negatively affect game with 'bad' code, because unlike in original mod, game api or any external variables are inaccessible (please report as bug otherwise).

Unlike in original mod, global (from inside combinator perspective) variables are always preserved, so there is no need to use special table 'var' to save them. For compatibility, 'var' is defined by default as empty table, but otherwise it is regular variable.

Compatible with code for LuaCombinator2, if that code use only circuit networks and pure lua. Examples from it's page all works.
Optimized to have less overhead on reading/writing signals. Currently up to 40% faster than original (in benchmark where lots of combinators reads and writes signals each tick).

Re: [MOD 0.18] Sandboxed LuaCombinator

Posted: Mon Apr 20, 2020 1:35 pm
by _Attila_
The mod Sandboxed LuaCombinator (0.4.1) caused a non-recoverable error.
Please report this error to the mod author.

Error while running event SandboxedLuaCombinator::on_gui_opened (ID 83)
__SandboxedLuaCombinator__/script/gui.lua:90: attempt to index field '?' (a nil value)
stack traceback:
__SandboxedLuaCombinator__/script/gui.lua:90: in function 'create_gui'
__SandboxedLuaCombinator__/script/gui.lua:20: in function 'open'
__SandboxedLuaCombinator__/control.lua:980: in function <__SandboxedLuaCombinator__/control.lua:972>

I am using a mod https://mods.factorio.com/mod/GhostPlacerExpress that revives ghosts to place an item. I am guessing your mod does not support the defines.events.script_raised_revive event and so does not recognize the combinator when it is selected. Mod also crashes if trying to remove it.