Moon Logic 2


Adds programmable Lua combinator. Based on Sandboxed LuaCombinator and LuaCombinator2 mods.

Content
9 months ago
2.0
1.18K
Circuit network

b Cannot save game with combinator on space platform

9 months ago
(updated 9 months ago)

https://ibb.co/tB74wLF

Only way I could save the game was to remove it. A few minutes later it occurred with combinators placed planetside as well.

9 months ago
(updated 9 months ago)

I am getting this same error without owning space expansion

Cannot save map: The mod Moon Logic 2 (0.1.7) caused a non-recoverable error.
Please report this error to the mod author.

Error while running event Moon_Logic_2::on_save()
Cannot serialise lua functions

After clearing all code from the combinator it still threw the error. Deleting all three combinators I was messing with allowed me to save again.

Edit: After building them again, and putting the same code I had in there, it let me save.

Edit 2: I originally had user(me) defined functions in there. Thinking that those might be what was causing it I rewrote it to all to not use the functions instead. It still failed to save before deleting the combinator. After deleting and replacing the combinator, and putting the same functionless code in there is when I could save.

9 months ago
(updated 9 months ago)

Only way I could save the game was to remove it. A few minutes later it occurred with combinators placed planetside as well.

Have you tried what I mentioned here?

Edit 2: I originally had user(me) defined functions in there. Thinking that those might be what was causing it I rewrote it to all to not use the functions instead. It still failed to save before deleting the combinator. After deleting and replacing the combinator, and putting the same functionless code in there is when I could save.

Meaning, are you also using user defined functions in the combinators?
After doing this and it being long enough for a few autosaves, it hasn't happened again.

9 months ago

I just confirmed, adding a combinator with user defined functions will cause this error until you delete the combinator.
Not even clearing or changing the code will fix it.

9 months ago

Yes, and I assumed that was the problem but was thrown a bit by the fact that removing them didn't fix it right away. Problem is I have an array to sort, and dunno how to do that without a function.

9 months ago
(updated 9 months ago)

Yes, and I assumed that was the problem but was thrown a bit by the fact that removing them didn't fix it right away. Problem is I have an array to sort, and dunno how to do that without a function.

Just unfunction/unoptimize the code.
You know how they teach you to turn repeat code into functions to reduce file size and other optimization reasons?
Do that backwards.
Everywhere you call the function gets replaced with all the code from inside the function.
Might make your script much larger, but that seems to be the only way it will work in current version.
Any functions built into lua and the game are fine, only your custom function defines need to be removed.

Edit: Anywhere you have function funct_name(vars) -[code that does stuff when funct is called]- end needs to be removed by replacing everywhere you call funct_name(intput_vars) with the -[code that does stuff when funct is called]-, then deleting the whole function funct_name(vars) -[code that does stuff when funct is called]- end.

9 months ago

Works everywhere except the table.sort function :) Unless I'm missing something. Suppose I could re-invent the built-in sort function myself to avoid needing the user-defined comparator function, but that's annoying as hell.

New response