Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD Beta Forum
Larkin
Wizard


Joined: 25 Mar 2003
Posts: 1113
Location: USA

PostPosted: Sun Feb 17, 2008 6:11 pm   

[2.18] Expression evaluation issues with data record variables
 
This script does not give me the results expected. I used a clean session to verify that the expression is truly incorrect and it's not something else interfering.

Code:
#VAR ninshi {rightleg=1}
#VAR ruptures {rightleg=2}
#IF (@ruptures.rightleg and !@ninshi.rightleg) {#SHOW right} {#SHOW no right}
#IF ((@ruptures.rightleg and !@ninshi.rightleg) or (@ruptures.leftleg and !@ninshi.leftleg)) {#SHOW one} {#SHOW none}


What I want to see is "no right" and then "none," but I see "no right" and "one" instead. The second expression is the one that's broken. I've had similar problems with zMUD and data record variables, and oddly enough it only happened when there were two elements, and only two, joined by "or" in the expression. Using %db or %iskey usually gets me around this problem, but it's still a bug that this way doesn't work.
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Sun Feb 17, 2008 7:21 pm   
 
#SWITCH works.

#SWITCH (@ruptures.rightleg and !@ninshi.rightleg) {#SHOW one} (@ruptures.leftleg and !@ninshi.leftleg) {#SHOW one} {#SHOW none}

Much more efficient too, in my opinion.

Charneus
Reply with quote
Larkin
Wizard


Joined: 25 Mar 2003
Posts: 1113
Location: USA

PostPosted: Sun Feb 17, 2008 8:17 pm   
 
Well, I wanted one expression to combine the two because you don't heal each leg individually. If either leg is damaged, I need to heal "legs" in general, basically. I've coded my own workaround for the logic, but this is still a bug I felt worth reporting. Your #SWITCH doesn't do the same thing as my #IF, either.
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Mon Feb 18, 2008 3:10 am   
 
Right. The #SWITCH will go through the list until the parameters are met. I fail to see how my switch doesn't do the same thing as your IF.

Scenario one: Ruptures.rightleg=1, but ninishi.rightleg=0. It shows one. If that fails, then it checks ruptures.leftleg and ninishi.leftleg. If the value for ruptures.leftleg=1, and ninishi.leftleg=0, then it shows one. If neither match, then it reports none. Your full alias should contain your first #IF statement and the switch:

Code:
#IF (@ruptures.rightleg and !@ninshi.rightleg) {#SHOW right} {#SHOW no right}
#SWITCH (@ruptures.rightleg and !@ninshi.rightleg) {#SHOW one} (@ruptures.leftleg and !@ninishi.leftleg) {#SHOW one} {#SHOW none}

I've tested it on my side, and it work.
Code:
#VAR ninshi {rightleg=1}
#VAR ruptures {rightleg=2}

plus the code I stated above reports "no right" and "none" as you had wanted. Unless there is something else I'm missing...

Charneus
Reply with quote
Larkin
Wizard


Joined: 25 Mar 2003
Posts: 1113
Location: USA

PostPosted: Mon Feb 18, 2008 3:57 am   
 
Yes, there is something you're missing. I only posted code used to reproduce the bug. It's not the full code I used for my alias, but thanks for your inputs. Smile
Reply with quote
Malach
Apprentice


Joined: 03 Nov 2007
Posts: 132

PostPosted: Tue Feb 19, 2008 3:26 pm   
 
I've done some playing around and this is definitely a problem with using OR (and ||) in combination with database variables that do not exist and the simple @Var and !@Var true/false test. If I use the following code:

Code:

#VAR ninshi {rightleg=1}
#VAR ruptures {rightleg=2}
#IF (@ruptures.rightleg and !@ninshi.rightleg) {#SHOW right} {#SHOW no right}
#IF ((@ruptures.rightleg and !@ninshi.rightleg) or (@ruptures.leftleg > 0 and @ninshi.leftleg < 1)) {#SHOW one} {#SHOW none}


It works as intended. If I use the following:

Code:
#VAR ninshi {rightleg=1|leftleg=2}
#VAR ruptures {rightleg=2|leftleg=2}
#IF (@ruptures.rightleg and !@ninshi.rightleg) {#SHOW right} {#SHOW no right}
#IF ((@ruptures.rightleg and !@ninshi.rightleg) or (@ruptures.leftleg and !@ninshi.leftleg)) {#SHOW one} {#SHOW none}


It also works as intended. If I use the following:

Code:
#VAR ninshi {rightleg=1}
#VAR ruptures {rightleg=2}
#IF (@ruptures.rightleg and !@ninshi.rightleg) {#SHOW right} {#SHOW no right}
#IF (@ruptures.leftleg and !@ninshi.leftleg) {#SHOW one} {#SHOW none}


It works as intended. I can use any combination of ands and such but as soon as the OR is introduced into the equation, it fails. There are simple ways around this of course. Simply fully writing out the expression instead of the using the @Var and !@Var shortcuts is the simplest. But it is still a weird bug.

EDIT: Oh and I can't get the problem to replicate using non database variables:

Code:
#ALIAS test {Test3 = 1;Test4 = 1;#IF ((@Test3 && !@Test4) OR (@Test1 && !@Test2)) {#say fired!} {#say didn't fire!}}


Works fine.
_________________
Intel Core2 Quad CPU @ 2.4 GHZ with Windows Vista Home Premium and 2 GB Ram
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD Beta Forum All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net