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
Jorville
Wanderer


Joined: 30 Apr 2006
Posts: 58
Location: Brookhaven, MS

PostPosted: Fri May 29, 2009 2:42 am   

trigger to reset toggle buttons
 
is there anyway to have a trigger reset a toggle button without it sending the command?

i got a toggle button to activate and deactivate a skill, but sometimes the mud deactivates it, i want to set a trigger on the message i get when it deactivates to reset my toggle button to off

i can set the trigger up to switch it off but it still send the deactivate command when the button is switched off, and since the command to activate and deactivate the skill is the same, it kinda creates a problem, sp when the trigger switches the button to the off state, it cuts the skill back on

i tried setting up variables for the button states but it ended up just creating a loop that sent the command to the mud over and over

any ideas would be appreciated
_________________
Jorville
Player on SWMUD
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Fri May 29, 2009 3:07 am   
 
Show us your code; copy the XML for the button and the trigger you've created that isn't working right, and paste them inside [code] tags. I don't have an adequate understanding of your setup to suggest a solution just from that description.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Jorville
Wanderer


Joined: 30 Apr 2006
Posts: 58
Location: Brookhaven, MS

PostPosted: Fri May 29, 2009 3:28 am   
 
i had been tinkering with it but i think this is how i had it, when i click the button for on and off it works fine, but if the mud sends the trigger message it starts a loop

ok the button code is like this:

<button type="Toggle" variable="sensedisturbance" autosize="false" width="126" height="23" priority="10" id="1">
<caption>Sense Disturbance Off</caption>
<value>sense disturbance</value>
<state caption="Sense Disturbance On">sense disturbance</state>
</button>

and for the engaged state of the button the xml is:

<button type="Toggle" variable="sensedisturbance" autosize="false" width="126" height="23" priority="10" id="1">
<caption>Sense Disturbance Off</caption>
<value>sense disturbance</value>
<state caption="Sense Disturbance On">sense disturbance</state>
</button>

the triggers are:

<trigger priority="40" enabled="false" id="4">
<pattern>You are no longer sensing disturbances in the Force.</pattern>
<value>sensedisturbance = 0</value>
</trigger>

and

<trigger priority="30" enabled="false" id="3">
<pattern>You are now sensing disturbances in the Force.</pattern>
<value>sensedisturbance = 1</value>
</trigger>
_________________
Jorville
Player on SWMUD
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Fri May 29, 2009 4:36 am   
 
Okay, I think the easiest way will be to add a line to the triggers that does ScriptTriggered=1. Then change the button code to: #if (@ScriptTriggered) {ScriptTriggered=0} {command}

What this'll do is signal when the state change is caused by a trigger; if it is, just reset the flag. If it isn't, then execute the command.

Incidentally, though, it seems that it might be easier to use a single-state button and just change the caption. You could do something like Sense Disturbance %if(@sensedisturbance,On,Off) in the button caption and that'll be it. You only really need to use multiple states when you need a different command for off and on.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Jorville
Wanderer


Joined: 30 Apr 2006
Posts: 58
Location: Brookhaven, MS

PostPosted: Fri May 29, 2009 5:26 am   
 
well there are other buttons im going to make that require diffrent commands so i might as well work it out, i got it now where it wont loop if the mud activates the trigger, but when i toggle the button on it sencds the command twice, and when i toggle it off it sends nothing, if the trigger activates it it switches it where it should go, i tried adding some waitfor commands to reset the variable, because when i turn the skill on i get the message that triggers the triggers also, if that makes sense, taking a couple years break from mudding with zmud and switching to this cmud scripting is blowing my mind, i thought i would remember more, anyway, here is what i got now:

buttons:

<button type="Toggle" variable="sensedisturbance" autosize="false" width="126" height="23" id="1">
<caption>Sense Disturbance Off</caption>
<value>#if (@ScriptTriggered) {ScriptTriggered = 0} {sense disturbance}
#WAITFOR {You are now sensing disturbances in the Force.} {ScriptTriggered = 0}</value>
<state caption="Sense Disturbance On">#if (@ScriptTriggered) {ScriptTriggered = 0} {sense disturbance}
#WAITFOR {You are no longer sensing disturbances in the Force.} {ScriptTriggered = 0}</state>
</button>

and

<button type="Toggle" variable="sensedisturbance" autosize="false" width="126" height="23" id="1">
<caption>Sense Disturbance Off</caption>
<value>#if (@ScriptTriggered) {ScriptTriggered = 0} {sense disturbance}
#WAITFOR {You are now sensing disturbances in the Force.} {ScriptTriggered = 0}</value>
<state caption="Sense Disturbance On">#if (@ScriptTriggered) {ScriptTriggered = 0} {sense disturbance}
#WAITFOR {You are no longer sensing disturbances in the Force.} {ScriptTriggered = 0}</state>
</button>

i think the whole button is covered in that one bit of script, but i'll post it from both sections anyway since i already pasted it


the triggers are:

<trigger priority="40" id="4">
<pattern>You are no longer sensing disturbances in the Force.</pattern>
<value>sensedisturbance = 0
ScriptTriggered = 1</value>
</trigger>

and

<trigger priority="30" id="3">
<pattern>You are now sensing disturbances in the Force.</pattern>
<value>sensedisturbance = 1
ScriptTriggered = 1</value>
</trigger>
_________________
Jorville
Player on SWMUD
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Fri May 29, 2009 4:01 pm   
 
Okay, I've now got a much better understanding of your problem. It seems to me like it works thus:

1) "sense disturbance" toggles whether this ability is on or off.
2) Sometimes it goes off by itself.
3) Sometimes something that isn't the button will make it go on.
4) You want the button's state to reflect the current state of the ability, but
a) not send the command if the state is being changed in response to a message from the MUD and
b) not attempt to change the state if the change was caused by the button being clicked.

Yes?
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Jorville
Wanderer


Joined: 30 Apr 2006
Posts: 58
Location: Brookhaven, MS

PostPosted: Fri May 29, 2009 4:31 pm   
 
im not quite sure i understand what you mean by b, but that is pretty much what im trying to do, 1-4 and a are right on the money
_________________
Jorville
Player on SWMUD
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Fri May 29, 2009 9:59 pm   
 
I mean that when you click the button, the command is sent, which makes a message which fires the trigger, which changes the variable and sends the command again. That gives you a loop ;)
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Jorville
Wanderer


Joined: 30 Apr 2006
Posts: 58
Location: Brookhaven, MS

PostPosted: Fri May 29, 2009 11:13 pm   
 
yea, thats exactly what im looking for
_________________
Jorville
Player on SWMUD
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