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


Joined: 16 Oct 2005
Posts: 22
Location: Canada

PostPosted: Wed Dec 15, 2010 4:11 am   

#ALARMs
 
OK it seems I have created some #ALARMs but cannot get rid of them or delete them.

Alarms:
-10:00 -> #SAY -=-=-= TRAINING OVER =-=-=- [in 44 secs]
5 -> #SAY "HELLO" [in 4 secs]
1 -> [in 1 secs]


How do I remove these alarms if I never set an ID or anything for them? I've quit CMUd and such but nothing. They still appear and execute over and over :(
Reply with quote
Gimli
Beginner


Joined: 16 Oct 2005
Posts: 22
Location: Canada

PostPosted: Wed Dec 15, 2010 4:16 am   
 
Omg I'm retarded...

#ALARMS are placed into the Triggers...

Wonder why I couldn't find that before....
Reply with quote
Anrok
Apprentice


Joined: 19 Nov 2010
Posts: 119

PostPosted: Thu Dec 16, 2010 9:16 am   
 
I have a question about alarms too and i dont want to create another topic.

I use a bunch of separate 1 second alarms to calculate remaining spell and skill times every second once i activate a spell or a skill. This alarm would look something like this and i would have up to 5 of them at any given time
Code:
#alarm spellname {1} {#math spellname (@spellname-1)}
That alarm is destroyed once the spell expires.

Is it easier on cmud to create alot of separate alarms like this for each spell when its active, or have 1 main alarm executing every {1} second with a few #IF's inside to check for active spells - something like
Code:
#alarm main {1} {#SW (@spell1>0) {#math spell1 (@spell1-1)} (@spell2>0) {#math spell2 (@spell2-1)} (@spell3>0) {#math spell3 (@spell3-1)}}


Or is it best to just set my tick timer to 1 second and run this script through tick timer ?
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Thu Dec 16, 2010 4:48 pm   
 
I'm inclined to say it's best to have one alarm. You avoid the overhead of processing several alarms and destroying and recreating them.

I would use several #IFs instead of a single #SWITCH that you have in your example. In your example, if multiple spells expire, only one will register.
_________________
Asati di tempari!
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Thu Dec 16, 2010 11:56 pm   
 
Events are an option, too.

#alarm -1 {#raise onSecond}

Code:
#event "evtBlind" onSecond {
  #if (@blind <= 0) {
    Blind = 0
    #t- evtBlind event
  } {
    #add Blind -1
  }
}
_________________
EDIT: I didn't like my old signature
Reply with quote
Anrok
Apprentice


Joined: 19 Nov 2010
Posts: 119

PostPosted: Wed Dec 29, 2010 7:35 pm   
 
Hey again guys, new question on a related topic. Now that i have a single #alarm that does an #IF check for an activated spell to calculate a value from it i ended up with a huge list of #IF's. Since all those spells and their times are in one database variable, would it be better to use #loopdb function instead ? Could anyone tell me if a list of #IF checks is worse/better than using #loopdb.

A simple example of the script is.

@spelllist is a dbvar with about 20 spells and their times, but only a few of them are active at a time.

Code:

#alarm "spellchecker" {1} {#if (@spelllist.1!="off") { do some math };#IF (#if (@spelllist.2!="off") { do some math };#if (@spelllist.3!="off") { do some math }} ...etc untill @spelllist.20


I know i can replace that script with

Code:

#alarm "spellchecker" {1} {#loopdb @spelllist {#if (%val!="off") { do some math }}


This saves me alot of trouble as i dont have to add extra slots if i want more spells, however i was slightly worried about spamming my CMUD with #loopdb every second.

Because only about 5 spells of those 20 are active at one time, with my huge list of #IF's CMUD has to work only 5 of them at a time while others are discarded because they are set to "off", so it didnt seem too bad. Would the second script load my CMUD much more because it has to #loop through all the database keys and values ?
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Wed Dec 29, 2010 11:38 pm   
 
With just 20 keys, it probably doesn't matter. However, why not use events? With events, there's no need for #LOOPDB or your #IF check and thus your script will be faster (but like I said, it so small that even if it were a slow and inefficient script it probably wouldn't matter.)

Code:
#trigger {whatever pattern indicates the spell effect happened} {
  #T+ evtEventForThisSpell event
  varTimerVariableForThisSpell = whatever value you would set it to
}

//Dunno where the event ID goes in the #event command syntax
#event onSpellDurationDecrement {
  #if (@varTimerVariableForThisSpell > 0) {#add varTimerVariableForThisSpell -1} {#T- evtEventForThisSpell event}
  anything else you want to do
}

#alarm -1 {#raise onSpellDurationDecrement}
_________________
EDIT: I didn't like my old signature
Reply with quote
Anrok
Apprentice


Joined: 19 Nov 2010
Posts: 119

PostPosted: Wed Dec 29, 2010 11:52 pm   
 
Hmm i didnt use it because i never knew about it, will read some helpfiles on it, thanks : )
Reply with quote
Anrok
Apprentice


Joined: 19 Nov 2010
Posts: 119

PostPosted: Thu Dec 30, 2010 1:54 am   
 
Hmm, what's the point of #events ? You still have to make a trigger to #raise them. Doesnt #trigger {pattern} {#raise Event} serve the same purpose as #trigger {pattern} {do stuff} ?
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Thu Dec 30, 2010 3:10 am   
 
Events allow you to attach multiple "do stuff" chunks of code to whatever trigger/button/alias/etc raises them, without having to clutter up or otherwise complexify that setting's code. Simpler = faster in CMud, even if the loads and savings in question are too small to matter or perceive.
_________________
EDIT: I didn't like my old signature
Reply with quote
Anrok
Apprentice


Joined: 19 Nov 2010
Posts: 119

PostPosted: Thu Dec 30, 2010 4:07 am   
 
Well, for me personally the complexity comes from using loads of conditionals to define a certain trigger. I.e the { do stuff } command is hidden under alot of #IF's or #SW's, so should i use all those #IF's and #SW's in the main script to #RAISE ? or should i put them all inside the #EVENT ? I see how #events could make my script look neater, but isnt it the same as simply using aliases inside the script ? I tried coding something using it for an hour or so and it did my head in, it takes a bit getting used to, as i've never done that before - i could've made 10 triggers in the time it took me to make a basic event Evil or Very Mad
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Fri Dec 31, 2010 2:16 am   
 
It depend on exactly what you are doing in all your #IF and #SWITCH statements. For instance, one advantage of using events is that you don't have to have all the events enabled at the same time. Say for instance, you have a trigger that raises onPrompt whenever you get a prompt from the mud. You can have a wide set of onPrompt events which do different things, but most of which are disabled except when certain conditions are true--say, enabled when you start combat, or something. This way, you wouldn't have to have a trigger for the prompt which checks a long list of possible conditions, like combat.

There are other cases where it makes more sense to do the #IF and #SWITCH. It all depends.
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