Bug - Not A Bug Sweat values not being checked correctly in r26568?

neomaster

New member
Hello,

Tried writing a script to automate using the new "Sweat Out Some Booze" skill, and found that although the property "sweat" returns with a value higher than 25, the following script won't trigger when looking up the value.

if (get_property("sweat") >= 25 && (get_property("_sweatOutSomeBoozeUsed") < 3 )) { use_skill($skill[7414]); }
I then tried the following, removing the condition of "_sweatOutSomeBoozeUsed" to see if that was the issue, and it still didn't trigger.
if (get_property("sweat") >= 25) { use_skill($skill[7414]); }
I then tried to look up what the value was actually returning with "print (get_property("sweat"));" which returned a value of 100, which is what I expected. I then tried to use the skill with the "use_skill($skill[7414]);" command and it worked perfectly fine without any conditions. There is a very real chance I've misunderstood something, or written something incorrectly, but I figured I'd check in case it was actually a bug.


EDIT:
Thread may not be necessary, can't reproduce the bug anymore, it seems to now be able to check the value correctly? No clue why it couldn't previously, or why it suddenly can now, but it runs commands properly after checking this value now.
 
Last edited:

neomaster

New member
Code:
get_property
returns a string. You want to use
Code:
get_property(lookup).to_int()
.
I've managed to get it working now both with and without using the extra ".to_int()" on the end of calling the sweat property, can I ask what the functional difference is between the two? Haven't come across the need to use it before and would like to learn more.
 

heeheehee

Developer
Staff member
can I ask what the functional difference is between the two?
ASH coerces between types in a very specific manner.

Without checking more closely, I'd expect that get_property(lookup) > 25 is actually resulting in the string comparison "100" > "25" which is false (since "1" is less than "2"), vs 100 > 25, which would be true.
 

neomaster

New member
ASH coerces between types in a very specific manner.

Without checking more closely, I'd expect that get_property(lookup) > 25 is actually resulting in the string comparison "100" > "25" which is false (since "1" is less than "2"), vs 100 > 25, which would be true.
That's really interesting! I'm surprised I haven't run into any headaches prior to now if that's how that kind of check can resolve. For the avoidance of any doubt, should I always be using the extra ".to_int()" if the value I'm checking is numeric?
 

heeheehee

Developer
Staff member
If it's an integer, yes.

If you try to compare "3.4" against 3.2, you should be using to_float().

Treating these as string comparison "works" as long as the two types are the same magnitude (e.g. "97" vs "38"), namely that the leading digit lines up (e.g. both numbers start with a tens digit). But if they're not, then all bets are off.
 

neomaster

New member
If it's an integer, yes.

If you try to compare "3.4" against 3.2, you should be using to_float().

Treating these as string comparison "works" as long as the two types are the same magnitude (e.g. "97" vs "38"), namely that the leading digit lines up (e.g. both numbers start with a tens digit). But if they're not, then all bets are off.
Thanks so much to the both of you for pointing this out to me and explaining it! I've just tested a few things and it lines up perfectly with what you're saying. My current sweat value is 25, and mafia is treating that as a value greater than 100, unless I use ".to_int()" and then it understands that 25 isn't greater than 100. Will keep this in mind in the future!
 
Top