Data Realms Fan Forums
http://45.55.195.193/

Lua help.
http://45.55.195.193/viewtopic.php?f=1&t=20018
Page 1 of 2

Author:  MesoTroniK [ Sun Oct 24, 2010 5:23 am ]
Post subject:  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

Author:  CaveCricket48 [ Sun Oct 24, 2010 6:15 am ]
Post subject:  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.

Author:  MesoTroniK [ Sun Oct 24, 2010 7:17 am ]
Post subject:  Re: Lua help.

Ooops sorry I put in the wrong forum. But I still cant get it to work :oops:

Author:  CaveCricket48 [ Sun Oct 24, 2010 5:27 pm ]
Post subject:  Re: Lua help.

Show me what you got so far.

Author:  MesoTroniK [ Sun Oct 24, 2010 6:25 pm ]
Post subject:  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

Author:  CaveCricket48 [ Sun Oct 24, 2010 6:53 pm ]
Post subject:  Re: Lua help.

^That is correct.

Author:  MesoTroniK [ Sun Oct 24, 2010 6:58 pm ]
Post subject:  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

Author:  CaveCricket48 [ Sun Oct 24, 2010 7:02 pm ]
Post subject:  Re: Lua help.

Tabbing has no effect. Do you have any Lua console errors?

Author:  findude [ Sun Oct 24, 2010 7:03 pm ]
Post subject:  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

Author:  MesoTroniK [ Sun Oct 24, 2010 7:04 pm ]
Post subject:  Re: Lua help.

Lua console, how do I use that? When I run the game it acts like the lua doesnt exist.

Author:  MesoTroniK [ Sun Oct 24, 2010 7:07 pm ]
Post subject:  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

Author:  findude [ Sun Oct 24, 2010 7:15 pm ]
Post subject:  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

Author:  MesoTroniK [ Sun Oct 24, 2010 7:27 pm ]
Post subject:  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 :???:

Author:  MesoTroniK [ Sun Oct 24, 2010 7:40 pm ]
Post subject:  Re: Lua help.

Also no errors show in the console. And there are some other missions that have the same problem :cry:

Author:  MesoTroniK [ Sun Oct 24, 2010 7:46 pm ]
Post subject:  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 :-(

Page 1 of 2 All times are UTC [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/