DSTMCreator Posted April 22, 2020 Share Posted April 22, 2020 (edited) (Sorry for my bad english) Hello everyone. I need help. I have my own mod. It adds new character based on wendy and another one based on abigail. when I try to summon ghost I get this error message: string "scripts/brains/abigailbrain.lua":45: attempt to index field "trader" (a nil value) It says trader is a nil value. Here is code from abigailbrain.lua (45th string): local function GetTraderFn(inst) local leader = inst.components.follower ~= nil and inst.components.follower.leader if leader ~= nil then return inst.components.trader:IsTryingToTradeWithMe(leader) and leader or nil -- HERE inst.components.trader is nil end end And code from abigail.lua: -- ... -- 375th string local function fn() inst = CreateEntity() inst.entity:AddTransform() inst.entity:AddAnimState() inst.entity:AddSoundEmitter() inst.entity:AddLight() inst.entity:AddNetwork() inst.AnimState:SetBank("ghost") inst.AnimState:SetBuild("ghost_abigail_build") inst.AnimState:PlayAnimation("idle", true) inst.AnimState:SetBloomEffectHandle("shaders/anim_bloom_ghost.ksh") inst:AddTag("character") inst:AddTag("scarytoprey") inst:AddTag("girl") inst:AddTag("ghost") inst:AddTag("noauradamage") inst:AddTag("notraptrigger") inst:AddTag("abigail") inst:AddTag("NOBLOCK") inst:AddTag("trader") inst:AddTag("ghostlyelixirable") -- ... -- 359th string inst:AddComponent("trader") inst.components.trader:SetAbleToAcceptTest(AbleToAcceptTest) It happened only after last update (wendy update). Before this update everything worked fine. what am I doing wrong? why trader is nil? Edited April 22, 2020 by DSTMCreator Link to comment https://forums.kleientertainment.com/forums/topic/117526-attempt-to-index-field-trader-a-nil-value-abigailbrainlua/ Share on other sites More sharing options...
CarlZalph Posted April 22, 2020 Share Posted April 22, 2020 Trader is nil because the brain is expecting to have in the entity's prefab: inst:AddComponent("trader") This happened in Wendy update since the flower rework lets you give the flower and elixirs to Abigail directly.. 1 Link to comment https://forums.kleientertainment.com/forums/topic/117526-attempt-to-index-field-trader-a-nil-value-abigailbrainlua/#findComment-1326908 Share on other sites More sharing options...
DSTMCreator Posted April 22, 2020 Author Share Posted April 22, 2020 54 minutes ago, CarlZalph said: Trader is nil because the brain is expecting to have in the entity's prefab: inst:AddComponent("trader") This happened in Wendy update since the flower rework lets you give the flower and elixirs to Abigail directly.. thank you but... error message confused me. as a result, the error file was not even mentioned in the error message! but anyway I fixed error. and got another... ../mods/newdust/modmain.lua:117 attempt to index field "inst" (a nil value) LUA ERROR stack traceback: ../mods/newdust/modmain.lua:117 in (method) Visit (Lua) <114-120> And code from modmain: AddBrainPostInit("abigailbrain", function(self) local _atfn = self.inst.components.aura.auratestfn self.inst.components.aura.auratestfn = function(inst, target) if inst.cowardmode then return false end return _atfn(inst, target) end local _caav = self.bt.root.children[1].Visit self.bt.root.children[1].Visit = function(self) _caav(self) if self.status == GLOBAL.RUNNING then local leader = self.inst.components.follower.leader if leader and not self.inst:IsNear(leader, 15) then self.inst.cowardmode = true self.status = GLOBAL.FAILED self.inst.components.combat:GiveUp() self.inst.components.locomotor:Stop() return else self.inst.cowardmode = nil end end end local _offn = self.bt.root.children[2].Visit self.bt.root.children[2].Visit = function(self) _offn(self) if self.status == GLOBAL.SUCCESS then self.inst.cowardmode = nil -- <--- HERE return end end end) inst is nil... Link to comment https://forums.kleientertainment.com/forums/topic/117526-attempt-to-index-field-trader-a-nil-value-abigailbrainlua/#findComment-1326924 Share on other sites More sharing options...
CarlZalph Posted April 22, 2020 Share Posted April 22, 2020 You're redefining what 'self' is by function scope. Link to comment https://forums.kleientertainment.com/forums/topic/117526-attempt-to-index-field-trader-a-nil-value-abigailbrainlua/#findComment-1327016 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