Purswader Posted December 14, 2014 Share Posted December 14, 2014 I have one problem with my costum backpack. It works fine as long as you are the host and use it. But If someone else picks it up, his game will crash with attached log. I think its because the images wouldn't load on his side, but i cant figure out why and how to fix it either. Some help would be appreciated.log(1).txt Link to comment Share on other sites More sharing options...
Purswader Posted December 14, 2014 Author Share Posted December 14, 2014 I already fixed that error, to get stuck with:Attempting to send resume requestReceiveResumeRequestMovement prediction enabled Deserialize local session session/09900001953A5D68/KU_KIcrqTgjFailed to load minimap from session data: session/09900001953A5D68/KU_KIcrqTgj_minimap[string "scripts/widgets/containerwidget.lua"]:29: attempt to index local 'widget' (a nil value)LUA ERROR stack traceback:scripts/screens/playerhud.lua:166 in (method) OpenContainer (Lua) <153-171> self = fireover = FireOver shown = true overlayroot = overlays inst = 100073 - (valid:true) focus = true handlers = table: 10E67D40 children = table: 10E67A98 clouds = UIAnim enabled = true focus_target = false vig = UIAnim under_root = under_root owner = 100072 - izim (valid:true) controls = Controls eventannouncer = EventAnnouncer iceover = IceOver root = root name = HUD focus_flow_args = table: 10E67D18 focus_flow = table: 10E67CF0 callbacks = table: 10E67AE8 parent = screenroot bloodover = BloodOver container = 100501 - pak (valid:true) side = false containerwidget = Containerscripts/components/container_replica.lua:202 in (method) Open (Lua) <188-209> self = ondetachclassified = function - scripts/components/container_replica.lua:64 acceptsstacks = true _numslots = 0 _isopen = false issidewidget = false _cannotbeopened = net_bool (22D95EE0) classified = 100740 - container_classified (valid:true) inst = 100501 - pak (valid:true) doer = 100072 - izim (valid:true)scripts/components/container_replica.lua:58 in (field) fn (Lua) <56-59> inst = 100501 - pak (valid:true) self = ondetachclassified = function - scripts/components/container_replica.lua:64 acceptsstacks = true _numslots = 0 _isopen = false issidewidget = false _cannotbeopened = net_bool (22D95EE0) classified = 100740 - container_classified (valid:true) inst = 100501 - pak (valid:true)scripts/scheduler.lua:170 in (method) OnTick (Lua) <144-199> self = running = table: 104EAA58 waitingfortick = table: 104EAA30 tasks = table: 104EAA08 waking = table: 22E641D0 attime = table: 104EAAD0 hibernating = table: 104EAAA8 tick = 474 k = PERIODIC 100501: 0.000000 v = true already_dead = falsescripts/scheduler.lua:380 in (global) RunScheduler (Lua) <378-386> tick = 474scripts/update.lua:134 in () ? (Lua) <118-180> dt = 0.033333335071802 tick = 474 i = 474SCRIPT ERROR! Showing error screen QueryServerComplete no callbackQueryServerComplete no callbackForce aborting... Link to comment Share on other sites More sharing options...
rezecib Posted December 14, 2014 Share Posted December 14, 2014 @Purswader, It looks like the container component isn't being replicated. This could be because of several things, but I'm guessing you don't have an inst.entity:AddNetwork() call in your backpack's constructor. If that's the case, I'd suggest looking at how the backpack prefab file changed between single player and DST, as there are several other relevant changes (most notably the if not TheWorld.ismastersim then return end part). Also, as with any other custom item mods, you should have all_clients_require_mod set to true in the modinfo, but you may have done that already. Link to comment Share on other sites More sharing options...
Purswader Posted December 14, 2014 Author Share Posted December 14, 2014 @Purswader, It looks like the container component isn't being replicated. This could be because of several things, but I'm guessing you don't have an inst.entity:AddNetwork() call in your backpack's constructor. If that's the case, I'd suggest looking at how the backpack prefab file changed between single player and DST, as there are several other relevant changes (most notably the if not TheWorld.ismastersim then return end part). Also, as with any other custom item mods, you should have all_clients_require_mod set to true in the modinfo, but you may have done that already. Thanks for that very quick response. I have all that changes implemented. You can take a look at my code here: local easing = require "easing"local assets={ Asset("ANIM", "anim/backpack.zip"), Asset("ANIM", "anim/swap_pak.zip"), Asset( "IMAGE", "minimap/pak.tex" ), Asset( "ATLAS", "minimap/pak.xml" ), Asset("IMAGE", "images/inventoryimages/pak.tex"), Asset("ATLAS", "images/inventoryimages/pak.xml"),}local function onequip(inst, owner) owner.AnimState:OverrideSymbol("swap_body", "swap_pak", "pak") owner.AnimState:OverrideSymbol("swap_body", "swap_pak", "swap_body") --owner.components.inventory:SetOverflow(inst) inst.components.container:Open(owner) local walkspeed = (owner.components.locomotor.walkspeed * 1.25) local runspeed = (owner.components.locomotor.runspeed * 1.25) endlocal function onunequip(inst, owner) owner.AnimState:ClearOverrideSymbol("swap_body") owner.AnimState:ClearOverrideSymbol("backpack") -- owner.components.inventory:SetOverflow(nil) inst.components.container:Close(owner)endlocal function OnOpen(inst) -- inst.sg:GoToState("open") inst.SoundEmitter:PlaySound("dontstarve/wilson/backpack_open", "open")end local function OnClose(inst) -- inst.sg:GoToState("close") inst.SoundEmitter:PlaySound("dontstarve/wilson/backpack_close", "open")end local slotpos = {}for y = 0, 3 do table.insert(slotpos, Vector3(-162, -y*75 + 114 ,0)) table.insert(slotpos, Vector3(-162 +75, -y*75 + 114 ,0))endlocal function fn() local inst = CreateEntity() inst.entity:AddTransform() inst.entity:AddAnimState() inst.entity:AddSoundEmitter() inst.entity:AddMiniMapEntity() inst.entity:AddNetwork() -- inst.components.container.itemtestfn = itemtest MakeInventoryPhysics(inst) inst.AnimState:SetBank("backpack1") inst.AnimState:SetBuild("swap_pak") inst.AnimState:PlayAnimation("anim") local minimap = inst.entity:AddMiniMapEntity() minimap:SetIcon("pak.tex") if not TheWorld.ismastersim then return inst end inst:AddComponent("inspectable") inst:AddComponent("dapperness") inst.components.dapperness.dapperness = TUNING.DAPPERNESS_TINY inst:AddComponent("inventoryitem") inst.components.inventoryitem.cangoincontainer = false inst.components.inventoryitem.atlasname = "images/inventoryimages/pak.xml" inst.replica.inventoryitem.atlasname = "images/inventoryimages/pak.xml" inst.components.inventoryitem.cangoincontainer = true inst.components.inventoryitem.foleysound = "dontstarve/movement/foley/backpack" inst:AddComponent("equippable") inst.components.equippable.equipslot = EQUIPSLOTS.BODY inst.components.equippable:SetOnEquip( onequip ) inst.components.equippable:SetOnUnequip( onunequip ) inst.entity:SetPristine() inst.components.dapperness.dapperness = ((TUNING.DAPPERNESS_MED*2)) --inst.entity:AddNetwork() inst:AddComponent("container") --inst:AddComponent("container_replica") inst.components.container:WidgetSetup("backpack") --inst.components.container_replica:WidgetSetup("backpack") MakeHauntableLaunchAndDropFirstItem(inst) inst.components.container.onopenfn = OnOpen inst.components.container.onclosefn = OnClose --inst:AddComponent("container_replica") --heaviness(inst) --nocontainers(inst) return instendreturn Prefab( "scripts/prefabs/pak", fn, assets) And my modinfo containsclient_only_mod = falseAnd my friend and i got the very same version of the mod, while testing it. Link to comment Share on other sites More sharing options...
rezecib Posted December 15, 2014 Share Posted December 15, 2014 Ah! Glad to see you've taken a look at the new code already. Let's see... Some things you should probably change, but I don't think are related to the problem you're encountering:I think you want SetPristine() to be right after the if not ismastersim part.It looks like the foleysound should be set before ismastersim, using inst.foleysound = "dontstarve/movement/foley/backpack"Shouldn't the return Prefab part be using "common/inventory/pak"?You're setting inst.components.inventoryitem.cangoincontainer twice in a row. backpack doesn't have OnOpen/OnClose functions stored in the container component anymore.I think I figured out what's causing the crash, and basically it's not your fault. The widget gets populated by a call to containers.widgetsetup, which on the host is called with the arguments self, prefab (where prefab is the "backpack" argument you gave to WidgetSetup). If you look at container_replica, though, on clients, it only passes self, and containters.widgetsetup looks at self.inst.prefab for the setup instead. I think this may just be something that @PeterA needs to fix. In the meantime, it might work to bypass this behavior by overriding containers.widgetsetup like this:local containers = GLOBAL.require("containers")local oldwidgetsetup = containers.widgetsetupcontainers.widgetsetup = function(container, prefab) if not prefab and container.inst.prefab == "pak" then prefab = "backpack" end oldwidgetsetup(container, prefab)end Link to comment Share on other sites More sharing options...
Purswader Posted December 15, 2014 Author Share Posted December 15, 2014 @rezecib Thank you again. I will try and let you know about its success. Maybe Dryicefox is interested in this topic too, cause i originally took his code and there was the same error. Link to comment Share on other sites More sharing options...
Purswader Posted December 15, 2014 Author Share Posted December 15, 2014 In the meantime, it might work to bypass this behavior by overriding containers.widgetsetup like this:local containers = GLOBAL.require("containers")local oldwidgetsetup = containers.widgetsetupcontainers.widgetsetup = function(container, prefab) if not prefab and container.inst.prefab == "pak" then prefab = "backpack" end oldwidgetsetup(container, prefab)end Maybe you can explain me how to override the function in detail? I keep getting errors :/ Link to comment Share on other sites More sharing options...
rezecib Posted December 15, 2014 Share Posted December 15, 2014 @Purswader, Well... it's just like I wrote it. You're modifying the containers table to replace the "widgetsetup" entry with a new function, which includes a call to the old function. What are the errors? Link to comment Share on other sites More sharing options...
Purswader Posted December 15, 2014 Author Share Posted December 15, 2014 rezecib, i tried to modify the original containers file into:local cooking = require("cooking")local params = {}local containers = { MAXITEMSLOTS = 0 }function containers.widgetsetup(container, prefab) 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) endendlocal oldwidgetsetup = containers.widgetsetupcontainers.widgetsetup = function(container, prefab) if not prefab and container.inst.prefab == "pak" then prefab = "backpack" end oldwidgetsetup(container, prefab)end...and the game just crashes on loading with:...[string "../mods/zim together/scripts/containers.lua"]:20: loop or previous error loading module 'containers'LUA ERROR stack traceback:../mods/zim together/scripts/containers.lua:20 in () ? (main) <0-0> cooking = table: 0BEEF578 params = table: 0BEEFD98 containers = table: 0BEEF690=[C]:-1 in (global) require (C) <-1--1>scripts/prefabs/container_classified.lua:1 in (local) fn (main) <0-0>scripts/mainfunctions.lua:80 in (global) LoadPrefabFile (Lua) <72-92> filename = prefabs/container_classified fn = function - scripts/prefabs/container_classified.lua:0 r = nilscripts/gamelogic.lua:156 in (upvalue) LoadAssets (Lua) <112-203> asset_set = FRONTEND load_frontend = true in_backend = false in_frontend = true i = 77 file = container_classifiedscripts/gamelogic.lua:1115 in (upvalue) DoResetAction (Lua) <1051-1120>scripts/gamelogic.lua:1131 in (local) complete_callback (Lua) <1123-1132>scripts/upsell.lua:27 in (global) UpdateGamePurchasedState (Lua) <11-30> complete_callback = function - scripts/gamelogic.lua:1123scripts/gamelogic.lua:1136 in () ? (Lua) <1134-1137>=[C]:-1 in (method) SetPersistentString (C) <-1--1>...and i think i am doing something very wrongoh wait... my fault Link to comment Share on other sites More sharing options...
Purswader Posted December 15, 2014 Author Share Posted December 15, 2014 @rezecib, works fine. Thank you very much Link to comment Share on other sites More sharing options...
SenL Posted January 18, 2015 Share Posted January 18, 2015 Hi,How did you fix this? mine crashes as client with same issue (I think). Link to comment Share on other sites More sharing options...
Purswader Posted January 18, 2015 Author Share Posted January 18, 2015 @SenL, try to download my zim mod and look in the modmain file, i can't remember but its all there Link to comment Share on other sites More sharing options...
SenL Posted January 20, 2015 Share Posted January 20, 2015 I don't have the code right now but I got it to work just as similar as your code to replace/overload the widgetsetup function.Did have a crash once (as a client) but I just ignore it. Played a few more hours without crash. Thanks for your help! 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