View unanswered posts | View active topics It is currently Thu Jan 02, 2025 10:40 pm



Reply to topic  [ 17 posts ]  Go to page 1, 2  Next
 Lua help. 
Author Message

Joined: Mon Dec 07, 2009 12:56 am
Posts: 36
Reply with quote
Post Lua help.
Hey guys I need some help. I want to either make one of the brain files load more than one lua, which doesnt seem to work. Or combine the Cash for kills lua, and smartbrain lua. I cant seem to figure out how to do the comments, to merge the files. Here are the two seperate luas I want to combine. Thanks in advance :grin:

Code:
function Update(self)
   for actor in MovableMan.Actors do
      if actor.Team ~= self.Team then
         self.CurrentDC = ActivityMan:GetActivity():GetTeamDeathCount(actor.Team);
         if self.LastDC == nil then
            self.LastDC = ActivityMan:GetActivity():GetTeamDeathCount(actor.Team);
         end
         if actor:IsDead() == true then
            local Money = CreateMOSParticle("Gold");
                Money.Pos = actor.AboveHUDPos + Vector(0,4);
         end
         self.CurrentF = ActivityMan:GetActivity():GetTeamFunds(self.Team);
         ActivityMan:GetActivity():SetTeamFunds(self.CurrentF + (self.CurrentDC - self.LastDC) * (60 + actor.GoldValue / 1.5), self.Team);
         self.LastDC = ActivityMan:GetActivity():GetTeamDeathCount(actor.Team);
      end
   end
end


Code:
function Update(self)
   for actor in MovableMan.Actors do
      if actor.Team == self.Team and actor.ClassName == "AHuman" then
         if actor:IsPlayerControlled() == false and actor.AIMode == 1 then
               actor:GetController():SetState(Controller.BODY_CROUCH, false);
               actor:GetController():SetState(Controller.MOVE_RIGHT, false);
               actor:GetController():SetState(Controller.MOVE_LEFT, false);
         end
      end
   end
end


Sun Oct 24, 2010 5:23 am
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post Re: Lua help.
Take one thing from and update function and stick it into the other update function. Like:
Code:
function Update(self)
(stuff)
end

+
Code:
function Update(self)
(stuff2)
end

=
Code:
function Update(self)
(stuff)
(stuff2)
end

And there's also a Lua Scripting forum for this.


Sun Oct 24, 2010 6:15 am
Profile

Joined: Mon Dec 07, 2009 12:56 am
Posts: 36
Reply with quote
Post Re: Lua help.
Ooops sorry I put in the wrong forum. But I still cant get it to work :oops:


Sun Oct 24, 2010 7:17 am
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post Re: Lua help.
Show me what you got so far.


Sun Oct 24, 2010 5:27 pm
Profile

Joined: Mon Dec 07, 2009 12:56 am
Posts: 36
Reply with quote
Post Re: Lua help.
Hey I appreciate the tips. Here is the code that doesnt work. Keep in mind I barely have ini files figured out, and the lua ones look like a alien language to me :???:

Code:
function Update(self)
(stuff)
end
   for actor in MovableMan.Actors do
      if actor.Team == self.Team and actor.ClassName == "AHuman" then
         if actor:IsPlayerControlled() == false and actor.AIMode == 1 then
               actor:GetController():SetState(Controller.BODY_CROUCH, false);
               actor:GetController():SetState(Controller.MOVE_RIGHT, false);
               actor:GetController():SetState(Controller.MOVE_LEFT, false);
         end
      end
   end
end


function Update(self)
(stuff2)
end
   for actor in MovableMan.Actors do
      if actor.Team ~= self.Team then
         self.CurrentDC = ActivityMan:GetActivity():GetTeamDeathCount(actor.Team);
         if self.LastDC == nil then
            self.LastDC = ActivityMan:GetActivity():GetTeamDeathCount(actor.Team);
         end
         if actor:IsDead() == true then
            local Money = CreateMOSParticle("Gold");
                Money.Pos = actor.AboveHUDPos + Vector(0,4);
         end
         self.CurrentF = ActivityMan:GetActivity():GetTeamFunds(self.Team);
         ActivityMan:GetActivity():SetTeamFunds(self.CurrentF + (self.CurrentDC - self.LastDC) * (60 + actor.GoldValue / 1.5), self.Team);
         self.LastDC = ActivityMan:GetActivity():GetTeamDeathCount(actor.Team);
      end
   end
end


Sun Oct 24, 2010 6:25 pm
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post Re: Lua help.
^That is correct.


Sun Oct 24, 2010 6:53 pm
Profile

Joined: Mon Dec 07, 2009 12:56 am
Posts: 36
Reply with quote
Post Re: Lua help.
I changed it and retabbed everything and it still doesnt work.

Code:
function Update(self)
   for actor in MovableMan.Actors do
      if actor.Team == self.Team and actor.ClassName == "AHuman" then
         if actor:IsPlayerControlled() == false and actor.AIMode == 1 then
               actor:GetController():SetState(Controller.BODY_CROUCH, false);
               actor:GetController():SetState(Controller.MOVE_RIGHT, false);
               actor:GetController():SetState(Controller.MOVE_LEFT, false);
         end
      end
   end
end
   for actor in MovableMan.Actors do
      if actor.Team ~= self.Team then
         self.CurrentDC = ActivityMan:GetActivity():GetTeamDeathCount(actor.Team);
         if self.LastDC == nil then
            self.LastDC = ActivityMan:GetActivity():GetTeamDeathCount(actor.Team);
         end
         if actor:IsDead() == true then
            local Money = CreateMOSParticle("Gold");
            Money.Pos = actor.AboveHUDPos + Vector(0,4);
         end
         self.CurrentF = ActivityMan:GetActivity():GetTeamFunds(self.Team);
         ActivityMan:GetActivity():SetTeamFunds(self.CurrentF + (self.CurrentDC - self.LastDC) * (60 + actor.GoldValue / 1.5), self.Team);
         self.LastDC = ActivityMan:GetActivity():GetTeamDeathCount(actor.Team);
      end
   end
end


Sun Oct 24, 2010 6:58 pm
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post Re: Lua help.
Tabbing has no effect. Do you have any Lua console errors?


Sun Oct 24, 2010 7:02 pm
Profile
User avatar

Joined: Tue Dec 12, 2006 3:10 pm
Posts: 495
Location: Uncertain quantum state
Reply with quote
Post Re: Lua help.
You are beynond help.

Code:
function Update(self)
   for actor in MovableMan.Actors do
      if actor.Team == self.Team and actor.ClassName == "AHuman" then
         if actor:IsPlayerControlled() == false and actor.AIMode == 1 then
               actor:GetController():SetState(Controller.BODY_CROUCH, false);
               actor:GetController():SetState(Controller.MOVE_RIGHT, false);
               actor:GetController():SetState(Controller.MOVE_LEFT, false);
         end
      elseif  actor.Team ~= self.Team then
         self.CurrentDC = ActivityMan:GetActivity():GetTeamDeathCount(actor.Team);
         if self.LastDC == nil then
            self.LastDC = ActivityMan:GetActivity():GetTeamDeathCount(actor.Team);
         end
         if actor:IsDead() == true then
            local Money = CreateMOSParticle("Gold");
            Money.Pos = actor.AboveHUDPos + Vector(0,4);
         end
         self.CurrentF = ActivityMan:GetActivity():GetTeamFunds(self.Team);
         ActivityMan:GetActivity():SetTeamFunds(self.CurrentF + (self.CurrentDC - self.LastDC) * (60 + actor.GoldValue / 1.5), self.Team);
         self.LastDC = ActivityMan:GetActivity():GetTeamDeathCount(actor.Team);
      end
   end
end


Sun Oct 24, 2010 7:03 pm
Profile

Joined: Mon Dec 07, 2009 12:56 am
Posts: 36
Reply with quote
Post Re: Lua help.
Lua console, how do I use that? When I run the game it acts like the lua doesnt exist.


Sun Oct 24, 2010 7:04 pm
Profile

Joined: Mon Dec 07, 2009 12:56 am
Posts: 36
Reply with quote
Post Re: Lua help.
Quote:
You are beynond help.
Ouch man. but when I use your code I start the game with like 100 billion dollars :0


Sun Oct 24, 2010 7:07 pm
Profile
User avatar

Joined: Tue Dec 12, 2006 3:10 pm
Posts: 495
Location: Uncertain quantum state
Reply with quote
Post Re: Lua help.
Code:
function Update(self)
   for actor in MovableMan.Actors do
      if actor.Team == self.Team then
      if   actor.ClassName == "AHuman" then
         if actor:IsPlayerControlled() == false and actor.AIMode == 1 then
               actor:GetController():SetState(Controller.BODY_CROUCH, false);
               actor:GetController():SetState(Controller.MOVE_RIGHT, false);
               actor:GetController():SetState(Controller.MOVE_LEFT, false);
         end
      end
      elseif  actor.Team ~= self.Team then
         self.CurrentDC = ActivityMan:GetActivity():GetTeamDeathCount(actor.Team);
         if self.LastDC == nil then
            self.LastDC = ActivityMan:GetActivity():GetTeamDeathCount(actor.Team);
         end
         if actor:IsDead() == true then
            local Money = CreateMOSParticle("Gold");
            Money.Pos = actor.AboveHUDPos + Vector(0,4);
         end
         self.CurrentF = ActivityMan:GetActivity():GetTeamFunds(self.Team);
         ActivityMan:GetActivity():SetTeamFunds(self.CurrentF + (self.CurrentDC - self.LastDC) * (60 + actor.GoldValue / 1.5), self.Team);
         self.LastDC = ActivityMan:GetActivity():GetTeamDeathCount(actor.Team);
      end
   end
end


Sun Oct 24, 2010 7:15 pm
Profile

Joined: Mon Dec 07, 2009 12:56 am
Posts: 36
Reply with quote
Post Re: Lua help.
Code:
function Update(self)
   for actor in MovableMan.Actors do
      if actor.Team == self.Team then
      if   actor.ClassName == "AHuman" then
         if actor:IsPlayerControlled() == false and actor.AIMode == 1 then
               actor:GetController():SetState(Controller.BODY_CROUCH, false);
               actor:GetController():SetState(Controller.MOVE_RIGHT, false);
               actor:GetController():SetState(Controller.MOVE_LEFT, false);
         end
      end
      elseif  actor.Team ~= self.Team then
         self.CurrentDC = ActivityMan:GetActivity():GetTeamDeathCount(actor.Team);
         if self.LastDC == nil then
            self.LastDC = ActivityMan:GetActivity():GetTeamDeathCount(actor.Team);
         end
         if actor:IsDead() == true then
            local Money = CreateMOSParticle("Gold");
            Money.Pos = actor.AboveHUDPos + Vector(0,4);
         end
         self.CurrentF = ActivityMan:GetActivity():GetTeamFunds(self.Team);
         ActivityMan:GetActivity():SetTeamFunds(self.CurrentF + (self.CurrentDC - self.LastDC) * (60 + actor.GoldValue / 1.5), self.Team);
         self.LastDC = ActivityMan:GetActivity():GetTeamDeathCount(actor.Team);
      end
   end
end


When I use that the code it works, in skirmish and all the campaign missions except tutorial. When I play that one I start with a ton of money and when I go to buy something the game locks, with no error message and has to be killed via task manager :???:


Sun Oct 24, 2010 7:27 pm
Profile

Joined: Mon Dec 07, 2009 12:56 am
Posts: 36
Reply with quote
Post Re: Lua help.
Also no errors show in the console. And there are some other missions that have the same problem :cry:


Sun Oct 24, 2010 7:40 pm
Profile

Joined: Mon Dec 07, 2009 12:56 am
Posts: 36
Reply with quote
Post Re: Lua help.
This is so hopelessly above my skill level Ill never figure it out. Guess I'll ony have anti retardness and cash for kills in skirmish only :-(


Sun Oct 24, 2010 7:46 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 17 posts ]  Go to page 1, 2  Next

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.060s | 13 Queries | GZIP : Off ]