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
Ambelghan
Novice


Joined: 04 Apr 2010
Posts: 49

PostPosted: Mon Apr 05, 2010 5:16 am   

Trouble with the my alarm using the proper time.
 
Alarm Code


Code:
<class name="RTGauge" id="96">
  <trigger name="RTGaugeAlarm" type="Alarm" priority="1000" enabled="false" id="100">
    <pattern>1</pattern>
    <value>#IF (@roundchange>0) {roundchange=@roundchange-1}  {#T- RTGaugeAlarm}
</value>
  </trigger>
  <var name="rt" id="106">17</var>
  <button type="Gauge" autosize="false" width="60" height="25" autopos="false" color="#800040" textcolor="#FF8080" priority="1070" id="107">
    <caption>rt: @roundchange</caption>
    <expr>@roundchange</expr>
    <gaugemax>@rt</gaugemax>
    <gaugelow>0</gaugelow>
  </button>
  <var name="roundchange" id="109">0</var>
  <trigger type="GSL" priority="9" id="113">
    <pattern>Q</pattern>
    <trigger name="q1" type="GSL">
      <pattern>q</pattern>
      <value>roundchange = (%gsl(Q)-%gsl(q))
rt = (@roundchange + 1)
#T+ RTGaugeAlarm
</value>
    </trigger>
  </trigger>
</class>


It is basically a #Trigger Q "gsl" with a #COND q "gsl" that does
Code:
roundchange = (%gsl(Q)-%gsl(q))
rt = (@roundchange + 1)
and a 1 sec alarm that counts down from roundchange

Appraise my stuff

Code:
<class name="InventoryApp" id="80">
  <trigger priority="810" id="81">
    <pattern>InventoryAppStart</pattern>
    <value>i</value>
    <trigger>
      <pattern>You are wearing %1</pattern>
      <value>#VAR baselist %1
baselist=%replace(@baselist,", ","|")
baselist=%replace(@baselist, ".",)
baselist=%replace(@baselist,"a ",)
baselist=%replace(@baselist,"and ",)
a=0
#VAR finallist {}
#FORALL @baselist
{
  a=@a+1
  finallist=%additem((%item(%replace(%i," ",|),%numitems(%replace(%i," ",|)))),@finallist)
}
#ECHO InventoryAppParse
a=0</value>
    </trigger>
  </trigger>
  <trigger priority="1280" id="128">
    <pattern>InventoryAppParse</pattern>
    <value>#IF (%numitems(@finallist)==0) {#ECHO InventoryAppDone;#T- InventoryAppAlarm} {app my %item(@finallist,1) careful;#T+ InventoryAppAlarm;finallist = %delitem(%item(@finallist,1),@finallist)} </value>
  </trigger>
  <trigger name="InventoryAppAlarm" priority="1300" enabled="false" id="130">
    <pattern>Roundtime:</pattern>
    <trigger type="Alarm" enabled="false">
      <pattern>@rt</pattern>
      <value>#ECHO InventoryAppParse
#T- InventoryAppAlarm</value>
    </trigger>
  </trigger>
</class>


Basically I #ECHO InventoryAppStart to have the system look at my character, then it takes the items and parse them into a list that the system can use. It echos out InventoryAppParse

Code:
#IF (%numitems(@finallist)==0) {#ECHO InventoryAppDone;#T- InventoryAppAlarm} {app my %item(@finallist,1) careful;#T+ InventoryAppAlarm;finallist = %delitem(%item(@finallist,1),@finallist)}


Which basically checks to make sure the list is full, if it is it appraises it and turns on a trigger that will wait for a "Roundtime:" then steps down to an ALARM that based off the @rt value. When the RT is done it #ECHO InventoryAppParse to start checking the list again.

By itself it works great, but I am a person who likes to break things. So I decided to do a search, which essentially gave me a 6sec roundtime. Then I started this script, the after the first appraisal the system would try to do another in 6 seconds, even thought the gauge variable and the rt variable are accurate, I believe that somehow it is firing before it gets changed, but too fast for it to be reflected in values.

Second:
Code:
<trigger name="InventoryAppAlarm" priority="1300" enabled="false" id="130">
  <pattern>Roundtime:</pattern>
  <trigger type="Alarm" enabled="false">
    <pattern>@rt</pattern>
    <value>#ECHO InventoryAppParse
#T- InventoryAppAlarm</value>
  </trigger>
</trigger>


For some reason when #T- InventoryAppAlarm is left on, it perma turns the trigger off, despite the fact that #T+ InventoryAppAlarm is a part of the InventoryAppParse trigger, which has to fire if there is an appraisal. An appraisal will happen and the InventoryAppAlarm will remain off. Thanks for looking over my code, hopefully I provided enough, clearly, to make it easier for you to help me.
Reply with quote
hogarius
Adept


Joined: 29 Jan 2003
Posts: 221
Location: islands.genesismuds.org

PostPosted: Mon Apr 05, 2010 11:31 am   
 
Since you mention GSL(Q) and GSL(q), this would be for a Simutronics game, correct?

Which one?
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Mon Apr 05, 2010 5:07 pm   
 
In your InventoryAppAlarm trigger, why is the condition a type "Alarm" trigger with pattern "@rt"? An alarm trigger should have a time pattern. Perhaps you meant to use an "Expression" type trigger, with a pattern like "@rt = 0"?

There are a number of things that could be simplified or cleaned up in your code, but this is the only bug that I've noticed so far.
Reply with quote
Ambelghan
Novice


Joined: 04 Apr 2010
Posts: 49

PostPosted: Mon Apr 05, 2010 6:33 pm   
 
Yes it is DragonRealms, sorry
Reply with quote
Ambelghan
Novice


Joined: 04 Apr 2010
Posts: 49

PostPosted: Mon Apr 05, 2010 6:42 pm   
 
I tried that Rahab, now it is doing funny triggers of when it fires that have nothing to do with the actual roundtime, fires before and after.
Reply with quote
Ambelghan
Novice


Joined: 04 Apr 2010
Posts: 49

PostPosted: Mon Apr 05, 2010 7:06 pm   
 
Woot, Rahab, you were right about it that InventoryAppAlarm trigger needing to be an expression, but and the zero thing with @rt would not work cause @rt is static it is the %gsl(Q)-%gsl(q) number, so it never really reaches zero, but @roundchange does! Flipping that in with your change made it actually follow the roundtimes correctly when they changed vales and were not the same time over and over. I have my first functioning script now! One thing that is still bugging me
Code:
<trigger name="InventoryAppAlarm" priority="1300" id="130">
  <pattern>Roundtime:</pattern>
  <value>#ECHO I turned on
</value>
  <trigger type="Expression">
    <pattern>@roundchange=0</pattern>
    <value>#ECHO InventoryAppParse
//#T- InventoryAppAlarm
</value>
  </trigger>
</trigger>

That #T- InventoryAppAlarm turns the zero state off and it stays off, despite InventoryAppParse's ability to turn it on and off at the very first and last run through:
Code:
<trigger priority="1280" id="128">
  <pattern>InventoryAppParse</pattern>
  <value>#IF (%numitems(@finallist)==0)
{
  #ECHO InventoryAppDone
  #T- InventoryAppAlarm
}
{
  app my %item(@finallist,1) careful
  #T+ InventoryAppAlarm
  finallist = %delitem(%item(@finallist,1),@finallist)
} </value>
</trigger>


Also, you said things could be cleaned up, this is literally my third day using this software, so anything you could show me would be helpful, thanks.
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Mon Apr 05, 2010 8:45 pm   
 
Hm. I thought I had a solution (changing the priority of InventoryAppAlarm to less than InventoryAppParse), but now I don't think that's right. I'm not sure what the problem is, but simply removing the #T- from InventoryAppAlarm may be the way to go.

As for cleaning things up, if this is really your third day working with Cmud, you're doing just fine! While your code doesn't take advantage of some more advanced features, especially ones which weren't available in Zmud, the code is fine as it is. If you want to learn some more advanced stuff, you could take a look at Local Variables and Events, both of which were not available in Zmud. Another function you could look at is %pop(). But if you have working code, there's no need to change it unless you want to practice using these more advanced things.
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