Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ General
➜ Conflicting Scripts
It is now over 60 days since the last post. This thread is closed.
Refresh page
Pages: 1 2
Posted by
| Traz
(31 posts) Bio
|
Date
| Fri 30 Mar 2018 04:14 AM (UTC) |
Message
| So I've played around a few different ways and I cannot for the life of me figure out why these two scripts can't go off the same line. I've had it happen with other scripts before but I could usually find some compromise. This one is beyond me and I need help. Both were disabled at the time for editing, but when both activated only one works.
<triggers>
<trigger
expand_variables="y"
group="NecroMLOL"
keep_evaluating="y"
match="*[Ki:*]*"
send_to="12"
sequence="99"
>
<send>local pl = @Pl
local half = @MaxPl * .5
local quarter = @MaxPl * .25
local stop = @MaxPl * .3
if lastTriggerTime == nil or os.time () - lastTriggerTime >=1 then
lastTriggerTime = os.time ()
if pl >= half then
Execute ("powd")
end
end</send>
</trigger>
</triggers>
<triggers>
<trigger
expand_variables="y"
group="NecroM"
keep_evaluating="y"
match="[Pl:*][Ki:*]*"
send_to="12"
sequence="98"
>
<send>require "wait"
if @Ki <= 50000 then
if lastTriggerTime == nil or os.time () - lastTriggerTime >= 5 then
wait.make (function ()
lastTriggerTime = os.time ()
Execute ("nmoff")
wait.regexp ("^Blood splatters as (.*?) soul fades away\.$")
wait.time (3)
Execute ("sense half-dead")
wait.time (3)
Send ("--")
Send ("--")
Execute ("senzu")
Send ("gtell sense me")
wait.time (10)
Execute ("nmon")
end)
end
end</send>
</trigger>
</triggers>
| Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #1 on Fri 30 Mar 2018 06:28 AM (UTC) |
Message
| Can you expand this by stating which trigger works?
Also post some example output that these triggers should match on? Then we can set up a test of the problem. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Traz
(31 posts) Bio
|
Date
| Reply #2 on Fri 30 Mar 2018 11:44 AM (UTC) Amended on Fri 30 Mar 2018 11:57 AM (UTC) by Traz
|
Message
| They both work, they just don't work together. Right now, the first one is working when both are activated.
The full line they match on is:
[Pl:688,894][Ki:229,083][3% EXP][Fatigue: 22%][HT][FM][Flying]
When Ki is below 50k, the second one should run. When Pl is more than half, which it is right now, the first one should run to make it less than half. I pull the @MaxKi variable from the score sheet that I have set on a timer every 10 minutes. | Top |
|
Posted by
| Fiendish
USA (2,534 posts) Bio
Global Moderator |
Date
| Reply #3 on Fri 30 Mar 2018 02:03 PM (UTC) Amended on Fri 30 Mar 2018 02:23 PM (UTC) by Fiendish
|
Message
| I see a few potential issues...
1) You're gatekeeping execution on whether lastTriggerTime is nil or some arbitrary time in the past, but the earlier trigger sets lastTriggerTime to the current time, which means that the next one will always be blocked if @Ki < 50000.
2) Arbitrary times in the past are rarely what you actually want to check against.
3) Where is @Ki set?
4) Since both of those triggers run on the same input, they should really just be one trigger with multiple steps. |
https://github.com/fiendish/aardwolfclientpackage | Top |
|
Posted by
| Traz
(31 posts) Bio
|
Date
| Reply #4 on Fri 30 Mar 2018 03:36 PM (UTC) |
Message
| 1) I know of no way around that, it's the only method I have learned thus far
3) @Ki is set to the current prompt, so whatever the ki is at in the prompt I showed, every time a command is entered, it is updated.
4) I'm unsure how to make a script do two different things for different criteria like that. | Top |
|
Posted by
| Fiendish
USA (2,534 posts) Bio
Global Moderator |
Date
| Reply #5 on Fri 30 Mar 2018 05:19 PM (UTC) Amended on Fri 30 Mar 2018 05:21 PM (UTC) by Fiendish
|
Message
|
Traz said:
1) I know of no way around that, it's the only method I have learned thus far
Method for what? You've asked why they don't both work, and I'm telling you at least one reason why they won't both work.
Quote: 3) @Ki is set to the current prompt, so whatever the ki is at in the prompt I showed, every time a command is entered, it is updated.
How many triggers do you have for your prompt line? Please show all of them. So far nothing you've shown sets Ki. |
https://github.com/fiendish/aardwolfclientpackage | Top |
|
Posted by
| Traz
(31 posts) Bio
|
Date
| Reply #6 on Fri 30 Mar 2018 06:58 PM (UTC) Amended on Fri 30 Mar 2018 06:59 PM (UTC) by Traz
|
Message
| Method for making sure a trigger doesn't spam the shit out of me.
These are all the triggers that are active for this group:
<triggers>
<trigger
expand_variables="y"
group="NecroM"
keep_evaluating="y"
match="*[Fatigue: *%]*"
send_to="12"
sequence="100"
>
<send>if @Fatigue >= 40 then
if lastTriggerTime == nil or os.time () - lastTriggerTime >= 30 then
lastTriggerTime = os.time ()
Execute ("drink1")
Execute ("drink2")
end
end</send>
</trigger>
<trigger
expand_variables="y"
group="NecroMLOL"
keep_evaluating="y"
match="*[Ki:*]*"
send_to="12"
sequence="99"
>
<send>local pl = @Pl
local half = @MaxPl * .5
local quarter = @MaxPl * .25
local stop = @MaxPl * .3
if lastTriggerTime == nil or os.time () - lastTriggerTime >=1 then
lastTriggerTime = os.time ()
if pl >= half then
Execute ("powd")
end
end</send>
</trigger>
<trigger
expand_variables="y"
group="NecroM"
keep_evaluating="y"
match="[Pl:*][Ki:*]*"
send_to="12"
sequence="98"
>
<send>require "wait"
if @Ki <= 50000 then
if lastTriggerTime == nil or os.time () - lastTriggerTime >= 5 then
wait.make (function ()
lastTriggerTime = os.time ()
Execute ("nmoff")
wait.regexp ("^Blood splatters as (.*?) soul fades away\.$")
wait.time (3)
Execute ("sense half-dead")
wait.time (3)
Send ("--")
Send ("--")
Execute ("senzu")
Send ("gtell sense me")
wait.time (10)
Execute ("nmon")
end)
end
end</send>
</trigger>
<trigger
enabled="y"
group="Variables"
keep_evaluating="y"
match="[Pl:*][Ki:*]*[*: *%]*"
send_to="12"
sequence="100"
>
<send>pl1 = ("%1")
pl2 = string.gsub (pl1, (","), "")
ki1 = ("%2")
ki2 = string.gsub (ki1, (","), "")
SetVariable ("Pl", pl2)
SetVariable ("Ki", ki2)
SetVariable ("Fatigue", "%5")</send>
</trigger>
</triggers>
| Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #7 on Fri 30 Mar 2018 08:52 PM (UTC) Amended on Fri 30 Mar 2018 08:53 PM (UTC) by Nick Gammon
|
Message
|
and:
So you are trying to match on [Ki:*] possibly preceded by [Pl:*]?
The easiest thing is to make that a regular expression and check for both in one trigger, eg.
See regular expressions for the meaning of those symbols.
Basically:
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Traz
(31 posts) Bio
|
Date
| Reply #8 on Sat 31 Mar 2018 03:32 AM (UTC) |
Message
| Ok, but they don't go off at the same time, so I don't know how putting them in the same trigger would even work. | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #9 on Sat 31 Mar 2018 03:52 AM (UTC) Amended on Sat 31 Mar 2018 03:53 AM (UTC) by Nick Gammon
|
Message
| What do you mean, the don’t go off at the same time?
A trigger matching:
would also match
because the first asterisk could match [Pl:*]
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Traz
(31 posts) Bio
|
Date
| Reply #10 on Sat 31 Mar 2018 04:49 AM (UTC) |
Message
| One goes off when ki is less than 50,000, the other goes off when pl is more than half. They don't usually occur at the same time, though they could. | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #11 on Sat 31 Mar 2018 06:05 AM (UTC) |
Message
| Your terminology is confusing me. Both triggers will fire, regardless of the numerical value of Ki, as there is no test for that in the trigger match line.
Perhaps if we can step back from what you think the solution is, to describing your problem in more detail?
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Traz
(31 posts) Bio
|
Date
| Reply #12 on Sat 31 Mar 2018 06:28 PM (UTC) Amended on Sat 31 Mar 2018 06:30 PM (UTC) by Traz
|
Message
| One trigger should go off only when Ki is less than 50000.
The other trigger should only go off when Pl is more than half.
How I have them set up initially, they both work when the other is not enabled. Only one works when both are enabled.
I just need both of them to work as stated above while both are enabled. | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #13 on Sat 31 Mar 2018 08:11 PM (UTC) |
Message
| You don't get to make conditional triggers like that (unless you mean that is the way the MUD sends things to you - is that what you mean?).
Can you copy/paste some example output from the MUD so we know what you are talking about?
Quote:
How I have them set up initially, they both work when the other is not enabled. Only one works when both are enabled.
I just need both of them to work as stated above while both are enabled.
In particular post messages that demonstrate that situation, so we can reproduce it. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #14 on Sun 01 Apr 2018 06:29 AM (UTC) |
Message
|
Traz said:
One trigger should go off only when Ki is less than 50000.
Do you mean "match" (rather than "go off")? Tomatoes go off if you don't eat them before they start to mould. Triggers match an incoming string.
Inside the trigger (once it matches) the code may decide to do this or that. It isn't clear to me whether you mean you want the trigger to match if Ki is less than 50000, or whether some code inside the trigger is supposed to do something different if Ki is less than 50000. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
42,874 views.
This is page 1, subject is 2 pages long: 1 2
It is now over 60 days since the last post. This thread is closed.
Refresh page
top