I can't figure out this error

tepesh

New member
Its quite possible I'm overlooking something basic. I just got into ASH scripting yesterday but I've been over the wiki and read a bunch of information here on the boards but I can't figure out what's wrong with this code.

Here's a short version of the script that produces the error message I'm seeing:

Code:
record BuffKeep {
  int    cost_per_mil; // how much for 100 turns
  int    min_turns;    // minimum number of turns for the buff
  int    min_buy;      // minimum number of turns to buy
  int    last_turns;   // number of turns when starting
  int    tried_order;  // highest order value attempted
};

void main() {
  BuffKeep [skill] buffkeep;

  file_to_map( "buffkeep1.txt", buffkeep );

  foreach sk in buffkeep {
    buffkeep[sk].cost_per_mil = buffkeep[sk].cost_per_mil * 10000;

    print( "Searching for "+skill_to_string(sk)+"... ("+buffkeep[sk].min_turns+":"+buffkeep[sk].last_turns+":"+buffkeep[sk].cost_per_mil+")" );
  }
}

When run, I get the error message "net.sourceforge.kolmafia.KoLmafiaASH$AdvancedScriptException: Invalid type name 'sk' (buff.ash, line 15)"

I've attached buffkeep1.txt in case it provides a necessary clue. Interestingly, if you comment out line 15, the script works properly - I didn't see anything on the wiki or here regarding this error message or the possibility that file_to_map'ed records were read only.

Thank you for taking the time to look this over.
 

Attachments

  • buffkeep1.txt
    202 bytes · Views: 53

macman104

Member
It took me a long while to figure this out. And I created this little test file
Code:
record BuffKeep {
  int    cost_per_mil; // how much for 100 turns
  int    min_turns;    // minimum number of turns for the buff
  int    min_buy;      // minimum number of turns to buy
  int    last_turns;   // number of turns when starting
  int    tried_order;  // highest order value attempted
};

void main()
{
	BuffKeep [skill] buffkeep;
	buffkeep[$skill[The Ode To Booze]].cost_per_mil = 0;
	buffkeep[$skill[The Ode To Booze]].min_turns = 0;
	buffkeep[$skill[The Ode To Booze]].min_buy = 0;
	buffkeep[$skill[The Ode To Booze]].last_turns = 0;
	buffkeep[$skill[The Ode To Booze]].tried_order = 0;
	
	map_to_file(buffkeep, "mapTest.txt");
}
To see if there was something wrong with the way your file was formatted, but I kept getting "Invalid type name '$' (TestMap.ash, line 12)". Couldn't for the life of me figure it out, tried changing the skill to an int, and was still getting an error. Finally figured out, it is the fact that you have BuffKeep and buffkeep. If you change buffkeep to something like...buffMap, it should work just fine.

Changing your code to this...
Code:
record BuffKeep {
  int    cost_per_mil; // how much for 100 turns
  int    min_turns;    // minimum number of turns for the buff
  int    min_buy;      // minimum number of turns to buy
  int    last_turns;   // number of turns when starting
  int    tried_order;  // highest order value attempted
};

void main() {
  BuffKeep [skill] buffMap;

  file_to_map( "buffkeep1.txt", buffMap );

  foreach sk in buffMap {
    buffMap[sk].cost_per_mil = buffMap[sk].cost_per_mil * 10000;

    print( "Searching for "+skill_to_string(sk)+"... ("+buffMap[sk].min_turns+":"+buffMap[sk].last_turns+":"+buffMap[sk].cost_per_mil+")" );
  }
}
Produced the following gCLI output
Searching for Carlweather's Cantata of Confrontation... (200:0:1700000)
Searching for Empathy of the Newt... (2000:0:1600000)
Searching for Fat Leon's Phat Loot Lyric... (2000:0:810000)
Searching for Jabañero Saucesphere... (2000:0:940000)
Searching for The Ode to Booze... (0:0:0)

EDIT: I will say that, it is kind of strange, since I thought the capitalization would have caused them to be differentiated. But you had me searching everywhere, I was re-reading stuff on the dev forums when veracity first rolled out maps and records, and everything, seeing where it went wrong. The error message didn't provide a whole lot of help in debugging either...
 

holatuwol

Developer
ASH is case-insensitive, so yeah ... once you define a type BuffKeep, you should (personally) treat it like a reserved word. The cryptic error message ... well, I have absolutely no idea how to fix it. >.>;
 

tepesh

New member
[quote author=macman104 link=topic=965.msg4794#msg4794 date=1181541487]
EDIT: I will say that, it is kind of strange, since I thought the capitalization would have caused them to be differentiated. But you had me searching everywhere, I was re-reading stuff on the dev forums when veracity first rolled out maps and records, and everything, seeing where it went wrong. The error message didn't provide a whole lot of help in debugging either...
[/quote]

THANK YOU!

I hadn't realized that ASH was case insensitive, in fact, I though I'd used that same trick elsewhere (and now have to go check in that). I was going nuts trying to figure this out - I guess I feel a bit better now and I completely agree regarding the lack error message detail.
 

macman104

Member
[quote author=holatuwol link=topic=965.msg4798#msg4798 date=1181546499]
ASH is case-insensitive, so yeah ... once you define a type BuffKeep, you should (personally) treat it like a reserved word. The cryptic error message ... well, I have absolutely no idea how to fix it. >.>;[/quote]Huh, same as tepash, I could have sworn as well that I'd used the same word, but I guess not. Good to know that it is case-insensitive. I wouldn't worry too much about the cryptic message, we know what the problem is now, so it's not too big a deal...
 
Top