Hard Light Productions Forums

Hosted Projects - Non-FreeSpace => MechCommander OmniTech => Topic started by: Drewbs on August 22, 2018, 01:55:19 pm

Title: ABL scripting error
Post by: Drewbs on August 22, 2018, 01:55:19 pm
I am encountering another syntax error for IsWithinArea. I have:
      if (IsWithinArea(VongL1a, -6976.0, -320.0, 0.0, 50.0) : true) then

The ABL library has:
IsWithinArea(UnitID, position Point, real Radius) : boolean;
      // UnitID(from GetUnitMates(SquadID,Array); , 3-point array or worldposition with xyz, range in meters

What am I doing wrong?
Title: Re: ABL scripting error
Post by: tisi on August 23, 2018, 09:05:47 am
I'm new to this forum and haven't used the ABL scripts yet, but  I have some general programming knowledge and any interpreter woud read your current line as this:

Code: [Select]
IsWithinArea(VongL1a, -6976.0, -320.0, 0.0, 50.0) : true
IsWithinArea(UnitID, position Point, real Radius) : boolean

where the variables are read like this:
Code: [Select]
UnitID = VongL1a
position Point (expects array) = -6976,0
real Radius = -320.0
because of the way the commas are used

you could try something like:

Code: [Select]
IsWithinArea(VongL1a, (-6976.0, -320.0, 0.0), 50.0) : true
either way, the function expects an array (however the syntax for arrays is in this language) between the first and second comma within the parantheses
Title: Re: ABL scripting error
Post by: magic on August 23, 2018, 12:44:04 pm
position type is the user data type (array (3) in abl script.

It has integerl values:
x (x coord),
y,
z (usually 0);

declaration:
Position aPoint;

assign data:
aPoint[0] = 6293;
aPoint[1] = 6464;
aPoint[2] = 0;

Pass the variable to the function:
IsWithinArea(VongL1a, aPoint, 50.0)
Title: Re: ABL scripting error
Post by: Drewbs on August 25, 2018, 01:01:24 am
Thanks guys! Works like a charm now!