ASL Bugs and Feature requests as of Build 1379
Nested If statements cannot return to caller, an8 hangs, turns white, titlebar states (Not Responding) and console stops output.
// Return True if Vertex Exists, Save NewID Mapping to $gVtxIDMap
int $VertexExists(point3 $xyz, string $uv, point3 $rgb, int $a)
{
int $i, $r;
for ($i = 0; $i < $gXYZs.size; $i++)
{
$DebugPrint(PrintToString("Compare to %d", $i));
// cant do && "Illegal Type arg"
if (($xyz.x == $gXYZs[$i].x) && ($xyz.y == $gXYZs[$i].y) && ($xyz.z == $gXYZs[$i].z))
{
if ($uv == $gSTs[$i])
{
if (($rgb.x == $gRGBs[$i].x) && ($rgb.y == $gRGBs[$i].y) && ($rgb.z == $gRGBs[$i].z))
{
if ($a == $gAs[$i])
{
$gVtxIDMap[$gVtxIDMap.size - 1] = $i;
//return true;
$r = 1; //BUG cannot return from here, this makes script wasteful
}
}
}
}
}
return $r;
}
Attributes cannot return NULL...
workaround: Use a global Attribute and use Push/Size = 0
//return $gCurObject.GetAttribute($i);
$gLookupAttributeUcase.push($gCurObject.GetAttribute($i));
return;
}
}
//return NULL;
$gLookupAttributeUcase.size = 0;
}
As Documented already Recursion is not supported, however it would be good to support for parsing trees.
void $ParseChildren(shape $Shape)
{
...
$DebugPrint("Parsing Children " + $Shape.name);
if ($Shape.GetKind() == SHAPE_KIND_GROUP)
{
//Recursion Not Supported
$ConsolePrint("Groups are not supported\n");
//$ParseChildren($Shape);
}
...
}
I also put together some functions for people to use but hope for native support for them instead.
// Returns Index to start of $Contains if within $Base.
// Returns False if $Base does not contain $Contains
int $StringContains(string $Base, string $Contains)
{
int $i, $r;
string $Comparitor;
//$DebugPrint(PrintToString("looking for %s in %s", $Contains, $Base));
for ($i = 0; $i < max(0,($Base.length - $Contains.length)); $i++)
{
$Comparitor = $Base.SubString($i, ($i + ($Contains.length-1)));
$DebugPrint(PrintToString("contains %s at %d", $Comparitor, $i));
if ($Comparitor == $Contains)
{
$r = $i +1;
break;
}
}
//$DebugPrint(PrintToString("returning %d", $r));
return $r;
}
// Split String $Base anywhere $Split occurs
// Returns Array (via $gSplit) of Strings
int $StringSplit(string $Base, string $Split)
{
int $r, $Start, $End;
$gSplit.size = 0;
while (1)//$StringContains($Base.SubString($Start, $Base.length), $Split))
{
$End = $StringContains($Base.SubString($Start, $Base.length), $Split);
if (!$End)
{
//$r = 0;
$DebugPrint($Base.SubString($Start, $Base.length));
$gSplit.push($Base.SubString($Start, $Base.length));
break;
}
$r++;
$DebugPrint($Base.SubString($Start, $End - 1 - $Split.length));
$gSplit.push($Base.SubString($Start, $End - 1 - $Split.length));
$Start = $Start + ($End-1) + ($Split.length);
}
$DebugPrint(PrintToString("Split legnth %d, contains %s", $gSplit.size, $gSplit[$gSplit.size-1]));
return $r;
}
// Returns String from Array (via $gSplit) of Strings
string $StringJoin()
{
int $i;
string $t;
for($i=0; $i< $gSplit.size; $i++)
{
$t = $t + $gSplit[$i];
}
$gSplit.size = 0;
return $t;
}
// Returns String as UPPER CASE
string $StringToUpper(string $str)
{
int $i, $t;
for ($i = 0; $i < $str.length; $i++)
{
$t = $str.GetChar($i);
if (($t >= 97) && ($t <= 122))
{
$t = $t - 32;
$str = $str.SetChar($t, $i);
}
}
return $str;
}
// Looks up Attribute by Name (Case-insensitive)
void $LookupAttribute(string $str, int $CaseCompare)
{
int $i, $r;
attribute $temp;
if (!$CaseCompare)
{
$str = $StringToUpper($str);
}
$DebugPrint("Looking up Attribute " + $str);
for ($i = 0; $i < $gCurObject.GetNumAttributes(); $i++)
{
$temp = $gCurObject.GetAttribute($i);
if (($StringToUpper($temp.GetName()) == $str) && (!$CaseCompare || ($temp.GetName() == $str)))
{
//return $gCurObject.GetAttribute($i);
$DebugPrint("Found Attribute " + $str);
$gLookupAttribute.push($temp);
$r = true;
break;
}
}
if ($r) return;
//return NULL;
$gLookupAttribute.size = 0;
}
// Convert quaternion to xyz (PYR)
point3 $QuaternionToPYR(quaternion $q) {
point3 $angles;
float $sin_cos, $cos_cos;
// pitch (x-axis rotation)
$sin_cos = 2 * ($q.w * $q.x + $q.y * $q.z);
$cos_cos = 1 - 2 * ($q.x * $q.x + $q.y * $q.y);
$angles.x = atan2($sin_cos, $cos_cos);
// yaw (y-axis rotation)
$sin_cos = 2 * ($q.w * $q.y - $q.z * $q.x);
if (abs($sin_cos) >= 1)
{
$angles.y = clamp($sin_cos, -PI / 2, PI / 2); // use 90 degrees if out of range
}
else
{
$angles.y = asin($sin_cos);
}
// role (z-axis rotation)
$sin_cos = 2 * ($q.w * $q.z + $q.x * $q.y);
$cos_cos = 1 - 2 * ($q.y * $q.y + $q.z * $q.z);
$angles.z = atan2($sin_cos, $cos_cos);
return $angles;
}
// Returns the integral value that is nearest to val, with halfway cases rounded away from zero.
int $round(float $val)
{
if ($val >= 0)
{
if (fract($val) >= 0.5)
{
return ceil($val);
}
else
{
return floor($val);
}
}
if (fract($val) > -0.5)
{
return ceil($val);
}
//else
return floor($val);
}
//Cast To Integer
int $int(float $val)
{
return $val;
}
//Cast to Float
float $float(int $val)
{
return $val;
}
I also took the documentation and put it in a h file for use in VS.
I shifted the comments round so it works with Intellisense and word completion as you type.
Which reminds me, any chance of ignoring #include "a8s.h" and then including other script files?
Also #if(0) #endif would be good to block certain code blocks from functioning
Many Thanks
Trev[/code]