|
Aleron Wanderer
Joined: 01 Aug 2005 Posts: 76
|
Posted: Sun Oct 08, 2006 2:06 pm
[1.09] Trouble comparing integers |
First, I have a class at the root level named 'Self', in it is a variable named 'hitPoints', and it is assigned a value by a trigger reading my prompt. Now, I've created two aliases, 'engine' and 'test'.
Here is the 'engine' alias:
Code: |
#SAY ENGINE alias
#WAIT 500
#SAY value of hit points: @hitPoints
#IF (@hitPoints > 8) {
#SAY hit points are greater than 8!!!
} {
#SAY hit points are less than 9!!!
} |
Here is the 'test' alias:
Code: |
#SAY TEST alias
#SAY Value of hitPoints: @hitPoints
#IF (@hitPoints < 10) {
#SAY hit points are less than 10!
} {
#SAY hit points are greater than or equal to 10!
} |
If I run test and engine, I get different results:
Code: |
TEST alias
Value of hitPoints: 21
hit points are greater than or equal to 10!
ENGINE alias
value of hit points: 21
hit points are less than 9!!! |
There is a problem here :P. After I typed all this up, I deleted engine, recreated it and what not, and the problem went away. I'm assuming the compiled code was generated incorrectly for some reason, but I didn't think enough to save it as well. Any ideas as to why this might have happened?
edit:
After copying my semi-original trigger text back into engine, I'm seeing the same problem again. I'm going to copy the compiled code here. Also, I failed to mention (for what it's worth), both 'engine' and 'alias' are in a different class at the root level named 'Homos' (a homonculous area).
Code: |
0000 LINE 2 ; #SAY ENGINE alias
0012 STR 'ENGINE'
0028 STR 'alias'
0044 CMD say (2)
0056 LINE 1 ; #WAIT 1000
0068 PUSHEXP 0084
0076 JUMP 0092
0084 INT 1000
0092 ARGSTR
0100 CMD wait (1)
0112 LINE 2 ; #SAY hit points: @hitPoints
0124 STR 'hit'
0136 STR 'points:'
0152 VARREF @hitPoints <hitPoints> (class BoondoggleSevsTFE)
0180 CMD say (3)
0192 LINE 3 ; #IF (@hitPoints > 8) {
0204 PUSHEXP 0220
0212 JUMP 0272
0220 VARREF @hitPoints <hitPoints> (class BoondoggleSevsTFE)
0248 INT 8
0256 GT
0260 SETEXP 0 0
0272 ARGSTR @hitPoints > 8
0296 PUSHLOC 0312
0304 JUMP 0416
0312 STR 'hit'
0324 STR 'points'
0340 STR 'are'
0352 STR 'greater'
0368 STR 'than'
0380 INT 8
0388 STR '!'
0400 CONCAT
0404 CMD say (6)
0416 ARGSTR #SAY hit points are greater than 8!
0464 PUSHLOC 0480
0472 JUMP 0580
0480 STR 'hit'
0492 STR 'points'
0508 STR 'are'
0520 STR 'less'
0532 STR 'than'
0544 INT 8
0552 STR '!'
0564 CONCAT
0568 CMD say (6)
0580 ARGSTR #SAY hit points are less than 8!
0624 CMD if (3) |
|
|
Last edited by Aleron on Sun Oct 08, 2006 4:38 pm; edited 1 time in total |
|
|
|
Seb Wizard
Joined: 14 Aug 2004 Posts: 1269
|
Posted: Sun Oct 08, 2006 3:08 pm |
You didn't mention what version of CMUD you're using... Can you put it in the subject of your original post by editing it? E.g. "[1.09] <Existing subject>".
|
|
|
|
Arminas Wizard
Joined: 11 Jul 2002 Posts: 1265 Location: USA
|
Posted: Sun Oct 08, 2006 3:40 pm |
There is an error with the Auto type in variables in 1.09. Try setting your hitPoints variable to type int and see if it still does this?
I've already submitted the Auto type via the cMud feedback. |
|
_________________ Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram |
|
|
|
Aleron Wanderer
Joined: 01 Aug 2005 Posts: 76
|
Posted: Sun Oct 08, 2006 4:41 pm |
Added the version to the subject, though I saw this before and after I updated to 1.09.
As per the AutoType to Integer...that appears to have fixed it. What a strange bug, when it works in one alias, but not another. |
|
|
|
asira Beginner
Joined: 24 Jun 2002 Posts: 24 Location: United Kingdom
|
Posted: Sun Oct 08, 2006 5:41 pm |
Autotyping was probably treating it as a string value, which would evaluate as 0 when converted to an integer for the comparison, hence it wasn't working correctly for either alias.
|
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Wed Oct 11, 2006 2:37 am |
Not sure which one of the bugs fixed this, but I just tried this example in v1.10 and it seems to work now.
|
|
|
|
|
|