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
nduval
Beginner


Joined: 06 Sep 2006
Posts: 10

PostPosted: Tue Aug 12, 2008 6:05 pm   

Sort of trigger question.
 
I have *very* limited experience using cmud, so keep that in mind when answering :P I capture things on my screen, the only way I know how, to make variables with them. For example, I have my HP Bar like this:

[MOB:None] [GXN:57678] [WPN:Unmarred] [ES:0] [LR:0%] (from the MUD)
And I capture it like this:
~[MOB~:(&enemystatus)~] ~[GXN~:(&g2n)~] ~[WPN~:(&weaponcondition)~] ~[ES~:(&esquires)~] ~[LR~:(&lightremaining)~%~]

So, each round of combat, my @g2n changes (the number goes down). What would be an easy way to capture in another variable the amount that the variable changed since the last update?

Thanks for your help!
Reply with quote
Toxic
Adept


Joined: 27 May 2008
Posts: 299

PostPosted: Tue Aug 12, 2008 6:49 pm   
 
Code:

<trigger priority="770" id="77">
  <pattern>~[MOB~:(*)~] ~[GXN~:(*)~] ~[WPN~:(*)~] ~[ES~:(*)~] ~[LR~:(*)~%~]</pattern>
  <value>#LOCAL $temp
enemystatus = %1
weaponcondition = %3
esquires = %4
lightremaining = %5
$temp = %2
#MATH timediff (@g2n-$temp)
g2n = $temp
#SHOW @timediff</value>
</trigger>
Reply with quote
nduval
Beginner


Joined: 06 Sep 2006
Posts: 10

PostPosted: Tue Aug 12, 2008 7:24 pm   
 
I do appreciate the reply, but if it is possible to explain this another way that would help a lot. I don't know how to create things via XML, and further, that changes the way my trigger is setup entirely. Using what I do currently, how might I do this using what you just told me? =)

I have a button that I use to show @g2n. I wanted it to be like @g2n (@timediff)

Could you tell me what to simply enter into the script text under my existing trigger pattern?
Reply with quote
Toxic
Adept


Joined: 27 May 2008
Posts: 299

PostPosted: Tue Aug 12, 2008 7:41 pm   
 
Its impossible to do under your current trigger pattern... You would need to switch to something like mine. It works in all the same ways, it just allows you to manipulate the data before its stored to the g2n var, which is what your asking for.
Reply with quote
Zugg
MASTER


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

PostPosted: Tue Aug 12, 2008 7:41 pm   
 
Whenever someone posts XML like this, just copy all of it and then open the Settings Editor in CMUD and right-click on the Tree view on the left and select Paste (or select Edit/Paste from the menu).

The advantage of pasting the XML is that you get all of the fields and options for the trigger all at once. But if you want to understand more of what you are doing, the stuff between the "pattern" XML tags goes into the Pattern field for the trigger, and the stuff between the "value" XML tags goes into the script Value for the trigger.
Reply with quote
nduval
Beginner


Joined: 06 Sep 2006
Posts: 10

PostPosted: Tue Aug 12, 2008 8:20 pm   
 
If either of you have a chance to answer one more on this... Usually here people always post suggestions like above, using * / * etc then naming each variable like %1 %2. I define my variable names inside the trigger pattern... Am I at some sort of disadvantage doing it this way?
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Thu Aug 14, 2008 5:09 pm   
 
Not a disadvantage, exactly. That is a perfectly fine way to do basic captures into variables. However, there are some things that you can't do that way, or at least not as easily as you can other ways. For instance, to do what you wanted in your first question, using direct capture in the trigger, you would need another permanent variable to hold the former value. With the method Toxic demonstrated, you use a local variable instead. Actually, it could be done without a local variable at all, but I prefer Toxic's method, assigning %2 to a local variable before doing any calculations.

Another good reason to use Toxic's method is that, if you don't need to retain the captured values between triggerings, you can use local variables instead. This will be slightly faster, make loading and saving the package faster, and reduce the clutter of variables in your package.
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