Modding Discussion Storage, Inventory, Containers

Discussion in 'Starbound Modding' started by The Avelon, Aug 18, 2018.

  1. The Avelon

    The Avelon Phantasmal Quasar

    So I was thinking about ways to interact with things in unloaded chunks. While they are unloaded they do nothing of course, but if you can directly mess with container contents in a chunk that IS loaded, I have a theoretical workaround.

    The idea is adding a category for player inventory that doesn't have an associated tab. The items that go here are dummy items which store a few string definitions: a world or chunk, a container, and an item id.

    The point is let's say you have a mod installed that uses this system and has a machine that will slowly produce copper bars from water over time. You put in a stack of water, get it wired, and push the button to start. It begins work, but when you leave the chunk it will stop.

    But what if you have a script firing that will, on an identical timer, start adding those dummy items into your inventory? Then you beam aboard your ship and you start receiving IOU items via a global script, which specify created copperbar, consumed water, container blah on world blah in chunk blah.

    Opening that container checks to see if you have any dummy items that involve it and if so, removes them and processes that many items. It deletes that many water units from input and adds that many copper bars to output.
  2. Quenn1599

    Quenn1599 Scruffy Nerf-Herder

    Why not just track the time when the machine's chunk was unloaded and then get the time when the chunk is loaded again and just do something like (rate of production) * (delta time)? It would be very efficient compared to adding another constant background task.
    The Avelon likes this.
  3. The Avelon

    The Avelon Phantasmal Quasar

    Oho?! I did not know it was possible to check the time on specific chunks loading and unloading, but yes, that is exactly what I'd like to be looking at.

    Do you know of some examples of scripts checking chunk load/unload times I could study?
  4. bk3k

    bk3k Oxygen Tank

    The electric mining drill(my script) from ISE4 aka Industrialization: Starbound Edition, or the machines from Idle Miners (same script slightly updated)

    The version in Idle Miners even saves the time in the object's properties, so it counts time when you've closed the game.
    Besides checking if the chunk is loaded, I also use uninit() calls to record the time. Feel free to reuse any code you find useful.
    The Avelon likes this.
  5. The Avelon

    The Avelon Phantasmal Quasar

    Excellent, thanks bk3k! I don't know just exactly what I'm going to do with this, but it's going to be devious!

Share This Page