View unanswered posts | View active topics It is currently Thu Dec 26, 2024 6:18 pm



Reply to topic  [ 14 posts ] 
 Lua Spawn Problems 
Author Message
User avatar

Joined: Thu Mar 06, 2008 10:54 pm
Posts: 1360
Location: USA
Reply with quote
Post 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
Profile
DRL Developer
DRL Developer
User avatar

Joined: Wed Dec 13, 2006 5:27 am
Posts: 3138
Location: A little south and a lot west of Moscow
Reply with quote
Post Re: Lua Spawn Problems
You shouldn't have to define the Health, and AIMode is not a valid AIMode :P Set the AIMode to Actor.AIMODE_SENTRY, Actor.AIMODE_PATROL or Actor.AIMODE_BRAINHUNT.


Sat May 16, 2009 11:18 pm
Profile WWW
User avatar

Joined: Thu Mar 06, 2008 10:54 pm
Posts: 1360
Location: USA
Reply with quote
Post 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
Profile
User avatar

Joined: Tue Nov 06, 2007 6:58 am
Posts: 2054
Reply with quote
Post 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
Profile
User avatar

Joined: Thu Mar 06, 2008 10:54 pm
Posts: 1360
Location: USA
Reply with quote
Post Re: Lua Spawn Problems
console output? what do you mean by that? sorry, new to lua


Sun May 17, 2009 1:22 am
Profile
happy carebear mom
User avatar

Joined: Tue Mar 04, 2008 1:40 am
Posts: 7096
Location: b8bbd5
Reply with quote
Post 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
Profile
User avatar

Joined: Fri May 11, 2007 4:30 pm
Posts: 1040
Location: England
Reply with quote
Post 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 :D


Sun May 17, 2009 12:55 pm
Profile
User avatar

Joined: Tue Nov 06, 2007 6:58 am
Posts: 2054
Reply with quote
Post 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
Profile
DRL Developer
DRL Developer
User avatar

Joined: Wed Dec 13, 2006 5:27 am
Posts: 3138
Location: A little south and a lot west of Moscow
Reply with quote
Post 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
Profile WWW
User avatar

Joined: Thu Mar 06, 2008 10:54 pm
Posts: 1360
Location: USA
Reply with quote
Post 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
Profile
User avatar

Joined: Thu Oct 16, 2008 5:37 pm
Posts: 52
Location: GERMANY
Reply with quote
Post 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
Profile
User avatar

Joined: Thu Mar 06, 2008 10:54 pm
Posts: 1360
Location: USA
Reply with quote
Post 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
Profile
User avatar

Joined: Thu Oct 16, 2008 5:37 pm
Posts: 52
Location: GERMANY
Reply with quote
Post 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
Profile
User avatar

Joined: Thu Mar 06, 2008 10:54 pm
Posts: 1360
Location: USA
Reply with quote
Post 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
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 14 posts ] 

Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.119s | 14 Queries | GZIP : Off ]