All pastes #577346 Raw Edit

Mine

public text v1 · immutable
·published 2007-06-19 21:25 UTC
rendered paste body
copy of a P.M.
From: zwzsg
To: FLOZi


I've often been annoyed, when making units with long repetitive sequence of pieces movement, like the segment of a scorpion's tail, the segment of a sandworm, the blade of an iris, that piecenum can be casted to integers but integers can't be casted to piecenum. Which means I can't feed a variable when scriptor expect a piecename. Even though script's piecenum are technically just integers. Since I realised about compile.cfg, I had to the idea to edit it to make it accept any number when piecenames are expected. I did the following:
In Compiler.cfg
Replace all:
OfType = TYP_PIECE;
by:
OfType = TYP_PIECE|TYP_VALUE;
And with that, I was able to have scripts such as:

BuildPillarX(basepiece,...)
{
var base,pillar,head,tip;
base =basepiece;
pillar =basepiece+1;
head =basepiece+2;
tip =basepiece+3;
move base to y-axis [-2] now;
move pillar to y-axis [-10] now;
move head to y-axis [-10] now;
....
}

Somehow I can't yet use directly a formula inside the move/turn command, but I can at least have a variable, which you'll agree would makes the script of multi segmented units animation, such as worm, caterpillar, long tails, etc... much shorter. Or here, it was used to write once the code that would move each four pillar of the Kernel Panic kernel, instead of having to manually copy'n'paste.

It's possible that verifying a piece and not an integer is supplied when Scriptor expects a piece is a safeguard to avoid improper code to be written, but I believe the advantage of having variable piecenames is much greater than the loss of a newbie protection.