Abandoned Ruins - Updated (core)

by Keysivi

This mod doesn't do anything by itself. You need to install ruin-set mods or no ruin will be spawned. It then can spawn randomly choosen ruins in the world. These ruins are destroyed fragments of bases, forts, small oases, and more. (Now co-authored with roland77)

Content
5 days ago
2.0
4.50K

b [FIXED] util.safe_insert_fluid() invalid and crashing logic

a month ago
    if fluids[name] or not fluids[name].valid then
      insert{name = name, amount = amount}

This inserts fluid if given fluid exists... or when the fluid doesn't exist and is not valid. Unsurprisingly it crashes on second option.
You probably meant:
if fluids[name] and fluids[name].valid then

a month ago
(updated a month ago)

Also with debug in spawning.lua in spawn_entity():

  local e = surface.create_entity
  {
    ...
  }
  if debug_log then log(string.format("[spawn_entity]: Entity created: e.valid='%s'", e.valid)) end

The debug log crashes when e doesn't exist.
This happens in a ruin with 16 entities, for enemy artillery-wagon and enemy fluid-wagon. Probably 'Realistic Ruins' ruin set.

a month ago
(updated a month ago)

Also with debug in spawning.lua in spawn_entity():
local e = surface.create_entity { ... } if debug_log then log(string.format("[spawn_entity]: Entity created: e.valid='%s'", e.valid)) end
The debug log crashes when e doesn't exist.
This happens in a ruin with 16 entities, for enemy artillery-wagon and enemy fluid-wagon. Probably 'Realistic Ruins' ruin set.

Ah:
https://lua-api.factorio.com/latest/classes/LuaSurface.html#create_entity

Return values

The created entity or nil if the creation failed.

Okay, so e.valid will fail when e is nil.

And I don't see any proper handling of e being nil. It just proceeds and maybe invoke other functions where nil might be stopped.

a month ago
(updated a month ago)

And I fixed the above one. Now I just wonder why there are local copies of prototypes.fluid and entity.insert_fluid()?

a month ago

I have removed the local copies (no need, just reference the original directly) with new release 1.3.9.

This thread has been locked.