|
Delrayne Beginner
Joined: 01 Feb 2008 Posts: 16
|
Posted: Fri May 06, 2011 7:19 am
Gauged Timer |
I had one for zMud, but of course I lost it....can't figure it out in Cmud...I've tried searching, but can't get anything to work...Basically I want a timer that counts down from 20 minutes and displays it via a gauge.. I appreciate and all help given. Thank you for your time.
|
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4690 Location: Pensacola, FL, USA
|
Posted: Fri May 06, 2011 4:23 pm |
This should do it for you.
Code: |
<class name="CountDown" id="1243">
<func name="timeConvert" id="1239">
<value>$minutes=($time/60)
$seconds=($time-($minutes*60))
#IF (%len($seconds)=1) {$seconds=%concat("0", $seconds)}
$endTime=%concat($minutes, ":", $seconds)
#RETURN $endTime</value>
<arglist>$time</arglist>
</func>
<var name="time" id="1240">1006</var>
<trigger name="CountDowner" type="Alarm" priority="12440" id="1244">
<pattern>-1</pattern>
<value>time=(@time-1)</value>
</trigger>
<button type="Gauge" autosize="false" width="60" height="23" color="yellow" gaugelowcol="red" gaugebackcol="#ECE9D8" priority="12460" id="1246">
<caption>@timeConvert(@time)</caption>
<expr>@time</expr>
<gaugemax>1200</gaugemax>
<gaugelow>0</gaugelow>
</button>
</class>
|
This provides everything except a means to restore the time to 20 minutes
time=(60*20) |
|
_________________ Discord: Shalimarwildcat |
|
|
|
oldguy2 Wizard
Joined: 17 Jun 2006 Posts: 1201
|
Posted: Fri May 06, 2011 5:27 pm |
Well...I don't think yours works Shalimar. You have to update the display somehow and call that function.
Here is a sort of complicated version of a countdown timer that you can enter whatever minutes you want or up to 60 seconds.
Code: |
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
<class name="Countdown" copy="yes">
<button name="btnTimer" type="Gauge" autosize="false" width="100" height="20" toolstyle="true" color="green" textcolor="white" border="silver" priority="40" copy="yes">
<caption>@timerDisplay</caption>
<expr>(@timerMinutes * 60) + @timerSeconds</expr>
<gaugemax>@timerMax</gaugemax>
</button>
<trigger name="CountdownTimer" type="Alarm" priority="10" enabled="false" copy="yes">
<pattern>*1</pattern>
<value>#if (@timerMinutes == 0 && @timerSeconds == 0) {
#T- CountdownTimer
}
#if (@timerSeconds < 1) {
timerMinutes = @timerMinutes - 1
timerSeconds = 59
}
timerDisplay = @DisplayTime()
timerSeconds = @timerSeconds - 1</value>
</trigger>
<var name="timerDisplay" type="Literal" copy="yes">00:00</var>
<var name="timerMinutes" usedef="true" copy="yes">0</var>
<alias name="StartCountdownMin" copy="yes">
<value>#if ($minutes == %null) {AdjustMinutes 1} {AdjustMinutes $minutes}
timerSeconds = 0
timerDisplay = @DisplayTime()
#T+ CountdownTimer</value>
<arglist>$minutes</arglist>
</alias>
<var name="timerSeconds" usedef="true" copy="yes">0</var>
<func name="DisplayTime" copy="yes">
<value>#if (@timerMinutes < 0) {
timerMinutes = 0
timerSeconds = 0
}
#return %concat(%if(@timerMinutes > 0,@timerMinutes,%concat(0,@timerMinutes)),":",%if(@timerSeconds > 9,@timerSeconds,%concat(0,@timerSeconds)))</value>
</func>
<alias name="StopCountdown" copy="yes">
<value>#T- CountdownTimer
timerMinutes = 0
timerSeconds = 0
timerDisplay = "00:00"</value>
</alias>
<alias name="ResumeCountdown" copy="yes">
<value>#T+ CountdownTimer</value>
</alias>
<alias name="AdjustMinutes" copy="yes">
<value>#if ($value > 60) {
timerMinutes = 59
timerMax = (60 * 60)
} {
#if ($value < 0) {
timerMinutes = 0
} {
timerMinutes = $value
timerMax = ($value * 60)
}
}
timerSeconds = 0</value>
<arglist>$value</arglist>
</alias>
<var name="timerMax" usedef="true" copy="yes">120</var>
<alias name="PauseCountdown" copy="yes">
<value>#T- CountdownTimer</value>
</alias>
<alias name="StartCountdownSec" copy="yes">
<value>#if ($seconds == %null) {AdjustSeconds 1} {AdjustSeconds $seconds}
timerMinutes = 0
timerDisplay = @DisplayTime()
#T+ CountdownTimer</value>
<arglist>$seconds</arglist>
</alias>
<alias name="AdjustSeconds" copy="yes">
<value>#if ($value > 60) {
timerSeconds = 60
timerMax = 60
} {
#if ($value < 0) {
timerSeconds = 0
} {
timerSeconds = $value
timerMax = $value
}
}
timerMinutes = 0</value>
<arglist>$value</arglist>
</alias>
</class>
</cmud>
|
To start a countdown of 20 minutes just enter "StartCountdownMin 20".
Edit: What I meant to say is you can enter whatever you want for minutes up to 60 minutes OR do a seconds countdown up to 60 seconds. It doesn't include hours. |
|
|
|
Delrayne Beginner
Joined: 01 Feb 2008 Posts: 16
|
Posted: Fri May 06, 2011 7:19 pm |
error: File: . Line:14 Col: 21 Error: Invalid element name:"
on yours oldguy |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4690 Location: Pensacola, FL, USA
|
Posted: Fri May 06, 2011 9:50 pm |
I actually made the stuff in cmud, it works fine here.
|
|
_________________ Discord: Shalimarwildcat |
|
|
|
Delrayne Beginner
Joined: 01 Feb 2008 Posts: 16
|
Posted: Fri May 06, 2011 10:35 pm |
Just got it working! thanks for the help guys/gals
|
|
|
|
oldguy2 Wizard
Joined: 17 Jun 2006 Posts: 1201
|
Posted: Sat May 07, 2011 5:49 am |
Delrayne wrote: |
error: File: . Line:14 Col: 21 Error: Invalid element name:"
on yours oldguy |
That's funny. It has no syntax errors. Not sure where that comes from. |
|
|
|
DraxDrax Apprentice
Joined: 22 Mar 2009 Posts: 149
|
Posted: Sat May 07, 2011 7:02 am |
oldguy2 wrote: |
Delrayne wrote: |
error: File: . Line:14 Col: 21 Error: Invalid element name:"
on yours oldguy |
That's funny. It has no syntax errors. Not sure where that comes from. |
When you copy/paste the XML to the forums, the less than and greater than characters (< and >) are converted to < and > When you post the script here, the forums converts < and > back to < and > That's what's causing the problem. For the XML to import properly, the script needs to be posted to the forums with the < and > codes intact. |
|
|
|
|
|