Marmalade Posted October 31, 2023 Share Posted October 31, 2023 I'm creating an item similar to Walter's slingshot that contains an item slot. Whenever I equip the item in a world with caves enabled, the game gives me this crash screen: This report doesn't give me the exact line of code in my mod like I'm used to with most crash screens, and when I go to line 30 in containerwidget.lua, I still can't find any pointers as to why my game is still crashing! containerwidget.lua: Here is my snippet of code in my modmain.lua that I believe creates the container: local function CreateSpecialSlingshotWidget() local params = containers.params params.specialslingshot = { 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, } containers.MAXITEMSLOTS = math.max(containers.MAXITEMSLOTS, params.specialslingshot.widget.slotpos ~= nil and #params.specialslingshot.widget.slotpos or 0) local old_widgetsetup = containers.widgetsetup function containers.widgetsetup(container, prefab, data) local pref = prefab or container.inst.prefab if pref == "specialslingshot" 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 function params.specialslingshot.itemtestfn(container, item, slot) return item:HasTag("specialitem") end end CreateSpecialSlingshotWidget() Link to comment https://forums.kleientertainment.com/forums/topic/152119-my-modded-container-is-crashing-the-game-when-caves-are-enabled/ Share on other sites More sharing options...
Rickzzs Posted November 1, 2023 Share Posted November 1, 2023 Two steps. 1.in prefab, server inst:AddComponent("container") inst.components.container:WidgetSetup("piggyback") 2.in prefab, client. If you are not registering a widget that has its name exactly the same as the prefab if not TheWorld.ismastersim then inst.OnEntityReplicated = function(inst) if inst.replica.container then inst.replica.container:WidgetSetup("piggyback") end end return inst end or 2.in modmain, both server and client, the name must match the prefab local params=require("containers").params params.piggyback={...(params you would like)} 2 Link to comment https://forums.kleientertainment.com/forums/topic/152119-my-modded-container-is-crashing-the-game-when-caves-are-enabled/#findComment-1676635 Share on other sites More sharing options...
Marmalade Posted November 1, 2023 Author Share Posted November 1, 2023 14 hours ago, Rickzzs said: if not TheWorld.ismastersim then inst.OnEntityReplicated = function(inst) if inst.replica.container then inst.replica.container:WidgetSetup("piggyback") end end return inst end Thank you, this simple change did just the trick! Link to comment https://forums.kleientertainment.com/forums/topic/152119-my-modded-container-is-crashing-the-game-when-caves-are-enabled/#findComment-1676778 Share on other sites More sharing options...
AlbertDelRiver Posted December 26, 2023 Share Posted December 26, 2023 I know this thread is EXTREMELY old but this helped me figure out a problem I had with changing the properties of the spice pack to the same slot capacity of the krampus sack. I didn't know the game ran on like, two 'dimensions' if caves are added. Thanks to the both of you. Link to comment https://forums.kleientertainment.com/forums/topic/152119-my-modded-container-is-crashing-the-game-when-caves-are-enabled/#findComment-1691011 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