|
Rebel Novice
Joined: 29 Oct 2007 Posts: 33
|
Posted: Wed Dec 31, 2008 10:34 am
First button - how do I add a timer to it? |
I have a command - "Thump", that I can use, and then I have to wait 60 seconds before I can use it again.
This seems a good use for a button - I would appreciate advice on how to make such a button work.
Ideally I think the button should change colour after the time period is up so that I know I can use that command again.
Is this possible? |
|
|
|
Qaiia Wanderer
Joined: 06 Apr 2007 Posts: 59
|
Posted: Wed Dec 31, 2008 1:50 pm |
Code: |
<button name="ThumpButton" transparent="false" color="navy" textcolor="white" priority="1510" id="151">
<caption>Thump!</caption>
<value>#SENDRAW {thump}
#SHOW "Thumping!"
#CALL %btnenable(ThumpButton,0)
#CALL %btncol(ThumpButton, black, grey)
#ALARM +60 {
#CALL %btnenable(ThumpButton,1)
#CALL %btncol(ThumpButton, white, navy)
#SHOW "Thumping enabled!"
}</value>
</button> |
|
|
|
|
calesta Apprentice
Joined: 07 Dec 2008 Posts: 102 Location: New Hampshire, USA
|
Posted: Wed Dec 31, 2008 1:55 pm |
You could do something like this:
Code: |
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
<button name="BtnThump" priority="10" copy="yes">
<caption>Thump</caption>
<value>#show Thumping
#call %btnenable(BtnThump,0)
#alarm +60 {
#show Can thump again
#call %btnenable(BtnThump,1)
}</value>
</button>
</cmud>
|
You should just be able to copy that XML and paste it into the package editor to see what the button looks like. |
|
|
|
Qaiia Wanderer
Joined: 06 Apr 2007 Posts: 59
|
Posted: Wed Dec 31, 2008 2:03 pm |
Heh, you could combine both of these for the dynamic button coloring as well as on-screen messaging.
edit: change my code posting to add on-screen messaging. |
|
|
|
Rebel Novice
Joined: 29 Oct 2007 Posts: 33
|
Posted: Wed Dec 31, 2008 2:17 pm Ermmm - where do I begin |
If I copy your code - can you tell me where I put it in the Package Editor?
I create a new button....then what?
Sorry to seem so stupid - thanks for all your help |
|
|
|
Qaiia Wanderer
Joined: 06 Apr 2007 Posts: 59
|
Posted: Wed Dec 31, 2008 2:20 pm |
Create a new button, then click the XML tab at the bottom and copy the XML above into the text editor and save it.
Be sure to get the most recent copy that I posted, I made a couple minor changes. |
|
|
|
Qaiia Wanderer
Joined: 06 Apr 2007 Posts: 59
|
Posted: Wed Dec 31, 2008 2:21 pm |
Oh, you may have to go into the button options tab to tell it which toolbar to display on.
|
|
|
|
Rebel Novice
Joined: 29 Oct 2007 Posts: 33
|
Posted: Wed Dec 31, 2008 3:12 pm |
hmm - can't get button color to have any effect - %btncol seems to do nothing when i call it
Any ideas? |
|
|
|
Qaiia Wanderer
Joined: 06 Apr 2007 Posts: 59
|
Posted: Wed Dec 31, 2008 3:27 pm |
You shouldn't have a problem if you paste in the code I posted above... it works just fine.
edit: Never mind, I guess you can't #CALL two functions inline... I added two more #CALL commands to perform the button coloring. See if that works.
The button should change color back to the original color when the #ALARM is up anyway. |
|
|
|
Rebel Novice
Joined: 29 Oct 2007 Posts: 33
|
Posted: Wed Dec 31, 2008 3:51 pm |
Many thanks - fine now
|
|
|
|
|
|