HelicopterRevival


Adds a fully animated attack helicopter to the game. Ideal for getting from A to B quickly, exploring the map, building islands and nuking biters from the sky. Originally forked from Kumpu with fixes for Factorio 0.18.2+, but adding some enhancements of my own as well.

Content
6 months ago
0.18 - 2.0
85.3K
Transportation

g Identified: Cause of the saving error

a month ago

Since 2.0, the reason for the "Cannot serialise Lua functions" error when running on_save() can be found on the forums here:

https://forums.factorio.com/viewtopic.php?p=667426#p667426

Since 2.0 (ref 113852) this error is thrown if you have lua functions inside of storage. Due to saving speed reasons, when lua values are saved we traverse the data in the most efficient way possible, by directly reading lua tables and lua values and if there is a lua function found we throw an error because this is an object that cannot be saved. If you want you can just dump the storage using serpent.dump and whenever you see eval() (if i remember correctly) then that was a lua function dumped and it is illegal to be there. Reason why this error is thrown is because lua functions cannot be serialised and if allowed they would have to be saved as nil instead and on load they would appear to be deleted.

Functions are no longer silently ignored when serialising the storage (previously global) table.
It seems like util.lua - and a lot of the code - utilises storage for interacting with and managing object instances. If you still want those tables to be serialised, you might need to strip out the functions. Otherwise, using your own custom ''global'' table for storing them should work.

a month ago
(updated a month ago)

Awesome, thank you!
I suspected something like that, but hadn't gotten anything solid so far... All the on_save() errors lead to... basically nothing, but now... oof... You see, HR (as well as the original Helicopters) uses stdlib, which does its own magic in there... I've been looking into ditching that myself, but it might take some more time...

This really is a great news, though!

a month ago
(updated a month ago)

From looking at the code, it seems like the stdlib stuff doesn't really do much interaction with storage, and even then it seems limited to just trains.

I imagine most of the difficulty will come from:
- checkAndTickInGlobal
- callInGlobal
- setMetatablesInGlobal
- insertInGlobal

Along with any direct access of storage that assumes the returned table contains function definitions, e.g:

for k, curHeli in pairs(storage.helis) do
    if not curHeli.curState then
        if curHeli.goUp then
            curHeli:changeState(curHeli.engineStarting)  -- changeState() can't exist on deserialised helicopters
        else
            curHeli:changeState(curHeli.descend)  -- changeState() can't exist on deserialised helicopters
        end
    end
end
18 days ago

Does anyone know how to fix that error ourselves? I'd do it and even upload it here but sadly I have zilch luascript experience or any coding experience whatsoever.

18 days ago

Does anyone know how to fix that error ourselves? I'd do it and even upload it here but sadly I have zilch luascript experience or any coding experience whatsoever.

It's... quite a modification... But here's a thing - a lot of people never encountered this issue, but I'm not denying it doesn't exist either... I found a temporary solution if this happens - you just deconstruct heli and plop it back on...

17 days ago

Thank you very much! The mod is too awesome to pass up to an error :)

New response