Arthurian Titan Posted August 22, 2020 Share Posted August 22, 2020 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! modmain.lua Link to comment Share on other sites More sharing options...
krylincy Posted August 22, 2020 Share Posted August 22, 2020 Hi, 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 ... Link to comment Share on other sites More sharing options...
DecDuck Posted August 26, 2020 Share Posted August 26, 2020 (edited) 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 Code: 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 end container:SetNumSlots(container.widget.slotpos ~= nil and #container.widget.slotpos or 0) else containers_widgetsetup_base(container, prefab, data) end end You could just modify this to do what you want. Edited August 26, 2020 by decduck3 Added Require (at the top) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now