OK now Iâm back at my desk, I have an example of adding a variable to every creature in the area. The syntax is actually âadd /~/VarTable,â.
Your understanding of the âunlessâ clause is correct. I suspect that the problem with your code is that itâs adding the VarTable to the area, not to the waypoint, because itâs not specifying the path.
Notice that the first part of my script - updating the template - uses a syntax like yours (and Shadooowâs), because the creature variables are added to the root (creature).
However, the second part of the script, which adds the same VarTable to every instance of a creature in every area, has to specify the path /~/.
# Adds a variable to every creature using a particular script
#
# Amends area instances, too.
%mod = 'c:\NeverwinterNights\nwn\modules\Dark Energy.mod' or die;
print "\n\nGLOBAL:\n";
for (%mod['*.utc'])
{
if (/ScriptDialogue eq 'bh_look_ahead')
{
add /VarTable, type => gffList unless /VarTable;
add /VarTable/Name, type => gffString, value => "LookAhead";
add /VarTable/[_]/Type, type => gffDword, value => 1;
add /VarTable/[_]/Value, type => gffInt, value => 1;
print /TemplateResRef, " ", /FirstName, "\n";
}
}
for (%mod['*.git'])
{
$area = $_;
$header = 0;
for (/{'Creature List'})
{
if (/~/ScriptDialogue eq 'bh_look_ahead')
{
if ($header == 0)
{
$header = 1;
print "\n\nAREA: ", $area, "\n";
}
add /~/VarTable, type => gffList unless /~/VarTable;
add /~/VarTable/Name, type => gffString, value => "LookAhead";
add /~/VarTable/[_]/Type, type => gffDword, value => 1;
add /~/VarTable/[_]/Value, type => gffInt, value => 1;
print /~/TemplateResRef, " ", /~/FirstName, "\n";
}
}
}
%mod = '>' or die;
close(%mod) or die;