Brave New World

by canidae

RTS-like scenario for Factorio. Player character is removed, all work must be done by bots

Scenarios
2 years ago
0.16 - 1.1
8.12K

i Seablock rock chest problem: [resolved]

3 years ago
(updated 3 years ago)

I think something like this would fix the problem with moving the items from the seablock rock chest. At least, it works for me

function moveSeablockChest(event)
  -- tiny hack to work around that SeaBlock sets up stuff after BNW on load
  if global.seablocked then
    return
  end

  local surface = game.surfaces["nauvis"]
  if not surface then
    return
  end

  -- move everything from the Home rock to the other chest
  local home_rock = surface.find_entity("rock-chest", {0.5, 0.5})
  if not home_rock then
    return
  end

  for name, count in pairs(home_rock.get_inventory(defines.inventory.chest).get_contents()) do
    global.seablock_chest.insert{name = name, count = count}
  end

  home_rock.destroy()
  global.seablock_chest = nil

  -- unregister handler
  script.on_nth_tick(10, nil)

  global.seablocked = true
end

script.on_nth_tick(10, moveSeablockChest)
3 years ago

Interesting. I should hunt through the Seablock code looking for how the home rock is created. It shouldn't be that hard to find.

This solution is an implementation of the brute force idea I suggested almost as a joke. :-) It's a good one. :-) I may actually incorporate it. :-)

One answer I would like is whether the on_nth_tick function in delete mode affects only that mod's events. I would be somewhat surprised if it was global because that would be a huge source of inter-mod conflicts.

3 years ago
(updated 3 years ago)

Yes, i didn't know, how to do it better :)
The rock-chest is created in Seablock in control.lua:73 with on_chunk_generated event.

Regarding the question. It's mentioned in documentation to use nil to unregister.
https://lua-api.factorio.com/latest/LuaBootstrap.html#LuaBootstrap.on_nth_tick
It doesn't explicitly say, that its only for the given mod, but it wouldn't make sense to describe a solution, which would break mods. Anyway, i really would like a definite answer, too

3 years ago

The on_chunk_generated event?! That's... hilarious. Such an ugly hack! Of course, the 'right' way to do it is to use a scenario like BNW does so it can determine the initial setup. Which would make SeaBlock and BNW incompatible, and you'd need a "SeaBlock BNW" scenario to combine them.

3 years ago
(updated 3 years ago)

Maybe, we could ask KiwiHawk, the new dev of Seablock, if he checks this code and provides a better alternative...
I'm not very experienced with factorio modding, though

3 years ago
(updated 3 years ago)

If it's ugly but it works, is it ugly? πŸ˜† That part isn't my code btw!

I'm planning on adding a remote interface to control the initial tech unlocks (requested by the dev for the omni compatibility mod https://mods.factorio.com/mod/OmniSea). I could put something else in the interface, listing starting items.

Any better suggestions?

3 years ago

Hey all.

I wanted to give it a try with seablock and cant get the stuff out of the starting rock.
I found that code above but i have no idea what to do with it.

Would it be possible to change the starting-layout from brave new world? Move everything 4 tiles to the left would solve the issues.

3 years ago

Hey all.

I wanted to give it a try with seablock and cant get the stuff out of the starting rock.
I found that code above but i have no idea what to do with it.

Would it be possible to change the starting-layout from brave new world? Move everything 4 tiles to the left would solve the issues.

That is an interesting idea. Brave New World actually has specific code for finding the starting rock and replacing it. Unfortunately, that code doesn't run until you do certain things.

Try having your robots build something and then take it down. Something the have they materials to build without the starting rock. That should cause the starting rock to disappear and be replaced with a logistics chest. I'll get to sticking that 'tick' based code this weekend. I really don't like the solution, it's a total hack. But it should work.

3 years ago

Omnifarious - do you use discord? Would be easier to discuss on there any changes I can do in Sea Block to make this compatibility work better.
Sea Block discord: https://discord.gg/AaryjXX/

3 years ago

Omnifarious - do you use discord? Would be easier to discuss on there any changes I can do in Sea Block to make this compatibility work better.
Sea Block discord: https://discord.gg/AaryjXX/

I just joined your Discord. I'll likely be working on this later today or tomorrow.

New response