Modding Discussion Is a Ender Chest possible? In Starbound

Discussion in 'Starbound Modding' started by Noah Nebula, Sep 20, 2018.

  1. Noah Nebula

    Noah Nebula Sandwich Man

    Is there a mod that adds an Ender Chest like container from Minecraft?

    So you can have two different chests, but they share the same inventory.

    If not, is it possible to do? How would I go about doing it?
     
    Last edited: Sep 20, 2018
  2. bk3k

    bk3k Oxygen Tank

    It has been forever since I played minecraft and I don't even remember what an Ender Chest is. You might want to explain further what you're looking for.
     
  3. NexusTheBrony

    NexusTheBrony Parsec Taste Tester

    a single storage tied to the player rather than the object, yet the player can't access it without the object
     
  4. Noah Nebula

    Noah Nebula Sandwich Man

    So you can have two different chests, but they share the same inventory.

    This guy can explain it if you still don't understand


    That's what I was thinking as well. How would I do that?

    Maybe add another item tab for your inventory that can only be accessed when you open the container. But how would I connect it to the container?

    Here is the player.config.patch that adds in the extra inventory tab. This only adds the extra tab, it cannot be visible in your inventory.

    [
    {
    "op": "add",
    "path": "/inventory/itemBags/arcstorageBag",
    "value": {
    "priority": 6,
    "size": 40
    }
    },
    {
    "op": "add",
    "path": "/inventoryFilters/arcstorageBag",
    "value": {
    "categoryWhitelist": [
    ]
    }
    }
    ]

    Now how do I access the tab through a container?
     
    Last edited by a moderator: Sep 23, 2018
  5. The Avelon

    The Avelon Phantasmal Quasar

    EDIT: I ranted a bit but I think most of what I said was irrelevant.

    So I think you could lay it out like this:

    The only item that goes in that tab is the player's Ender Key. The key itself is what holds the items, a la Enhanced Storage or Digital Storage. While the pane is open it copies items from the key on Init and the update writes the item information as a table to the key.

    So when you close it and re-open it, it will have the updated inventory including empty slots, so you wouldn't be able to dupe items with it because the copying from the key only fires once. Since your tab is invisible unless you make a GUI for it, the player would never interact with their key except to initially craft it.

    EDIT2: This would probably still be highly iffy in multiplayer and COULD dupe items if 2 players can access the same container at the same time... I do not remember if that is possible in Starbound; it's been a long time since I played it online.

    EDIT3: It would also be inherently incompatible with automated item transfer systems if you did this; storing items in it remotely would just cause those items to be deleted when you opened it manually.

    You could prevent duping if there is a way to execute code when the pane is closed. Not sure if uninit works on container UIs.

    Another thing to look into is perhaps making the chest itself NOT be a container but rather just interactable furniture that opens your custom UI pane. That should prevent duping too since it would then be instanced, and it would preclude problems with autoamated systems. But then I am not sure if you could execute the lua commands you need - container consume and so forth.
     
    Last edited: Sep 20, 2018
  6. Noah Nebula

    Noah Nebula Sandwich Man

    I was thinking of having the items on your character just under its own hidden tab. And you can only access that item tab when you open up a certain container. That way we have no bugs of cloning items and the items can be private for multiplayer.
     
  7. The Avelon

    The Avelon Phantasmal Quasar

    Yeah, but how do you plan to make them show up in said tab? These will be already whitelisted for the other tabs, so they will show up in those tabs if the player is directly holding them.

    What I'm suggesting is storing them in the item that you are creating, which won't show up in any visible tab.
     
  8. bk3k

    bk3k Oxygen Tank

    Well one thing you might find interesting right off is this mod. It isn't exactly what you're looking for because it stores the data for all items contained within itself. It is an active item that destroys itself when interacted with, but it calls an interface which has the data for the items. Upon Uninit() it gives the player an item containing all the data. So that avoids duplication.

    There is more than way then to go about it.

    1. Store the data in world data. That would only be accessible from the current world, but anywhere in the world would be fine. But that can easily work with objects placed in the world. The nameSpace used to store the data can incorporate the player's UUID, so each player has their own inventory. In this case the object merely calls up an interface. The player need not carry around an item.

    2. Do much what that mod does, but make the player carry an "Ender's Key" that can only be used with the specific type of object near by. But essentially it otherwise does the same thing as the mod I linked to but with an added object requirement to use it. This can be used on multiple worlds since all the inventory data is stored within the item.
     
    The Avelon likes this.
  9. The Avelon

    The Avelon Phantasmal Quasar

    Can a script attached to an activeitem access anything that a container UI can't? The reason I ask is that were I to use this mod (and I probably would!), I would prefer to activate the chest than to use an item from inventory if possible.

    The hiccup I'm most worried about is, can the script attached to the custom UI window read (and write to) the table being stored in your Ender Key, or merely detect that you have one?

    Conversely, if you have an Ender's Key and activate the chest object, could that trigger the EK's active effect (bypassing the need for using it manually)?
     
    Last edited: Sep 21, 2018
  10. bk3k

    bk3k Oxygen Tank

    I don't think that's a problem so much. Scripted interface panes can access the player table. This is probably what you want
    Code:
    #### `ItemDescriptor` player.consumeItem(`ItemDescriptor` item, [`bool` consumePartial], [`bool` exactMatch])
    
    Attempts to consume the specified item from the player's inventory and returns the item consumed if successful. If consumePartial is `true`, matching stacks totalling fewer items than the requested count may be consumed, otherwise the operation will only be performed if the full count can be consumed. If exactMatch is `true` then parameters as well as item name must match.
    It should return the ItemDescriptor, and thus the data you need. So you do much the same thing - consume the item with the interface's init() and return it upon uninit() via player.giveItem()

    So something like this (unchecked - simply typed into browser window)
    Code:
    container = {}
    init = function()
      local key = {
        name = "ender_key",
        count = 1
      }
      local itemDes = player.consumeItem(key, false, false)
      if itemDes then
        storage.enderKey = true
        if itemDes.properties then
          container = itemDes.properties.container or {}
        end
      else
        storage.enderKey = false
      end
    end
    
    
    uninit = function()
      local key = {
        name = "ender_key",
        count = 1,
        properties = { 
          container = container
        }
      }
      player.giveItem(key)
    end
    
     
    The Avelon likes this.
  11. Noah Nebula

    Noah Nebula Sandwich Man

    So would this script be implemented in the containers .object file?

    "scripts" : ["????.lua"]

    I made the enderchest.object and enderkey.activeitem

    How can we make this work?
     

    Attached Files:

    Last edited by a moderator: Sep 23, 2018
  12. The Avelon

    The Avelon Phantasmal Quasar

    I think next creating a config for the chest UI, so that not all chests of the same slot number gain the effect, because object scripts can't access player but scriptpanes like the container UI can, so that's where you'll be attaching your script.

    EDIT: The script as written kicks an error but just change storage.enderKey to hasEnderKey and it works for taking the key and giving one back on uninit.

    I made a config and attached it because I was curious if it was going to be that simple. It isn't, but that's okay - next stage will be populating the chest with the items stored in the key. Shouldn't be too much of a problem, this is where the backpack mod and enhanced storage come into play. If necessary we can write a table like in ES's quickstack.lua - this is how I got the take all script going, by reversing that script's logic.

    But since we know that the key part works and are at this step, the definite answer to the original question is yes. Ender Chests can be made for Starbound. :)
     
    Last edited: Sep 23, 2018
  13. Noah Nebula

    Noah Nebula Sandwich Man

    Ok so I made the .config file as enderchest24.config, and I am using @bk3k 's script in the .config like so. It does not work, but I believe that one of you understands why.


    {
    "script" : "/scripts/enderstorage.lua",
    "gui" : {
    "background" : {
    "type" : "background",
    "fileHeader" : "/interface/chests/chestheader.png",
    "fileBody" : "/interface/chests/slots17to24.png",
    "fileFooter" : "/interface/chests/chestfooter.png"
    },
    "objectImage" : {
    "type" : "image",
    "position" : [40, 104],
    "file" : "",
    "centered" : true,
    "maxSize" : [40, 40],
    "minSize" : [40, 40]
    },
    "clear" : {
    "type" : "button",
    "base" : "/interface/button.png",
    "hover" : "/interface/buttonhover.png",
    "press" : "/interface/buttonhover.png",
    "caption" : "Take all",
    "position" : [52, 26]
    },
    "itemGrid" : {
    "type" : "itemgrid",
    "position" : [81, 62],
    "dimensions" : [4, 4],
    "spacing" : [19, 19],
    "backingImage" : "/interface/inventory/empty.png"
    },
    "itemGrid2" : {
    "type" : "itemgrid",
    "position" : [4, 43],
    "slotOffset" : 16,
    "dimensions" : [8, 1],
    "spacing" : [19, 19],
    "backingImage" : "/interface/inventory/empty.png"
    },
    "count" : {
    "type" : "label",
    "value" : "24 SLOTS",
    "hAnchor" : "mid",
    "position" : [120, 140]
    },
    "overlay" : {
    "type" : "image",
    "file" : "/interface/chests/shine17to24.png",
    "position" : [0, 3]
    },
    "close" : {
    "type" : "button",
    "base" : "/interface/x.png",
    "hover" : "/interface/xhover.png",
    "pressed" : "/interface/xpress.png",
    "pressedOffset" : [0, 0],
    "position" : [143, 156]
    }
    }
    }
     

    Attached Files:

  14. bk3k

    bk3k Oxygen Tank

    I'm on mobile so I can't give a comprehensive answer. That code was far from complete. It was only a starting point to give an idea of what how it can work. You would need to pick up Lua to go any further with it.
     
    The Avelon and Noah Nebula like this.
  15. The Avelon

    The Avelon Phantasmal Quasar

    Yeah, all that script does right now is give you the key. But for attaching the script the syntax is

    Code:
    "scripts" : [ "scripts/enderstorage.lua" ],
    "scriptDelta" : 20
    And if you switch the item type and tag from key to tool you can confirm it entering and leaving inventory properly.
     
    Last edited: Sep 24, 2018
  16. Noah Nebula

    Noah Nebula Sandwich Man

    I tried implementing it that way, and now the game crashes when I open the chest
     
  17. The Avelon

    The Avelon Phantasmal Quasar

    That's odd, maybe it is in the wrong parentheses? I used a slightly different naming convention but here is the one I made (using your handle, it's nn_enderchest24.config).

    Don't mind the extra lines in the script. I was messing around with it but it still does nothing extra. I think the key is set to tool as well so is visible in inventory.
     

    Attached Files:

  18. bk3k

    bk3k Oxygen Tank

    Because you'd actually want
    Code:
    "scripts" : [ "/scripts/enderstorage.lua" ],
    "scriptDelta" : 20
    Which should at least stop it from crashing. That of course assumes you have a script named enderstorage.lua sitting in /scripts/ because if you don't the game will still crash.
     
    Noah Nebula likes this.
  19. The Avelon

    The Avelon Phantasmal Quasar

    Whoops, I got autocorrected and didn't notice! My bad. Gboard really doesn't like code.

    Well you can ignore the zip I posted; just add that / behind scripts and your version will be good to go.
     
  20. Noah Nebula

    Noah Nebula Sandwich Man

    Yea the chest opens without crashing. But does not share the same inventory of another chest, how do we extend bk3k's script to accomplish this?
     

Share This Page