|
complex Apprentice
Joined: 12 Apr 2004 Posts: 134 Location: USA
|
Posted: 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> |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4692 Location: Pensacola, FL, USA
|
Posted: 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 |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4692 Location: Pensacola, FL, USA
|
Posted: Thu Sep 30, 2010 6:41 pm |
Code: |
#if (%countlist(@WeaponQueue)>0) {
%pop(WeaponQueue)
#t- CheckQueue
} |
that is all you need |
|
_________________ Discord: Shalimarwildcat |
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Thu Sep 30, 2010 6:52 pm |
Why is there a command that does nothing?
|
|
|
|
Tech GURU
Joined: 18 Oct 2000 Posts: 2733 Location: Atlanta, USA
|
Posted: 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! |
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: 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).
|
|
|
|
complex Apprentice
Joined: 12 Apr 2004 Posts: 134 Location: USA
|
Posted: 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> |
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Thu Sep 30, 2010 8:32 pm |
They do not need to be, no.
|
|
|
|
complex Apprentice
Joined: 12 Apr 2004 Posts: 134 Location: USA
|
Posted: 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> |
|
|
|
complex Apprentice
Joined: 12 Apr 2004 Posts: 134 Location: USA
|
Posted: 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> |
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Fri Oct 01, 2010 6:03 am |
Try using %db() instead of the dot syntax of @dbvar.key
|
|
|
|
complex Apprentice
Joined: 12 Apr 2004 Posts: 134 Location: USA
|
Posted: 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> |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: 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.
|
|
|
|
complex Apprentice
Joined: 12 Apr 2004 Posts: 134 Location: USA
|
Posted: Fri Oct 01, 2010 9:25 pm |
Excellent that worked like a charm!
|
|
_________________ <Clever text here> |
|
|
|
|
|