notnotmelon / factorissimo-2-notnotmelon

Factorissimo adds factory buildings to Factorio. Place them down, walk in, build your factories inside!
https://mods.factorio.com/mod/factorissimo-2-notnotmelon
MIT License
14 stars 9 forks source link

interface get_factory_by_entity returns nil #101

Open kuxynator opened 1 week ago

kuxynator commented 1 week ago

the error occurs as soon as space-age is active. it works without sapce-age new game w/o space age > works open the same save with spage-age > nil new game w/ space age > nil

entiy is userdata: {name = "factory-1", type = "storage-tank"}

we had the same problem before, but we didn't find out which mod was causing it. but now we can't ignore spage age ;-)

notnotmelon commented 1 week ago

Here is the relevant code


remote_api.get_factory_by_entity = function(entity)
    if entity == nil then return nil end
    return storage.factories_by_entity[entity.unit_number]
end

It seems that the entity userdata requires a unit_number defined.

kuxynator commented 3 days ago

there is a unit number image and I call this in on_built_entity event, if that helps