<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>
Conflicting Scripts
Posted by Traz on Fri 30 Mar 2018 04:14 AM — 16 posts, 62,524 views.
Also post some example output that these triggers should match on? Then we can set up a test of the problem.
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.
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.
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.
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.
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.
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>
match="[Pl:*][Ki:*]*"and:
match="*[Ki:*]*"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.
match="^(?:\[Pl:(.*?)\])?\[Ki:(.*?)\]"
regexp="y"See regular expressions for the meaning of those symbols.
Basically:
^ <-- start of line
(?: <-- start of group without a capture
\[Pl: <-- matches [Pl
(.*?) <-- capture the Pl value, non-greedy
\] <-- matches ]
)? <-- end of group, group is optional
\[Ki: <-- matches [Ki
(.*?) <-- capture the Ki value, non-greedy
\] <-- matches ]What do you mean, the don’t go off at the same time?
A trigger matching:
[Pl:*][Ki:*]*would also match
*[Ki:*]*because the first asterisk could match [Pl:*]
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?
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.
Can you copy/paste some example output from the MUD so we know what you are talking about?
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.
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.