Moneo, add Variable to object in git file [SOLVED]

Heyho folks,

does anyone know how to add the VarTable and some vars with moneo?

In the letoscript examles I found something, but it seems not to work.

add /VarTable, type => gffList unless /VarTable; add /VarTable/Name, type => gffString, value => "ItemProperties_Mask"; add /VarTable/[_]/Type, type => gffDword, value => 1; add /VarTable/[_]/Value, type => gffInt, value => 16;

Has someone a tip for me?

Thanks in advance and greets,
Dunahan

here is my moneo script that does this, among other things

%mod = ‘skladaciitemy.erf’;

for (’*.uti’ in %mod)
{
for (/{‘PropertiesList’})
{
if(/~/PropertyName == 15)
{
/~/CostValue = 13;
}
}
add /VarTable, type => gffList unless /VarTable;
add /VarTable/Name, type => gffString, value => “VERSION”;
add /VarTable/[]/Type, type => gffDword, value => 1;
add /VarTable/[
]/Value, type => gffInt, value => 2;
}

%mod = ‘>’;
close(%mod);

1 Like

The [_] syntax works as well as [] so at first sight the OP code look OK. Much depends on the context, though - the whole script needs to be something like Shadooow’s.

This is my script, but it is like Shadooow’s:

%mod = 'mytest.mod' or die$!;
$searchfor = 'spawn_point';

for ('*.git' in %mod) {
  for (/WaypointList) {
    $locname = {/~/TemplateResRef};
    $searchstring = substr($locname, 0, 11);
	  
    if ($searchstring eq $searchfor) {
        $name = /~/LocalizedName;
        add /VarTable, type => gffList unless /VarTable;
        add /VarTable/Name, type => gffString, value => "NESS";
        add /VarTable/[_]/Type, type => gffDword, value => 3;
        add /VarTable/[_]/Value, type => gffInt, value => $name;
    }
  }
}

%mod = '>';
close %mod;

When I open the module in the toolset or use moneo to read out the vartable, they are not set … I think I made a simple mistake that I can’t see for all the letters …

I think the issue may be that you’re trying to create a table within a table, i.e adding a variable table to every element of the waypoint table. I’m not at my desk right now, but IIRC the syntax for that is something like

add [_]/VarTable,

When I open the git in GffEditor and look at the WaypointList part, a waypoint without a variable doesn’t have the VarTable [List] struct.

I think, that this line

 add /VarTable, type => gffList unless /VarTable; 

should only add a VarTable, unless it’s already existing.

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;
2 Likes

Thank you Proleric and Shadooow! The code Proleric shared, was helpful.
Now it works like expected.

// Syntax Moneo Version 2.7
// Copies Name and Tag from special waypoints to variables NESS uses
// Thx to Proleric and Shadooow for debugging the code!
// dunahan@schwerterkueste.de

%mod = '[MOD_NAME].mod' or die$!;
$searchfor = 'spawn_point';   // change this, if your waypoint have other ResRefs

for ('*.git' in %mod) {
  for (/WaypointList) {
    $locname = {/~/TemplateResRef};
    $searchstring = substr($locname, 0, 11);
    
    if ($searchstring eq $searchfor) {
      $name = /~/LocalizedName;
      add /~/VarTable, type => gffList unless /~/VarTable;
      add /~/VarTable/Name, type => gffString, value => "NESS";
      add /~/VarTable/[_]/Type, type => gffDword, value => 3;
      add /~/VarTable/[_]/Value, type => gffString, value => $name;
      
      $tag = /~/Tag;
      add /~/VarTable/Name, type => gffString, value => "NESS_TAG";
      add /~/VarTable/[_]/Type, type => gffDword, value => 3;
      add /~/VarTable/[_]/Value, type => gffString, value => $tag;
      
      for (/~/VarTable) {
        print /~/Name, ";", /~/Type, ";", /~/Value, "\n";
      }
    }
  }
}

%mod = '>';
close %mod or die$!;