Zeroless Posted January 5, 2019 Share Posted January 5, 2019 (edited) I try to add a new Maxwell minion type that works like Chester so I call it Shadow bearer, It works correctly if I play alone but if I play with friends the game will crash and freeze when someone on server try to create Shadow bearer. I also attached pictures with error log of my friend as client below. This is a code that makes a minion local function MakeMinion(prefab, tool, hat, master_postinit) local assets = { Asset("ANIM", "anim/waxwell_shadow_mod.zip"), Asset("SOUND", "sound/maxwell.fsb"), Asset("ANIM", "anim/"..tool..".zip"), } local function fn() local inst = CreateEntity() inst.entity:AddTransform() inst.entity:AddAnimState() inst.entity:AddSoundEmitter() inst.entity:AddNetwork() inst.entity:AddDynamicShadow() --Bugfix for hat that alters shadow (eyebrella) inst.DynamicShadow:Enable(false) MakeGhostPhysics(inst, 1, 0.5) inst.Transform:SetFourFaced(inst) inst.AnimState:SetBank("wilson") inst.AnimState:SetBuild("waxwell_shadow_mod") inst.AnimState:PlayAnimation("idle") inst.AnimState:SetMultColour(0, 0, 0, .5) if tool ~= nil then inst.AnimState:OverrideSymbol("swap_object", tool, tool) inst.AnimState:Hide("ARM_normal") else inst.AnimState:Hide("ARM_carry") end if hat ~= nil then inst.AnimState:OverrideSymbol("swap_hat", hat, "swap_hat") inst.AnimState:Hide("HAIR_NOHAT") inst.AnimState:Hide("HAIR") else inst.AnimState:Hide("HAT") inst.AnimState:Hide("HAT_HAIR") end if tool == "swap_cane" then inst:AddTag("isCourier") inst:AddComponent("container") inst.components.container:WidgetSetup("treasurechest") end inst:AddTag("scarytoprey") inst:AddTag("shadowminion") inst:SetPrefabNameOverride("shadowwaxwell") inst.entity:SetPristine() if not TheWorld.ismastersim then return inst end inst:AddComponent("locomotor") inst.components.locomotor.runspeed = TUNING.SHADOWWAXWELL_SPEED inst.components.locomotor.pathcaps = { ignorecreep = true } inst.components.locomotor:SetSlowMultiplier(.6) inst:AddComponent("health") inst.components.health:SetMaxHealth(TUNING.SHADOWWAXWELL_LIFE) inst.components.health:StartRegen(TUNING.SHADOWWAXWELL_HEALTH_REGEN / 2, TUNING.SHADOWWAXWELL_HEALTH_REGEN_PERIOD) inst.components.health.nofadeout = true inst.components.health.redirect = nodebrisdmg inst:AddComponent("combat") inst.components.combat.hiteffectsymbol = "torso" inst.components.combat:SetRange(2) inst:AddComponent("follower") inst.components.follower:KeepLeaderOnAttacked() inst.components.follower.keepdeadleader = true inst:AddComponent("inventory") inst.components.inventory:DisableDropOnDeath() inst:AddComponent("trader") inst.components.trader:SetAcceptTest(ShouldAcceptItem) inst.components.trader.onaccept = OnGetItemFromPlayer --inst.components.trader.onrefuse = OnRefuseItem inst.components.trader.deleteitemonaccept = false inst:SetBrain(brain) inst:SetStateGraph("SGshadowwaxwell") inst:ListenForEvent("attacked", OnAttacked) if master_postinit ~= nil then master_postinit(inst) end return inst end return Prefab(prefab, fn, assets, prefabs) end Basically, this original mod made by Farxodor, I use his make minion code and only add this to his code if tool == "swap_cane" then inst:AddTag("isCourier") inst:AddComponent("container") inst.components.container:WidgetSetup("treasurechest") end Does anyone know how I can fix this error? All help is greatly appreciated. Thank you. Edited January 5, 2019 by Zeroless Link to comment https://forums.kleientertainment.com/forums/topic/101470-solved-crash-attempt-to-index-field-container-a-nil-value/ Share on other sites More sharing options...
Ultroman Posted January 6, 2019 Share Posted January 6, 2019 (edited) Since the problem happens on clients, it's probably about the components which are/aren't added to the entity on the clients. As you can see in the Chester prefab, the container is not added if TheWorld.ismastersim is false, so I think you need to move your if-statement which adds the container-component below your TheWorld.ismastersim check. Edited January 6, 2019 by Ultroman Link to comment https://forums.kleientertainment.com/forums/topic/101470-solved-crash-attempt-to-index-field-container-a-nil-value/#findComment-1140198 Share on other sites More sharing options...
Zeroless Posted January 6, 2019 Author Share Posted January 6, 2019 3 hours ago, Ultroman said: Since the problem happens on clients, it's probably about the components which are/aren't added to the entity on the clients. As you can see in the Chester prefab, the container is not added if TheWorld.ismastersim is false, so I think you need to move your if-statement which adds the container-component below your TheWorld.ismastersim check. Thank you for your help, I have edited as you said, now everyone can make shadow bearer but clients will crash if try to open shadow bearer no matter who created it. below is error log when clients try to open shadow bearer. Link to comment https://forums.kleientertainment.com/forums/topic/101470-solved-crash-attempt-to-index-field-container-a-nil-value/#findComment-1140239 Share on other sites More sharing options...
Ultroman Posted January 6, 2019 Share Posted January 6, 2019 I could be wrong, but is Chester not normally inaccessible to anyone who isn't the "owner" of the Eyebone? I don't think others are supposed to interact with eachother's living containers, using the usual code. Look at how a chest is implemented, to see how they've solved the networking/widget issue. 1 Link to comment https://forums.kleientertainment.com/forums/topic/101470-solved-crash-attempt-to-index-field-container-a-nil-value/#findComment-1140253 Share on other sites More sharing options...
Zeroless Posted January 6, 2019 Author Share Posted January 6, 2019 15 minutes ago, Ultroman said: I could be wrong, but is Chester not normally inaccessible to anyone who isn't the "owner" of the Eyebone? I don't think others are supposed to interact with eachother's living containers, using the usual code. Look at how a chest is implemented, to see how they've solved the networking/widget issue. but a client also got crash too, even though he is the owner Link to comment https://forums.kleientertainment.com/forums/topic/101470-solved-crash-attempt-to-index-field-container-a-nil-value/#findComment-1140263 Share on other sites More sharing options...
Zeroless Posted January 6, 2019 Author Share Posted January 6, 2019 I suppose I know why it crashed, I think I create a container in wrong way, did you have some guide that teaches about how to create container? already search it in this community but doesn't find it. Link to comment https://forums.kleientertainment.com/forums/topic/101470-solved-crash-attempt-to-index-field-container-a-nil-value/#findComment-1140273 Share on other sites More sharing options...
Ultroman Posted January 6, 2019 Share Posted January 6, 2019 (edited) Not really. Look at the chest prefab, or one of the many chest mods out there. There's also a bunch of mods which add more Chesters, and even one that makes it possible for everyone to have their own Chester from the start of the game. Edited January 6, 2019 by Ultroman Link to comment https://forums.kleientertainment.com/forums/topic/101470-solved-crash-attempt-to-index-field-container-a-nil-value/#findComment-1140357 Share on other sites More sharing options...
Zeroless Posted January 7, 2019 Author Share Posted January 7, 2019 Thank you @Ultroman for your help, you are so kind. this problem is already solved. Link to comment https://forums.kleientertainment.com/forums/topic/101470-solved-crash-attempt-to-index-field-container-a-nil-value/#findComment-1140597 Share on other sites More sharing options...
jcosmick Posted May 4, 2023 Share Posted May 4, 2023 On 1/7/2019 at 5:49 PM, Zeroless said: Thank you @Ultroman for your help, you are so kind. this problem is already solved. How did you resolved it? Link to comment https://forums.kleientertainment.com/forums/topic/101470-solved-crash-attempt-to-index-field-container-a-nil-value/#findComment-1633565 Share on other sites More sharing options...
GodIess Posted May 5, 2023 Share Posted May 5, 2023 19 hours ago, jcosmick said: How did you resolved it? I had a similar problem, I solved it this way if not TheWorld.ismastersim then inst.OnEntityReplicated = function(inst) inst.replica.container:WidgetSetup("shoevel_container") end return inst end 1 Link to comment https://forums.kleientertainment.com/forums/topic/101470-solved-crash-attempt-to-index-field-container-a-nil-value/#findComment-1633703 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