• v:Disposition LUA error
    3 replies, posted
Hey guys, I've been trying to fix the old deer NPC that went missing a while back. I have got it almost done, but I'm having issues with the Disposition. Obviously the deer is supposed to run away when players are nearby it, but it seems the lua must be outdated or something. When I spawn the deer, I automatically get the following error. [CODE][ERROR] addons/piratecat's deer snpc/lua/entities/npc_piratecatdeer/init.lua:6: attempt to call method 'Disposition' (a nil value) 1. AnimalBehaviour - addons/piratecat's deer snpc/lua/entities/npc_piratecatdeer/init.lua:6 2. unknown - addons/piratecat's deer snpc/lua/entities/npc_piratecatdeer/init.lua:3 [/CODE] The code in reference is this; [CODE]function ENT:AnimalBehaviour() local nearby = ents.FindInSphere(self:GetPos(),800) if (!nearby) then return end for k,v in pairs(nearby) do if v:Disposition(self) == 1 || (v:IsPlayer() && GetConVarNumber("ai_ignoreplayers") == 0) then self.noticed = true self:AddEntityRelationship(player.GetByID(1), D_FR, 99 ) [/CODE] Could anyone give me a hand? Cheers.
[url]http://wiki.garrysmod.com/page/NPC/Disposition[/url] Disposition hasn't changed. The parameters seem to be mixed up; self should be the precedent and the value should be the secondary argument.
[QUOTE=code_gs;47852116][url]http://wiki.garrysmod.com/page/NPC/Disposition[/url] Disposition hasn't changed. The parameters seem to be mixed up; self should be the precedent and the value should be the secondary argument.[/QUOTE] Could you give me a hand as to what I should put in this instance?
Change the v and self around
Sorry, you need to Log In to post a reply to this thread.