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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Elemar
Beginner


Joined: 04 Jan 2001
Posts: 14

PostPosted: Tue Feb 19, 2002 9:13 pm   

5.55 to 6.16 upgrade trigger problem
 
I've been using 5.55 and upgraded to 6.16 recently.

I had this auction trigger which esentially took the following from my mud :

>Your bid has been rejected because:
>Your bid of 100 is insufficient. You must bid at least 1,000,100.

And created a YESNO box to ask the user if they wanted to pay the increased price.

The trigger is as follows :

#var Amount %1
#YESNO "Your bid is too low, bid %1" {YES: bid @Queue %remove( ",", {%remove( ",", @Amount)})} {No:}

Where Amount is the 1,000,100. Queue is set by my 'bid' alias which simply takes two arguments

#var Queue %1
#var Amount %2
"bid %1 %2"

and sends the command direct to the mud ie. 'bid b 100'
the 'bid' alias is required to store the Queue letter for later use by the trigger.

My problem is this : It worked in 5.55.
It'd pick up the trigger, display the yes/no box, and when 'yes' was clicked send :

bid b 100100

to the mud. Under 6.16 however it doesn't. It sends :

"bid @Queue %remove( ",", {%remove( ",", @Amount)})"

It appears it's not evaluating the expression, (Oh, and don't ask me why I have two remove's in there, I have no idea), and sending the expression itself to the mud.

Any ideas on what's going on? And wether I've got something set in 5.55 that I don't in 6.16?
I have both installations and it continued to work in 5.55.

Thanks in advance,
Elemar
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Wed Feb 20, 2002 12:53 am   
 
I'm not sure if this is the problem, but try replacing the line
"bid %1 %2"
with
~bid %1 %2

Also, the function %remove() only strips the first occurence of a string so you should switch to the %replace() function. The modified version would be something like:

Trigger Pattern:
You must bid at least (%x).
Value:
#YESNO "Your bid is too low, bid %1" {bid @Queue %replace(%1,",","")}

Alias Name:
bid
Value:
#VAR Queue %1
#VAR Amount %2
~bid %1 %2


LightBulb
All scripts untested unless otherwise noted
Reply with quote
Elemar
Beginner


Joined: 04 Jan 2001
Posts: 14

PostPosted: Wed Feb 20, 2002 10:50 pm   
 
Thanks Bulb :)

The ~bid thing did the trick. I'd like to know what ~ does though - I couldn't find a reference to it in the help files.

The %replace didn't work, mind you. A string like 75,000 comes out as 75
I expect that's why I used the %remove (and the second %remove was to cope with numbers larger than 999,999 - which would have 2 comma's).

So, I left the trigger as it was, did placed the ~ infront of my bid, removed the quotes and it's all peachy now.

Thanks for the help,
Elemar.
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Wed Feb 20, 2002 11:20 pm   
 
quote:

Thanks Bulb :)

The ~bid thing did the trick. I'd like to know what ~ does though - I couldn't find a reference to it in the help files.

The %replace didn't work, mind you. A string like 75,000 comes out as 75
I expect that's why I used the %remove (and the second %remove was to cope with numbers larger than 999,999 - which would have 2 comma's).

So, I left the trigger as it was, did placed the ~ infront of my bid, removed the quotes and it's all peachy now.

Thanks for the help,
Elemar.



The ~ is the quote character, used to force ZMud to take special characters (ie, %#@;") as the literal character. Same thing applies to aliases. If you have an alias named bid, then 'bid' will always get interpreted as the alias whereas '~bid' will always get interpreted as the literal word 'bid'.

EDIT: the system variables seem to be read-only, which is why %replace() doesn't work.

li'l shmoe of Dragon's Gate MUD
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Thu Feb 21, 2002 12:26 am   
 
Nope, the problem is not that system variables are read-only (which they are, because you can't change their value), because you are not trying to change their value, you are just using the value of %1, modifying it (but at this time, it is just a copy) and returning it so the script can do something with the modified version. (Don't you just love paragraphs with only one sentence? )

The problem lies in the way zMUD parses the function. When you do this:
%replace(%1, ",", "")

zMUD will put whatever value %1 has in the place it was found. Then, it parses the function call again so that, this time, it may call it with the correct arguments. However, if %1 happens to contain a comma, it will be just as if you typed:
%replace(2,000,",","")

and that is where zMUD gets confused. It expects three arguments for %replace but receives four. So it drops the last one, and you end up replaceing every instance of "000" that appears in "2" with ",", but there are not any "000"s in "2", so it just returns "2"

To solve this, you enclose %1 in double quotes (even though it may seem that zMUD will not parse it this way, it will) to tell zMUD to treat it as just one argument. Then, when it is expanded, you get:
%replace("2,000", ",", "")

which will return:
2000

Kjata
Reply with quote
Elemar
Beginner


Joined: 04 Jan 2001
Posts: 14

PostPosted: Sat Feb 23, 2002 9:31 pm   
 
Woot!

That explains the odd behaviour, and my wierd workaround. I shall replace with the more acceptable function. Thanks, Kjata.

As for the ~ - I was using the "stuff to send here" that previous versions used. Enclosing the 'bid' in quotes sent it direct to the mud, rather than interpreting and using the alias. I can see I have catching up to do.

I am educated, I'm enlightened and I'm thankful to you all for your help.

Ele.
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Sat Feb 23, 2002 9:48 pm   
 
Err, so does it parse a @variable differently than the %variable?

%replace(%1, "blah", "bleh")

did NOT work for me (in the instances I can remember), but

#variable @1 %1
%replace(@1, "blah", "bleh")


did with absolutely no change to the code or trigger save the addition of the #var line ("blah" and "bleh" are placeholders, not actual values).

li'l shmoe of Dragon's Gate MUD
Reply with quote
Charbal
GURU


Joined: 15 Jun 2001
Posts: 654
Location: USA

PostPosted: Sat Feb 23, 2002 11:58 pm   
 
quote:

Err, so does it parse a @variable differently than the %variable?



Yes, %1 expansions are handled before arguments are sent off to the function whereas @ expansion is done by functions that require it and left alone by those that don't (ie, %literal).

So if %1 is "1, 2"

%replace(%1, ",", "") is expanded as
%replace(1, 2, ",", "") and then the arguments 1, 2, ",", and "" are sent to %replace

For the second example, I assume you meant either
#variable 1 {%1}
%replace(@1, "blah", "bleh")

or

#variable 1 "%1"
%replace(@1, "blah", "bleh")

instead of

#variable @1 %1
%replace(@1, "blah", "bleh")


In any case, using something like this, we send the arguments "@1", "blah" and "bleh" to %replace. %replace expands "@1" and, since the arguments are already pigeonholed into their slots, doesn't cause problems as above.


 - Charbal
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion 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