Data Realms Fan Forums http://45.55.195.193/ |
|
Lua Spawn Problems http://45.55.195.193/viewtopic.php?f=73&t=14689 |
Page 1 of 1 |
Author: | Mind [ Sat May 16, 2009 9:08 pm ] |
Post subject: | Lua Spawn Problems |
Ok, so having a problem. Im trying to make it so a new zombie actor is spawned once an actor on one team dies, and this is what i have why could this not be working? Code: if actor.Team == self.Team and actor:IsDead() == true then local position = actor.Pos; local team = actor.Team; local AImode = actor.AIMode; actor.Lifetime = 2; rebornActor = CreateAHuman(self.AList[math.random(#self.AList)],"Undead.rte"); rebornActor.Pos = position; rebornActor.Team = team; rebornActor.AIMode = AImode; rebornActor.Health = 100; MovableMan:AddActor(rebornActor); end thanks to anyone who helps |
Author: | TheLastBanana [ Sat May 16, 2009 11:18 pm ] |
Post subject: | Re: Lua Spawn Problems |
You shouldn't have to define the Health, and AIMode is not a valid AIMode Set the AIMode to Actor.AIMODE_SENTRY, Actor.AIMODE_PATROL or Actor.AIMODE_BRAINHUNT. |
Author: | Mind [ Sun May 17, 2009 12:42 am ] |
Post subject: | Re: Lua Spawn Problems |
Code: if actor.Team == self.Team and actor:IsDead() == true then local position = actor.Pos; local team = actor.Team; local AImode = actor.AIMode_SENTRY; actor.Lifetime = 2; rebornActor = CreateAHuman(self.AList[math.random(#self.AList)],"Undead.rte"); rebornActor.Pos = position; rebornActor.Team = team; rebornActor.AIMode = AImode; MovableMan:AddActor(rebornActor); end have this, but it still doesnt work. Any help? |
Author: | mail2345 [ Sun May 17, 2009 1:08 am ] |
Post subject: | Re: Lua Spawn Problems |
What's running the code? It also might be helpful to know the contents of self.AList, and more of the code's context. And how exactly it broke(crash, not working, ect). Anyway, use this(has debugging print statements) and post the console output. Code: if actor.Team == self.Team and actor:IsDead() == true then local position = actor.Pos; print("Reviving...") local team = actor.Team; local AImode = actor.AIMode_SENTRY; actor.Lifetime = 2; print(position) rebornActor = CreateAHuman(self.AList[math.random(#self.AList)],"Undead.rte"); rebornActor.Pos = position; rebornActor.Team = team; rebornActor.AIMode = AImode; MovableMan:AddActor(rebornActor); end |
Author: | Mind [ Sun May 17, 2009 1:22 am ] |
Post subject: | Re: Lua Spawn Problems |
console output? what do you mean by that? sorry, new to lua |
Author: | Duh102 [ Sun May 17, 2009 1:24 am ] |
Post subject: | Re: Lua Spawn Problems |
Console output is simply what the engine prints to the console. That is, when you run the lua code (by killing the actor or whatever) and then open the console, it will have printed something to it. Or, if you can do it, have the thing happen while the console is open. |
Author: | robolee [ Sun May 17, 2009 12:55 pm ] |
Post subject: | Re: Lua Spawn Problems |
if actor.Team == self.Team and actor:IsDead() == true then local position = actor.Pos; local team = actor.Team; local AImode = actor.AIMode_SENTRY; actor.Lifetime = 2; rebornActor = CreateAHuman(self.AList[math.random(#self.AList)],"Undead.rte"); rebornActor.Pos = position; rebornActor.Team = team; rebornActor.AIMode = AImode; MovableMan:AddActor(rebornActor); end lol, you dummy, you only changed one AI mode declaration |
Author: | mail2345 [ Sun May 17, 2009 6:17 pm ] |
Post subject: | Re: Lua Spawn Problems |
If the AIMode was the problem, the unit would come out broked. But it seems that the unit refuses to spawn at all. |
Author: | TheLastBanana [ Sun May 17, 2009 6:26 pm ] |
Post subject: | Re: Lua Spawn Problems |
The reason is that because AIMode is not a valid setting, the function errors out before the actor can be added to the scene. |
Author: | Mind [ Sun May 17, 2009 8:28 pm ] |
Post subject: | Re: Lua Spawn Problems |
Ok, zombie problem is fixed, but when they appear, two appear, and i cant find out how to only make one appear. TheLastBanana said to make a variable "x" and make it false, then when the actor dies, check if it is false, and if it is false, spawn the zombie and set it to be true so that another zombie doesnt spawn. (correct me if im wrong TLB ) How would i do this with this code? Code: if healTimer:IsPastSimMS(healInterval) then for actor in MovableMan.Actors do if actor.Team == self.Team and actor.Health < 1 and actor.ID ~= self.ID then local position = actor.Pos; local team = actor.Team; local AImode = actor.AIMode actor.Lifetime = 2; rebornActor = CreateAHuman(self.AList[math.random(#self.AList)]); rebornActor.Pos = position; rebornActor.Team = team; rebornActor.AIMode = AImode; MovableMan:AddActor(rebornActor); end end end Thanks |
Author: | Teemperor [ Wed May 20, 2009 2:58 pm ] |
Post subject: | Re: Lua Spawn Problems |
need help with my code (it´s nearly the same like above so this thread) Code: if self.Health > 400 then self.health = 0 local position = self.Pos; local team = self.Team; local AImode = self.AIMode; reborndrone = CreateAHuman("AMedic Drone"); reborndrone.Pos = position; reborndrone.Team = team; reborndrone.AIMode = AImode; MovableMan:AddActor(reborndrone); end the problem is that nothing happens if the drone has more than 400 life (don´t say: uhh, max 100 health pls) need help |
Author: | Mind [ Wed May 20, 2009 3:03 pm ] |
Post subject: | Re: Lua Spawn Problems |
Um.... Teemperor wrote: need help with my code (it´s nearly the same like above so this thread) [code] if self.Health > 400 then make 400 whatever you want to.... I think thats what youre asking... |
Author: | Teemperor [ Wed May 20, 2009 3:23 pm ] |
Post subject: | Re: Lua Spawn Problems |
The Mind wrote: make 400 whatever you want to.... I think thats what youre asking... No, i want that when the actor has more than 400 life he suddenly die and the same Actor with 100 Health and without wounds stand there |
Author: | Mind [ Wed May 20, 2009 10:04 pm ] |
Post subject: | Re: Lua Spawn Problems |
Teemperor wrote: need help with my code (it´s nearly the same like above so this thread) Code: for actor in MovableMan.Actors do ----- if self.Health > 400 then ----- self.health = 0 ----- local position = self.Pos; ----- local team = self.Team; ----- local AImode = self.AIMode; ----- reborndrone = CreateAHuman("AMedic Drone"); ----- reborndrone.Pos = position; -----reborndrone.Team = team; -----reborndrone.AIMode = AImode; ----- MovableMan:AddActor(reborndrone); ----- end end Try this. May work, may not. |
Page 1 of 1 | All times are UTC [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |