Moneo / Letoscript query - assigning a value to a resref - SOLVED

I’m trying to rebuild the area table in module.ifo.

Everything works except the line

add /Mod_Area_list/Area_Name, type => gffResref, value => $area;

This builds the table entry correctly, except that the value appears to be blank. This is strange, because printing $area before and after that line demonstrates that it contains the correct string value. Am I missing a trick?

The full script is

# Ensures that the area list in module.ifo matches the area files in the module.
# The list is corrupted if an area is deleted from the Export window or temp0.  

%mod = 'C:\Users\MyUser\Documents\Neverwinter Nights\modules\Test.mod' or die;

#
# Build area list in a table
#
@area_list = ();
$area_count = 0;
#  
  for (%mod['*.git']) 
    {	
      $area = substr($_, 0, -4);  
      print "Area In=", $area, "\n";
      $area_list[++$area_count] = $area;
    }
#
# Copy table to module
#
for (%mod['module.ifo'])
{
  delete /Mod_Area_list;
  #
  for (@area_list)      
    {
      $area = $_;
      print "Area Found=", $area, "\n"; 
      add /Mod_Area_list, type => gffList unless /Mod_Area_list;  
      add /Mod_Area_list/Area_Name, type => gffResref, value => $area;	
      print "Area Out=", $area, "\n";       	  
    }
}  
%mod = '>' or die;
close(%mod) or die;

I am not very familiar with Moneo, but have you tried putting $area in double quotes?

add /Mod_Area_list/Area_Name, type => gffResref, value => "$area";

@pscythe I see where you’re coming from, but that sets every field to the literal

$area

instead of the string contained within the variable $area.

1 Like

I found a workaround. Having created the table entry with the blank value, we simply assign the value to the field we just made:

      add /Mod_Area_list/Area_Name, type => gffResref, value => $area;
      /Mod_Area_list/[_]/Area_Name = $area;

I don’t know why the first statement doesn’t work by itself. It works for fields of type gffString etc. Maybe Moneo has a bug when assigning resrefs.

1 Like