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
oldguy2
Wizard


Joined: 17 Jun 2006
Posts: 1201

PostPosted: Sun Sep 26, 2010 6:47 am   

[3.29b] Expression Triggers Not Firing Properly?
 
I am pretty sure this is not how expression triggers should be working. I created the following test in an untitled session:

Code:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
  <class name="ExpressionTest" copy="yes">
    <var name="varA" type="Record" copy="yes">
      <value>One=0|Two=0</value>
      <json>{"Two":0,"One":0}</json>
    </var>
    <var name="varB" type="Record" copy="yes">
      <value>One=0|Two=0</value>
      <json>{"Two":0,"One":0}</json>
    </var>
    <var name="allTrue" usedef="true" copy="yes">
      <value>0</value>
      <default>0</default>
    </var>
    <trigger type="Expression" priority="40" newline="false" copy="yes">
      <pattern>@varA.One &amp;&amp; @varB.One</pattern>
      <value>#print "varA.One and varB.One are true"</value>
    </trigger>
    <trigger type="Expression" priority="50" newline="false" copy="yes">
      <pattern>@varA.Two &amp;&amp; @varB.Two</pattern>
      <value>#print "varA.Two and varB.Two are true"</value>
    </trigger>
    <trigger type="Expression" priority="60" newline="false" copy="yes">
      <pattern><![CDATA[@varA.One && @varA.Two && @varB.One && @varB.Two]]></pattern>
      <value>allTrue = 1</value>
    </trigger>
    <trigger type="Expression" priority="70" copy="yes">
      <pattern>@allTrue</pattern>
      <value>#print "All are true"</value>
    </trigger>
    <trigger type="Expression" priority="80" newline="false" copy="yes">
      <pattern>@varA.One &amp;&amp; !@varB.One</pattern>
      <value>#print "varA.One true but not varB.One"</value>
    </trigger>
    <trigger type="Expression" priority="90" newline="false" copy="yes">
      <pattern>!@varA.One &amp;&amp; @varB.One</pattern>
      <value>#print "varB.One true but not varA.One"</value>
    </trigger>
    <alias name="test" copy="yes">
      <value>varA.One = 1
varB.One = 1
varA.Two = 1
varB.Two = 1
varA.One = 0
varA.Two = 0
#print "--------------------------------"</value>
    </alias>
    <trigger priority="110" copy="yes">
      <pattern>!@varA.Two &amp;&amp; @varB.Two</pattern>
      <value>#print "varB.Two true but not varA.Two"</value>
    </trigger>
    <alias name="reset" copy="yes">
      <value>varA.One = 0
varB.One = 0
varA.Two = 0
varB.Two = 0
allTrue = 0</value>
    </alias>
  </class>
</cmud>


I then entered executed the test alias and the following is what printed:

Quote:
varA.One true but not varB.One
varA.One and varB.One are true
varA.One and varB.One are true
All are true
varA.One and varB.One are true
varA.Two and varB.Two are true
varB.One true but not varA.One
varA.Two and varB.Two are true
varB.One true but not varA.One
--------------------------------
varB.One true but not varA.One


That message after the break printed quite a few seconds later.

I then executed the reset alias and the following printed:

Quote:
varB.One true but not varA.One
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Mon Sep 27, 2010 1:14 am   
 
I believe that Expression triggers, like status windows, are not intended to work on database variables.
Reply with quote
oldguy2
Wizard


Joined: 17 Jun 2006
Posts: 1201

PostPosted: Mon Sep 27, 2010 1:54 am   
 
I thought that might be the case, but it doesn't clarify that anywhere. It simply says it checks the expression. However, I guess it makes sense because it is checking them any time any of the values change in the database variable. Oh well. It's not a big deal. Just ignore this post and delete it if that is the case.
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Mon Sep 27, 2010 7:15 pm   
 
Rahab is correct. Expression triggers will not work properly with database variables. There is no way for the low-level JSON library to notify the higher-level zScript parser that some internal table value has changed. Also, CMUD tracks variable changes only for the top-level variable and not for each "key" in a database variable. This is something that might improve in the future, but for 3.x, it just is not supported.
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