josk Posted April 7, 2013 Share Posted April 7, 2013 Just trying to understand using functions between Scripts. Code is taken from Darkness Awaits but cut down a bit. self:AttackEnemy() is called in the goblin Script. but I get attempt to index local 'Newplayer' (a nil value) In Newplayer Script I have function Script:TakeDamage(damage) if self.Health>0 then self.Health = self.Health - damage end end in Goblin Script I have function Script:AttackEnemy(Newplayer) local entitypos = Newplayer.entity:GetPosition(true) local pos = Transform:Point(entitypos.x,entitypos.y,entitypos.z,nil,self.entity) pos = pos * self.entity:GetScale() pos.z = pos.z * -1 if pos.z>0 and pos.z<self.attackRange then if pos.z>math.abs(pos.x) then Newplayer:TakeDamage(10) end end end Quote Elite Cobra Squad Link to comment Share on other sites More sharing options...
josk Posted April 7, 2013 Author Share Posted April 7, 2013 Sorted, studied the code bit by bit and and read the the explanation of the EnemyAttackForEachEntityInAABBDoCallback(entity,extra) by Chris Vossen in a past thread, another hurdle is overcome. 1 Quote Elite Cobra Squad Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.