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


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Tue Jun 29, 2010 8:36 pm   

3.21 BUG w/ Stringlists
 
To replicate:

Code:

<class name="test_string" id="121">
  <var name="string_test" type="StringList" id="122">
    <value>val1|val2|val3|val4</value>
    <json>["val1","val2","val3","val4"]</json>
  </var>
  <trigger priority="15770" id="123">
    <pattern>This is a test of (val%d)</pattern>
    <value>$val_l=%trim( %replace( %1, "does", ""))
#show %if(%ismember( $val_l, string_test), "TRUE", "FALSE")
#show "$val_l: "$val_l
#SWITCH (%match( %trigger, %concat( "This is a test of ", $val_l)) &amp;&amp; %ismember( $val_l, string_test)) {#show "MATCH!"}
{#show "NO MATCH!"}
#show %if(%ismember( $val_l, string_test), "TRUE", "FALSE")</value>
  </trigger>
</class>


Install the script above, type in:
#show "This is a test of val1"

Your output should be:

This is a test of val1
TRUE
$val_l: val1
MATCH!
TRUE

This is as intended.

Now, close the session. Re-open the session and type in:
#show "This is a test of val1"

This is a test of val1
FALSE
$val_l: val1
NO MATCH!
FALSE

Now open the setting's editor and go to the test_string class. Click on the variable string_test, then click on the trigger.
Type:
#show "This is a test of val1"

You should get
This is a test of val1
TRUE
$val_l: val1
MATCH!
TRUE
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
GeneralStonewall
Magician


Joined: 02 Feb 2004
Posts: 364
Location: USA

PostPosted: Tue Jun 29, 2010 9:28 pm   
 
Any way you can simplify this?
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Tue Jun 29, 2010 9:30 pm   
 
Not sure, that was about as simple as I could make it when I looked at it. I could look again.
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Wed Jun 30, 2010 1:29 pm   
 
Confirmed (with caveats). So the behavior you described is very weird and certainly occurs with the code you posted.

Now the caveats. You are using %ismember but incorrectly. The syntax is as follows:
Quote:
%ismember(s,list)

For example
Code:
#IF (%ismember(@petitioner,@friendsList)) {cast heal @petitioner} {say Nope.}




You are referencing the list name without the '@'. Now I may have missed a beta feature that allows this (or it may be a fluke of referencing session cache). Since this 'cache' presumably gets flushed when you close the session and the code fails. When you access the package editor, I suspect you repopulate this 'cache' and then the code works again. I'm sure Zugg can fill in the specifics but I'm pretty this is the gist of what's happening.

The test code works consistently with the '@' symbol.

Code:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
  <class name="test_string" copy="yes">
    <var name="string_test" type="StringList" copy="yes">
      <value>val1|val2|val3|val4</value>
      <json>["val1","val2","val3","val4"]</json>
    </var>
    <trigger priority="15770" copy="yes">
      <pattern>This is a test of (val%d)</pattern>
      <value>$val_l=%trim( %replace( %1, "does", ""))
#show %if(%ismember( $val_l, @string_test), "TRUE", "FALSE")
#show "$val_l: "$val_l
#SWITCH (%match( %trigger, %concat( "This is a test of ", $val_l)) &amp;&amp; %ismember( $val_l, @string_test)) {#show "MATCH!"}
{#show "NO MATCH!"}
#show %if(%ismember( $val_l, @string_test), "TRUE", "FALSE")</value>
    </trigger>
  </class>
</cmud>
_________________
Asati di tempari!
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Wed Jun 30, 2010 3:11 pm   
 
I was told dropping the @ symbol allows you to access the variable by reference, instead of making several copies of it, which would result in faster script execution for longer lists. However, if it's not saving the data, this is a problem.

It's likely that the same thing is happening here as well.


EDIT: Link to by-reference stuff. Am I misinterpreting it?
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
Zugg
MASTER


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

PostPosted: Wed Jun 30, 2010 4:24 pm   
 
Chamenas is correct in his use of the "by reference" stuff. In 3.2x if you enter a function name into the command line and press F1 and see an argument of type "List", "ListRef", or "Table" then the argument allows the @ to be dropped for a direct reference that is faster than using @ (which makes a copy of the variable).

Still looking into the original bug report.
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Wed Jun 30, 2010 4:47 pm   
 
Tech wrote:
Now I may have missed a beta feature that allows this ...


Man my memory is getting bad, because I was here for that other discussion too. Smile

Well Zugg's got the info he needs so it should get handled.
_________________
Asati di tempari!
Reply with quote
Zugg
MASTER


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

PostPosted: Thu Jul 01, 2010 12:23 am   
 
There was a bug dealing with list/table variables not getting set properly at session startup. The internal json table was not being created until needed so sometimes a script could access this undefined table before it was created. Fixed for the next update.
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