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


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Thu Sep 02, 2010 4:04 pm   

[3.25]Bug with %{i} in #LOOP
 
Not sure when this started happening, as I can't remember using it over the last couple of days (may have been pre-3.23...) However, a script that I have in the library that used to work no longer does.

Put simply, this was the script:
Code:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
  <alias name="find" copy="yes">
    <value>$mob=%1
#SWITCH (%2 AND %3) {#LOOP %2,%3 {where %{i}.$mob}} (%2 AND !%3) {#LOOP %2,( %2+8) {where %{i}.$mob}} {#LOOP 8 {where %{i}.$mob}}</value>
  </alias>
</cmud>


I tried it today, and all it did was send 'where' 8 times. To fix it, I had to do:

Code:
#SEND {%concat("where ",%i,".",$mob)}


The problem may very well be %key.%val syntax, but I hadn't had any problem with it until now. Not sure how many people it may affect, nor how many more scripts of mine are broken that I haven't checked yet, but it'd be nice if I could go back to %{i}.$mob, if possible.

Charneus
Reply with quote
dbosst
Apprentice


Joined: 15 Jun 2010
Posts: 121

PostPosted: Thu Sep 02, 2010 4:29 pm   
 
might be related to http://forums.zuggsoft.com/forums/viewtopic.php?t=35705&sid=03e5776fdda167ab877f98db3f1fbc8f
Reply with quote
Zugg
MASTER


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

PostPosted: Thu Sep 02, 2010 4:52 pm   
 
I'll check into this, but why aren't you just doing this:
Code:
#LOOP 8 {where %i.$mob}

Not sure why you are using the indirect {} reference. This syntax is normally only use when you have a variable expression within the {}. It's still a bug and I'll add it to the list.
Reply with quote
Zugg
MASTER


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

PostPosted: Thu Sep 02, 2010 4:56 pm   
 
Oh, nevermind, I see the issue here. This actually isn't a bug. I see that you are trying to send the "." verbatim whereas CMUD is taking this to be a database key reference. There is no way for CMUD to know that %i isn't a database variable reference.

You might try:
Code:
#LOOP 8 {where %i"."$mob}

or
Code:
#LOOP 8 {where %i~.$mob}

to basically tell CMUD that the "." character is a literal value and not a database key reference. So there isn't any bug here, it's working as intended.
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Thu Sep 02, 2010 10:46 pm   
 
The "." worked. I guess it's more of a 'Hey, this worked for all previous versions, so why does it stop now?' kind of thing. Oh well... time to go through the scripts and see if I need to make any other changes. :P Thanks for the "." idea!

Charneus
Reply with quote
Zugg
MASTER


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

PostPosted: Fri Sep 03, 2010 4:55 pm   
 
That fact that it worked in previous versions was a bug that prevented you from using the %i.$mob syntax to reference the $mob key within the %i database variable/table. However, the situation you are in is probably much more common than the situation where you want to use %i.$mob, so maybe I should change it so that to reference %i as a database variable you would need to use %db instead. I know a lot of MUDs need stuff like:

get 1.corpse

and stuff like that where you want to loop through a bunch of objects in the room. So I can see that this change might cause too many compatibility problems for older scripts. I'll give it some thought.
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