|
Gratch Newbie
Joined: 10 Nov 2001 Posts: 4
|
Posted: Sat Nov 10, 2001 2:26 am
Toggle button help |
I am trying to create a toggle button that when pressed will cast a spell. If the spell is cast successfully the button will stay depressed thus giving me a visual as to which spells are affecting my char. When the spell wears off the button will pop out and be ready to be pressed again to recast the spell.
I am using variables to keep track of the button state. I have put @spell = 1 in the value field of the toggle button which allows a variable set by simple triggers to control the state of my button. Works Great!!!
One Problem though. When I initially press the button it casts the spell. If successful the spell gets cast again and waisting precious mana. How can I keep the spell from being cast the same spell a second time if successful without losing any functionality in my button. Any help would be greatly appreciated. Thanks in advance. |
|
|
|
Acaila Apprentice
Joined: 30 Aug 2001 Posts: 187 Location: Netherlands
|
Posted: Sat Nov 10, 2001 12:32 pm |
Sounds to me like you have 2 triggers acting on the same mud output. Better check if you have something else set up besides the button which also fires. If not, could you post the code of your button so we can see if there's anything wrong with that?
Acaila |
|
|
|
Gratch Newbie
Joined: 10 Nov 2001 Posts: 4
|
Posted: Sat Nov 10, 2001 2:10 pm |
I know why the spell gets cast twice. I just don't know a suitable workaround.
Variable created: invis
Toggle Button Button up state. Script Value: cast invis
Toggle Button down state: Just changed the color values.
Toggle Button Advanced tab. Value: @invis = 1
When the button initially gets pressed the spell invis is cast but the button immediately changes state to button up because of the @invis = 1 in the advanced tab, Which controls the button state up or down. 0=up, 1=down. I only cast the spell and did not change the variable... yet.
Even though the toggle button was pressed the button will show the up state. Thats what I want.
Two triggers actually control the button's state
#TRIG1 {You fade out of exsistance} {@invis = 1}
#TRIG2 {You are no longer invisable} (@invis = 0}
With the button just being pressed, button shows state as up, the spell was cast. Trigger catches a successful spell cast, changes @invis value to 1 thus changing the button's state to down. Problem is at that point the spell is recast. I don't want it recast if the spell is successful. I just want the buttons state to change.
I'm not sure how else to explain this. Appologies if its not clear. I'm using zMud ver 6.16. What I want is a button that when pressed will cast a spell but stay up. If the spell is cast successfully I want the button to appear to be pressed in thus giving me a visual as to what spells are affecting me. All works perfect except that the same spell ends up getting cast twice on a successful cast. |
|
|
|
Humpton Apprentice
Joined: 10 Oct 2000 Posts: 158 Location: Chicago, IL
|
Posted: Sat Nov 10, 2001 2:48 pm |
It's early Saturday morning, but how about.
Press the button, spell is attempted, state changes to down.
Two triggers.
One is the fail message. Set the state to back up.
The other is the wear off message. Set the state back up.
And, I guess you can have the button turn the spell off if you click it again?
Therefore, if you fail, the button will pop straight back up, and take a bit longer as you wait for the spell to turn off.
I don't think much code is needed, and perhaps I can come up with it later.
Stay JOLLY!
H
___
Humpton lives like he types.... fast, and full of mistakes!
Core 2651: For those who prefer the future to the past. |
|
|
|
Gratch Newbie
Joined: 10 Nov 2001 Posts: 4
|
Posted: Sat Nov 10, 2001 3:12 pm |
I thought of that but i figured it would be much easier to detect a successful cast than an unsuccessful cast. And what if i press, lets say, 3 buttons real fast one after another. Won't keeping track of unsuccessful casts, and spells they belong to, be a royal pain? Furthermore there are many different lines of text that can be produced from the mud for an unsuccessful cast and only 1 for a successful cast.
You give me an idea though. I could set a timer to look for a successful trigger. If no successful trigger in a certain amount of time then button = up.
I'll try that.
Thanks for the thought |
|
|
|
Acaila Apprentice
Joined: 30 Aug 2001 Posts: 187 Location: Netherlands
|
Posted: Sat Nov 10, 2001 4:35 pm |
This may be a little far-fetched, but bear with me.
What you can do is make 2 buttons, the first being the one you push to cast the spell, the second to keep track of whether that spell is still active or not (by kepping track of the variable). Put them in seperate classes so you can turn them off.
To say it step by step:
1) You push button Invis1: It casts spell invisibility, turns on the class with button Invis2, and turns itself off.
2) Button Invis2 checks if you succesfully cast the spell (then it gets pushed down) or failed (turns itself off, and turns class for Invis1 back on)
3) Now when invis wears off, the Invis2 button get disabled again, and Invis1 reappears.
Just a thought
Acaila |
|
|
|
Gratch Newbie
Joined: 10 Nov 2001 Posts: 4
|
Posted: Sat Nov 10, 2001 6:21 pm |
I seem to have found a suitable fix.
I changed the value in the button up state from:
cast invis
to:
cast invis
#WA
Walla!!!! I think it makes the button not trigger its state until there is activity in the main mud window which is usually the result of the spell being cast. No more double casting. I think this is just a temp fix as if anything else comes through the mud that is not the response to the spell being cast could throw things off a little bit.
Thank a lot to both of you for helping me out withthis. Hoopefully I can return the favor someday. |
|
|
|
|
|