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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
complex
Apprentice


Joined: 12 Apr 2004
Posts: 134
Location: USA

PostPosted: Thu Sep 30, 2010 5:56 pm   

script advice
 
Currently I am putting the finishing touches on a sell script, but I am still a newbie when it comes to zscript stuff.

The code it self is working, but I have an issues with this line

Code:

%if(%countlist(@weaponQueue>0),%pop(@weaponQueue),#t+ CheckQueue)
#t- CheckQueue


The alias is by itself in the class CheckQueue, and there is a matching trigger that responds to a merchant giving me gold which enables the class, and calls the alias.

I have a problem with the code, currently it will still disable the class regardless of weather there was a pop action. I know its because the #t- clause is after the if statement, but I could not figure out how to have multiple commands within the if clause. What I would like to happen is something like this
Code:

<pseudo code>

if(%countlist(@WeaponQueue>0)
{
    %pop(@WeaponQueue);
    #t- CheckQueue
}
else
{
    <do nothing>
}
_________________
<Clever text here>
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4692
Location: Pensacola, FL, USA

PostPosted: Thu Sep 30, 2010 6:36 pm   
 
its )>0,
not >0),
for the if clause

also, you dont use the @ symbol on the variable in %pop

#NOOP does nothing
_________________
Discord: Shalimarwildcat
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4692
Location: Pensacola, FL, USA

PostPosted: Thu Sep 30, 2010 6:41 pm   
 
Code:
#if (%countlist(@WeaponQueue)>0) {
%pop(WeaponQueue)
#t- CheckQueue
}


that is all you need
_________________
Discord: Shalimarwildcat
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Thu Sep 30, 2010 6:52 pm   
 
Why is there a command that does nothing? Shocked
_________________
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: Thu Sep 30, 2010 7:41 pm   
 
The #NOOP command is a holdover from zMUD days before the introduction of the #CALL command. From the documentation:
Quote:
Does nothing! (Wow, what a powerful command). Actually, it *does* expand its parameters, so its a useful way to execute a function and throw away the result

_________________
Asati di tempari!
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Thu Sep 30, 2010 7:48 pm   
 
Ah, okay. I assumed #CALL was a part of zMUD as well, which just comes from my lack of experience with zMUD (which is unfortunate since most of my MUD is stuck on zMUD, leaving me unable to help them in a lot of circumstances).
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
complex
Apprentice


Joined: 12 Apr 2004
Posts: 134
Location: USA

PostPosted: Thu Sep 30, 2010 8:21 pm   
 
Thank you!

I did not realise that you could leave the else clause blank. Does it matter of the lists are not in the same base class as the alias that is calling them?
_________________
<Clever text here>
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Thu Sep 30, 2010 8:32 pm   
 
They do not need to be, no.
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
complex
Apprentice


Joined: 12 Apr 2004
Posts: 134
Location: USA

PostPosted: Fri Oct 01, 2010 4:42 am   
 
Still working on the sell script I...

I need to match two pattern types

sword of the hero
(10) sword of the here

So I made this trigger
Code:

<trigger id="64">
  <pattern>(%d)*({@WeaponList})</pattern>
  <value>#LOO %1{
  #VAR SellQueue %addItem(@SellWeaponCMD.%2,@SellQueue)
}</value>
</trigger>


There are a few problems with it though.
First it matches perfectly every time, but the loop command messes everything up. I edit my scripts in the package editor and I see # infront of some commands, and % infront of others. At first I thought # was the command to enter from the command line, and % from the package editor.

Also I am not sure that I need to have #VAR SellQueue called every time I want to add an item to the queue, but when I take it away, for what ever reason the command %addItem(@SellWeaponCMD.%2,@SellQueue) just spits the command out, and does not add the item.

Suggestions?
_________________
<Clever text here>
Reply with quote
complex
Apprentice


Joined: 12 Apr 2004
Posts: 134
Location: USA

PostPosted: Fri Oct 01, 2010 5:09 am   
 
Never mind I figured it out * Maybe not, that does not add the items to the list for some reason.

Code:

<trigger type="Loop Expression" id="64">
  <pattern>(%d)*({@WeaponList})</pattern>
  <value>#LOOP %1 {
  SellQueue = %addItem(@SellWeaponCMD.%2,@SellQueue)
}</value>
</trigger>
_________________
<Clever text here>
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Fri Oct 01, 2010 6:03 am   
 
Try using %db() instead of the dot syntax of @dbvar.key
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
complex
Apprentice


Joined: 12 Apr 2004
Posts: 134
Location: USA

PostPosted: Fri Oct 01, 2010 3:24 pm   
 
That did not work, but the problem was that I changed the trigger type into a loop expression, so I never tried to match the text. It occurred to me that I probably do not need to created a class for each item that I want to toggle, and instead just toggle that specific item. But how do you toggle complex trigger names?

#-t (%d)*({@ArmorList})

does not get the job done, but

#t- emptyQueue does.
_________________
<Clever text here>
Reply with quote
Zugg
MASTER


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

PostPosted: Fri Oct 01, 2010 4:29 pm   
 
You need to give the complex trigger a short ID name. You'll find the ID name field in the trigger editor if you click the More button to show the option panel at the bottom of the editor. Then you can use the ID name in the #T- command.
Reply with quote
complex
Apprentice


Joined: 12 Apr 2004
Posts: 134
Location: USA

PostPosted: Fri Oct 01, 2010 9:25 pm   
 
Excellent that worked like a charm!
_________________
<Clever text here>
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD 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