Sign in to follow this  
Arthurian Titan

Make Backpack have less slots

Recommended Posts

Hi! I'm trying to make a mod that reduces the quantity of slots on a backpack, however I'm unable to accomplish it. I would appreciate some help in how to reduce the quantity of slots, the backpack interface changes, but it continues with the same quantity of slots. My modmain will go attached here. I would appreciate any help!


Share this post

Link to post
Share on other sites
krylincy    49


your  mod looks very complex and i am not into it. but why did you edit the widgets/inventorybar if you just wanna change the backpack widget setup?

your widgetsetup_Base looks good, did you receive the testing print? i thought we must re-initialize the backpacks with the new setup function because they are already setup with the old function. 

have you tried to put more print messages into your code to debug what runs and what not? is it working on serverside/host already? and is your issue with the more slots just visuell or are they also usable as default (maybe only the design didn't change)

i know that might not help you to find the bug/problem ...

Share this post

Link to post
Share on other sites
decduck3    21

Umm... why? I tried to make the Chef Pouch have 8 slots, so it should be pretty similar. From what I've learnt, you can't use a AddPrefabPostInit


containers = GLOBAL.require("containers")

local params = {}

params.spicepack =
	widget =
        slotpos = {
			Vector3(-162, -75 * 0 + 114, 0), -- You have to do it this way since you can't really use a "for" loop outside of a function
			Vector3(-162, -75 * 1 + 114, 0), -- Each one represents one slot
			Vector3(-162, -75 * 2 + 114, 0),
			Vector3(-162, -75 * 3 + 114, 0),
			Vector3(-162 + 75, -75 * 0 + 114, 0),
			Vector3(-162 + 75, -75 * 1 + 114, 0),
			Vector3(-162 + 75, -75 * 2 + 114, 0),
			Vector3(-162 + 75, -75 * 3 + 114, 0),
        animbank = "ui_backpack_2x4", -- Setting the bank
        animbuild = "ui_backpack_2x4", -- And the build
        pos = Vector3(-5, -70, 0),
    issidewidget = true,
    type = "pack",

containers.MAXITEMSLOTS = math.max(containers.MAXITEMSLOTS, params.spicepack.widget.slotpos ~= nil and #params.spicepack.widget.slotpos or 0)

local containers_widgetsetup_base = containers.widgetsetup
function containers.widgetsetup(container, prefab, data)
    local t = params[prefab or container.inst.prefab]
    if t ~= nil then
        for k, v in pairs(t) do
            container[k] = v
        container:SetNumSlots(container.widget.slotpos ~= nil and #container.widget.slotpos or 0)
        containers_widgetsetup_base(container, prefab, data)

You could just modify this to do what you want.

Edited by decduck3
Added Require (at the top)

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this