Consult script for setting properties

relyk

New member
I was using a consult script (My first attempt at one) to record when boots get charged so I could use it to stomp Beastly Paste before farming. Unfortunately, I set the property as bootsCharged. Behold a few days later support for boot charging was added in r9854. The problem was it used the same exact name. The script looks like this:
Code:
void main(int initround, monster foe, string page) {
	boolean charge = get_property("bootsCharged").to_boolean();
	if(contains_text(page,"rubs its soles together") && charge != true ){
		set_property("bootsCharged", true);
	}
	else if( charge != false ){
		set_property("bootsCharged", false);
	}
}
The farming script would then go stomp some ducks for Beastly Paste and set the property back to false. The only time it would be set back to true is when the boots were charged again, unless something else turned it to true, in this case KoLmafia itself by coincidence of using the same exact variable.

What would be a good way to ensure this doesn't happen? Should I have used a Zlib variable instead of KoLmafia settings?
 

Ethelred

Member
I preface my own personal mafia settings with my initials, etu (Ethelred the Unready), as in etuVariableFoo, since it's unlikely that the Mafia devs would use that particular prefix. If I want it to be reset at rollover, just slap an underscore in front of that, as in _etuVariableToBeReset.
 

slyz

Developer
What would be a good way to ensure this doesn't happen? Should I have used a Zlib variable instead of KoLmafia settings?
Why not just let Mafia set the variable? Remove the set_property() from your scripts, and you should be fine.
 
Top