Game Development Community

An (syntx-)error, I can't find...

by fetze · in Torque Game Engine · 03/16/2004 (5:59 am) · 4 replies

Sorry, but I have to disturb again ^^

So, I scripted something in the Torque .cs-Scriptfiles:

for (%i = 0; %i < 8; %i++) {
if ((%image = %obj.getMountedImage(%i)) > 0) {
if (isObject(%image.ammo) && %image.ammo.getId() == %this.getId()) {
%obj.setImageAmmo(%i,%amount != 0);
if (%i == %obj.equippedItem) {
%obj.setEnergyLevel(%obj.getInventory(%this.getId()) / %obj.maxInventory(%this.getId()) * 60);
}
}
}
}

So, there has to be some syntax-error, because the for-loop doesn't work. It counts to 0 but not higher. Whats the Matter with it?
Sorry, that I disturb with something like this, but I am a scripting-n00b :(

#1
03/16/2004 (9:52 am)
I'd love to read your code, but I can't. :)

Could you perhaps use the
[code]
tag so that formatting survives? Indentation makes code much easier to read and debug.
#2
03/16/2004 (10:15 am)
Ok, here it is:

for (%i = 0; %i < 8; %i++) {
   if ((%image = %obj.getMountedImage(%i)) > 0) {
      if (isObject(%image.ammo) && %image.ammo.getId() ==      %this.getId()) {
         %obj.setImageAmmo(%i,%amount != 0);
         if (%i == %obj.equippedItem) {
            %obj.setEnergyLevel(%obj.getInventory(%this.getId()) /  %obj.maxInventory(%this.getId()) * 60);
         }
      }
   }
}
#3
03/16/2004 (10:22 am)
for(%i = 0; %i < 8; %i++)
{
   if((%image = %obj.getMountedImage(%i)) > 0)
   {
      if (isObject(%image.ammo) && %image.ammo.getId() == %this.getId()) 
      {
          %obj.setImageAmmo(%i,%amount != 0); // ??? this is wrong
          if (%i == %obj.equippedItem) 
          {
             %obj.setEnergyLevel(%obj.getInventory(%this.getId()) /  %obj.maxInventory(%this.getId()) * 60);         
          }
      }
   }
   else
     echo("image " @ %i @ " Not Found");

}
#4
03/16/2004 (10:48 am)
Oh, thanks, i completely forgot about that :D