Jump to content

Expanding Chef Pouch


Recommended Posts

A while ago I asked this question: 

 And it worked. But when I loaded it on my dedicated server and my friend joined, his hud and stuff was all messed up. I tried to fix it but I couldn't, so I removed the code. I really would like to try to get it to work.

 

Information:

My friend's stat and parts of his hud were disappearing. My hud was fine. It may have been due to me being an admin on the server.

The code (that didn't work):

local require = GLOBAL.require -- Obviously needs a require
local Vector3 = GLOBAL.Vector3 -- Also needs Vector3
local containers = require "containers" -- And containers.lua

Assets = {
    Asset("ANIM", "anim/ui_backpack_2x4.zip"), -- The anim file for the backpack widget
}

local params = {}

params.spicepack = -- I've kept the name as "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
        end
        container:SetNumSlots(container.widget.slotpos ~= nil and #container.widget.slotpos or 0)
    else
        containers_widgetsetup_base(container, prefab, data)
    end
end

Can anyone figure out what was wrong?

Edited by decduck3
Link to comment
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
 Share

×
  • Create New...