View unanswered posts | View active topics It is currently Fri Dec 27, 2024 11:17 pm



Reply to topic  [ 3 posts ] 
 Unkown Lua Error *Fixed 
Author Message
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post Unkown Lua Error *Fixed
Code:
ERROR: HeadCrab.rte/Control.lua:3: 'then' expected near '='

I'm not completely sure what this means, and my attampts at fixing aren't successful. My script is below.

Code:
function Update(self)
   self.targetcontrol = false;
   if self.target:GetController():IsState(Controller.WEAPON_FIRE) and self.targetcontrol = false then
   local curdist = 50;
   for actor in MovableMan.Actors do
      local dist = SceneMan:ShortestDistance(self.Pos,actor.Pos,true);
      if dist.Magnitude < curdist and actor.ID ~= self.ID then
         self.target = actor;
      self.targetcontrol = true;
      end
   end
end

   if self.target:IsDead() then
   self.GetsHitByMOs = 1;
   self.HitsMOs = 1;
   self.targetcontrol = false;
   end

   if self.targetcontrol = true then
   self.GetsHitByMOs = 0;
   self.HitsMOs = 0;
   self.Pos = self.target.Pos;
   end

   if self.target:GetController():IsState(Controller.HOLD_LEFT) and self.targetcontrol = true then
   self.target:GetController():IsState(Controller.HOLD_LEFT)
   end

   if self.target:GetController():IsState(Controller.HOLD_RIGHT) and self.targetcontrol = true then
   self.target:GetController():IsState(Controller.HOLD_RIGHT)
   end
end


This script is supposed to take control of the left and right movement of the closest actor within 50 pixels when fire is pressed. And this is attached to an actor.


Last edited by CaveCricket48 on Tue Aug 25, 2009 3:52 pm, edited 1 time in total.



Tue Aug 25, 2009 3:11 pm
Profile
happy carebear mom
User avatar

Joined: Tue Mar 04, 2008 1:40 am
Posts: 7096
Location: b8bbd5
Reply with quote
Post Re: Unkown Lua Error
You put "self.targetcontrol = false" in an if/then/else statement. You want "self.targetcontrol == false"
= is setting
== is equality comparison.

EDIT: This applies to all of them that you have "if something = something". They should always be "if something == something" if you're doing a comparison.


Tue Aug 25, 2009 3:26 pm
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post Re: Unkown Lua Error
Thanks, that worked.


Tue Aug 25, 2009 3:52 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 3 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:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.028s | 15 Queries | GZIP : Off ]