trying to change over my root counter from cmud to mush

Posted by Dragonlord on Fri 26 Feb 2016 10:05 PM — 2 posts, 12,520 views.

#0
#class {Maleficarum Counter}

TotalRoots is a variable and %d is the total amount of roots I am carrying at my rootbags, and trunks.

The triggers are for after battles and scatters roots that gathered.

The #ST is my status bar display

At this moment I have 3 trunks and 2 rootbag, and the way I have to do the put roots into the containers are like so

put all.malef seven
put all.malef 2.seven
put all.malef trunk
put all.malef 2.trunk
put all.malef 3.trunk

in cmud I was able to

{i}.seven
{i}.trunk


#VAR TotalRoots %d

#TRIGGER {You take (%d) of a maleficarum root from the corpse} {#AD TotalRoots %d}

#TRIGGER {You take a maleficarum root from the corpse};#AD TotalRoots 1

#TRIGGER {A gnarled and blackened root is on the ground.};#AD TotalRoots 1

#ST {Roots gathered: @TotalRoots}

#Class 0

any help would be vary helper
thanks
Australia Forum Administrator #1
To get you started, here is one of the triggers converted:


<triggers>
  <trigger
   enabled="y"
   match="A gnarled and blackened root is on the ground."
   send_to="12"
   sequence="100"
  >
  <send>

SetVariable ("TotalRoots", (tonumber (GetVariable ("TotalRoots")) or 0) + 1)

SetStatus ("Roots gathered: ", GetVariable ("TotalRoots"))

</send>
  </trigger>
</triggers>



Template:pasting
For advice on how to copy the above, and paste it into MUSHclient, please see Pasting XML.



GetVariable ("TotalRoots") gets you the variable contents. Since that is a string, to add to it you need to convert it to a number with tonumber.

The very first time, when the variable doesn't exist yet, you will get nil. Saying "or 0" substitutes zero in that case.

Then we add 1 to it, and put the result back into "TotalRoots".