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
ronfar_74@hotmail.com
Beginner


Joined: 30 Aug 2006
Posts: 10

PostPosted: Thu Apr 14, 2016 4:55 am   

Threads
 
I've been trying to make a tick timer for the mud I play using an alarm, but i've notice when moving quickly such as a speed path the alarm stalls till finish and I been trying to figure out how to use the #thread command to make it work or if it possible here's what I've made in an attempt.

pattern
(You cough and choke from the diseased gasses wafting through the air.|You cough and choke from the toxic gasses wafting through the air.|A sudden\, strong gust of wind knocks you to the ground\!|The current pulls you along to the (.+)\.\.\.|A sudden torrent of lava sweeps you the (.+)\.|Your stomach rumbles\.|Your throat feels parched\.|(You are|(.+) is) buffeted to the (.+) by crosswinds\!|You shiver and suffer from the poison burning within\.|(.+) shivers and suffers\.|(You struggle|(.+) struggles) (.*)against the webs which hold (.+) in place\.|You turn pale and shudder as dark magic burns away some of your life force\.|(.+) turns pale and shudders\.)

script text
#var tick 14
#thread "tick" {
#alarm tickTimer {+1} {
#add tick -1
#if (@tick==-1) {#var tick 14}
}}

tick's are every 15 seconds, and only way to know a tick happened for sure is those lines in the pattern
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4671
Location: Pensacola, FL, USA

PostPosted: Thu Apr 14, 2016 12:17 pm   
 
I don't think you need to use #THREAD for this.
It is intended for more complex code, and coders who understand threading in general.
Usually something that might otherwise hang the system.

Also, your alarm is not using the best syntax:

#alarm "tickTimer" +1 {
#add tick -1
#if (@tick==-1) {#var tick 14}
}

But that may be unneeded altogether.
The client has an inbuilt tick timer system.
You could change the script text to:
#TS

Then make use of the #TIMER command to set what happens on the tick.
#HELP #TIMER
_________________
Discord: Shalimarwildcat
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Sat Apr 16, 2016 6:44 am   
 
I figured I would help your regex out some:
(?:Your stomach rumbles\.|Your throat feels parched\.|You cough and choke from the (?:diseased|toxic) gasses wafting through the air\.|A sudden, strong gust of wind knocks you to the ground!|The current pulls you along to the \w+\.\.\.|A sudden torrent of lava sweeps you the \w+\.|\w+ (?:are|is) buffeted to the \w+ by crosswinds!|You shiver and suffer from the poison burning within\.|\w+ (?:shivers and suffers|turns pales and shudders)\.|\w+ struggles? .*against the webs which hold \w+ in place\.|You turn pale and shudder as dark magic burns away some of your life force\.)

Switching to the timer as shalimar suggested is easiest.

If you choose to stay with an alarm then you will want to create a permanent alarm by putting the following in the command line:
#VAR tick {-1} {-1}
#ALARM "tickTimer" {-1} {#ADD tick -1;#IF (!@tick) {tick=15}}

Note that the time pattern is -1 so that the alarm will only be active while you are online. You should also locate the variable tick in a class that is reset to default upon connection. The use of -1 as the default value keeps the alarm from thinking it got a tick until your trigger properly detects the alignment.

In the trigger you would put:
tick=15
#CALL %alarm("tickTimer",1000)

If your trigger only aligns the tick and does not need to respond to any of those messages, then you can also disable that trigger when it fires. You want to enable it when connecting to the mud so that it can properly align your timer. See #EVENT
_________________
The only good questions are the ones we have never answered before.
Search the Forums
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