[TF] Is there a bug in comparison operators?
Brought to you by:
kenkeys
|
From: mazur at xs4all.nl (S. Linnemann) - 2003-04-01 10:41:53
|
On Sun, 2003-03-30 at 17:07, Stefan Linnemann wrote:
> got the prompt thingy sorted, now, mainly by avoiding %Px in the
> assignments, but now I stumble upon further weirdness:
> I'm designing an automated healing system for my character:
> All concerned variables are globally /set to 0 on startup.
> /def -p1 -mregexp -h'PROMPT ' prm_hook = /test prompt("%*")%;/set \
> hitp=%1%; /set manap=%2%;/set status=%3%;/test \
> hitp:=substr({hitp},5,4)%;/test \
> manap:=substr({manap},10,4)%;/test status:=substr({status},5)%; /if \
> ({hitp} > \
> {maxhit}) /set maxhit %hitp%; /endif%; /if ({manap} > {maxmana}) /set \
> maxmana %manap%; /endif%; /checkstatus
> (Well, in actuality it's a single line, but you get the point.)
> /def checkstatus = /if ( {hitp} < {maxhit} ) /echo Drinking health.%; \
> /endif
> Weirdness 1: the comparison ({manap} > {maxmana}) does not always
> trigger the /set maxmana %manap when true. (same for hits)
> Weirdness 2: The comparison ({hitp} < {maxhit}) often triggers even when
> their values are equal.
> I've used many listvars to check the variables in question before and
> after the triggers, so it's not a hidden value change.
> So what's the matter? Please help, and add I'm being stupid if I am.
Well, it turned out to be, that the hitppoints part of the prompt,
often, but not always, includes a colour-reset code, so inserting the
stringlength in the operating cured the weirdnesses.
Sorry to have bothered you.
Stefan.
|