5Y2h6YCa Posted January 28, 2024 Share Posted January 28, 2024 Firstly i wrote this in modmain.lua local params = {} params.yuzu_ammo = { widget = { slotpos = { Vector3(0, 32 + 4, 0), }, slotbg = { { image = "slingshot_ammo_slot.tex" }, }, animbank = "ui_cookpot_1x2", animbuild = "ui_cookpot_1x2", pos = Vector3(0, 15, 0), }, usespecificslotsforitems = true, type = "hand_inv", excludefromcrafting = true, } local containers = require "containers" local old_widgetsetup = containers.widgetsetup function containers.widgetsetup(container, prefab, data) local pref = prefab or container.inst.prefab if pref == "yuzu_ammo" then local t = params[pref] 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) end else return old_widgetsetup(container, prefab, data) end end Then i added this in the prefab functions inst.components.container:WidgetSetup("yuzu_ammo") At frist it worked,but the problem showed up after i add caves to my world. The report shows: "scripts/widgets/containerwidget.lua":30: attempt to index local "widget"(a nil value) Link to comment https://forums.kleientertainment.com/forums/topic/154042-got-some-problems-with-container-widget/ 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