rons0n Posted October 24, 2015 Share Posted October 24, 2015 So a simple problem but I'm probably over thinking it, my backpacks for my characters no longer working. Right now I just defaulted them to act like regular backpacks but I wanted them to start in their inventory. Even after the change the game still crashes for clients, any reason why? I know its something widget related but the only widget related things I see is the WidgetSetup. backpack1:local assets ={ Asset("ANIM", "anim/armor_littleredannie.zip"), Asset("ATLAS", "images/inventoryimages/armor_littleredannie.xml"), Asset("IMAGE", "images/inventoryimages/armor_littleredannie.tex"),}local function onequip(inst, owner) owner.AnimState:OverrideSymbol("swap_body", "armor_littleredannie", "backpack") owner.AnimState:OverrideSymbol("swap_body", "armor_littleredannie", "swap_body") inst.components.container:Open(owner) endlocal function onunequip(inst, owner) owner.AnimState:ClearOverrideSymbol("swap_body") owner.AnimState:ClearOverrideSymbol("backpack") inst.components.container:Close(owner)endlocal function fn() local inst = CreateEntity() inst.entity:AddTransform() inst.entity:AddAnimState() inst.entity:AddSoundEmitter() inst.entity:AddMiniMapEntity() inst.entity:AddNetwork() MakeInventoryPhysics(inst) inst.AnimState:SetBank("armor_littleredannie") inst.AnimState:SetBuild("armor_littleredannie") inst.AnimState:PlayAnimation("anim") inst.MiniMapEntity:SetIcon("armor_littleredannie.png") inst:AddTag("fridge") inst:AddTag("nocool") inst.foleysound = "dontstarve/movement/foley/backpack" if not TheWorld.ismastersim then return inst end inst.entity:SetPristine() inst:AddComponent("inspectable") inst:AddComponent("inventoryitem") inst.components.inventoryitem.imagename = "armor_littleredannie" inst.components.inventoryitem.atlasname = "images/inventoryimages/armor_littleredannie.xml" inst.components.inventoryitem.cangoincontainer = false inst:AddComponent("equippable") inst.components.equippable.equipslot = EQUIPSLOTS.BODY inst.components.equippable:SetOnEquip(onequip) inst.components.equippable:SetOnUnequip(onunequip) inst:AddComponent("container") inst.components.container:WidgetSetup("backpack") MakeHauntableLaunchAndDropFirstItem(inst) return instendreturn Prefab("common/inventory/armor_littleredannie", fn, assets)backpack2:local assets ={ Asset("ANIM", "anim/anniepack.zip"), Asset("ANIM", "anim/swap_anniepack.zip"), Asset("ATLAS", "images/inventoryimages/anniepack.xml"), Asset("IMAGE", "images/inventoryimages/anniepack.tex"),}local function onequip(inst, owner) owner.AnimState:OverrideSymbol("swap_body", "swap_anniepack", "backpack") owner.AnimState:OverrideSymbol("swap_body", "swap_anniepack", "swap_body") if inst.components.container ~= nil then inst.components.container:Open(owner) end endlocal function onunequip(inst, owner) owner.AnimState:ClearOverrideSymbol("swap_body") owner.AnimState:ClearOverrideSymbol("backpack") if inst.components.container ~= nil then inst.components.container:Close(owner) endendlocal function fn() local inst = CreateEntity() inst.entity:AddTransform() inst.entity:AddAnimState() inst.entity:AddSoundEmitter() inst.entity:AddMiniMapEntity() inst.entity:AddNetwork() MakeInventoryPhysics(inst) inst.AnimState:SetBank("anniepack") inst.AnimState:SetBuild("anniepack") inst.AnimState:PlayAnimation("idle") inst.MiniMapEntity:SetIcon("anniepack.png") inst.foleysound = "dontstarve/movement/foley/backpack" if not TheWorld.ismastersim then return inst end inst.entity:SetPristine() inst:AddComponent("inspectable") inst:AddComponent("inventoryitem") inst.components.inventoryitem.imagename = "anniepack" inst.components.inventoryitem.atlasname = "images/inventoryimages/anniepack.xml" inst.components.inventoryitem.cangoincontainer = false inst:AddComponent("equippable") inst.components.equippable.equipslot = EQUIPSLOTS.BODY inst.components.equippable:SetOnEquip(onequip) inst.components.equippable:SetOnUnequip(onunequip) inst:AddComponent("container") inst.components.container:WidgetSetup("backpack") MakeHauntableLaunchAndDropFirstItem(inst) return instendreturn Prefab("common/inventory/anniepack", fn, assets) Log: [00:00:59]: [string "scripts/widgets/containerwidget.lua"]:29: attempt to index local 'widget' (a nil value)LUA ERROR stack traceback: scripts/widgets/containerwidget.lua:29 in (method) Open (Lua) <24-132> scripts/screens/playerhud.lua:185 in (upvalue) OpenContainerWidget (Lua) <182-187> scripts/screens/playerhud.lua:195 in (method) OpenContainer (Lua) <189-197> scripts/components/container_replica.lua:204 in (method) Open (Lua) <190-211> scripts/components/container_replica.lua:58 in (field) fn (Lua) <56-59> scripts/scheduler.lua:194 in (method) OnTick (Lua) <168-225> scripts/scheduler.lua:406 in (global) RunScheduler (Lua) <404-412> scripts/update.lua:162 in () ? (Lua) <146-219> Link to comment https://forums.kleientertainment.com/forums/topic/58664-i-derped-with-the-backpacks/ Share on other sites More sharing options...
DarkXero Posted October 25, 2015 Share Posted October 25, 2015 @rons0n, default backpacks work because the client loads the containerwidget that corresponds to the prefab name.Your backpack is named anniepack, and no anniepack is found in the params table in containers.lua.The WidgetSetup of the container component does nothing for the client.if not TheWorld.ismastersim then inst.OnEntityReplicated = function(inst) inst.replica.container:WidgetSetup("backpack") end return instend Link to comment https://forums.kleientertainment.com/forums/topic/58664-i-derped-with-the-backpacks/#findComment-682404 Share on other sites More sharing options...
rons0n Posted October 25, 2015 Author Share Posted October 25, 2015 Oh okay, I swear I had that exactly line but I must've renamed it to anniepack by accident instead of leaving it as backpack. So in the end I just simply renamed something I shouldnt have. Silly me Allwell, thanks for pointing out my mistake that I should've guessed myself! Link to comment https://forums.kleientertainment.com/forums/topic/58664-i-derped-with-the-backpacks/#findComment-682447 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