Author |
Message |
Mind
Joined: Thu Mar 06, 2008 10:54 pm Posts: 1360 Location: USA
|
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
|
Sat May 16, 2009 9:08 pm |
|
|
TheLastBanana
DRL Developer
Joined: Wed Dec 13, 2006 5:27 am Posts: 3138 Location: A little south and a lot west of Moscow
|
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.
|
Sat May 16, 2009 11:18 pm |
|
|
Mind
Joined: Thu Mar 06, 2008 10:54 pm Posts: 1360 Location: USA
|
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?
|
Sun May 17, 2009 12:42 am |
|
|
mail2345
Joined: Tue Nov 06, 2007 6:58 am Posts: 2054
|
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
|
Sun May 17, 2009 1:08 am |
|
|
Mind
Joined: Thu Mar 06, 2008 10:54 pm Posts: 1360 Location: USA
|
Re: Lua Spawn Problems
console output? what do you mean by that? sorry, new to lua
|
Sun May 17, 2009 1:22 am |
|
|
Duh102
happy carebear mom
Joined: Tue Mar 04, 2008 1:40 am Posts: 7096 Location: b8bbd5
|
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.
|
Sun May 17, 2009 1:24 am |
|
|
robolee
Joined: Fri May 11, 2007 4:30 pm Posts: 1040 Location: England
|
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
|
Sun May 17, 2009 12:55 pm |
|
|
mail2345
Joined: Tue Nov 06, 2007 6:58 am Posts: 2054
|
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.
|
Sun May 17, 2009 6:17 pm |
|
|
TheLastBanana
DRL Developer
Joined: Wed Dec 13, 2006 5:27 am Posts: 3138 Location: A little south and a lot west of Moscow
|
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.
|
Sun May 17, 2009 6:26 pm |
|
|
Mind
Joined: Thu Mar 06, 2008 10:54 pm Posts: 1360 Location: USA
|
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
|
Sun May 17, 2009 8:28 pm |
|
|
Teemperor
Joined: Thu Oct 16, 2008 5:37 pm Posts: 52 Location: GERMANY
|
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
|
Wed May 20, 2009 2:58 pm |
|
|
Mind
Joined: Thu Mar 06, 2008 10:54 pm Posts: 1360 Location: USA
|
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...
|
Wed May 20, 2009 3:03 pm |
|
|
Teemperor
Joined: Thu Oct 16, 2008 5:37 pm Posts: 52 Location: GERMANY
|
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
|
Wed May 20, 2009 3:23 pm |
|
|
Mind
Joined: Thu Mar 06, 2008 10:54 pm Posts: 1360 Location: USA
|
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.
|
Wed May 20, 2009 10:04 pm |
|
|
|