Help - Search - Members - Calendar
Full Version: Prompt Trigger In Mush
Achaea's Forums > Off-Topic > Tech Support > Client Help
Rire
I'm trying to make a prompt trigger that will set my current health points, and if they're lower than my siphealth variable send the command 'sip health' to the game and turn my elixar balance off.

CODE
^(\d{1,4})h, (\d{1,4})m \w*-

executes
CODE
SetVariable("currenthealth", %1)
SetVariable("currentmana", %2)

if currenthealth < siphealth and healbalance == "1" then
send("siphealth")
SetVariable("healbalance", 1)
end

and I get the error
CODE
[string "Trigger: "]:4: attempt to compare two nil values
stack traceback:
    [string "Trigger: "]:4: in main chunk

which I think has something to do with the 'if currenthealth < siphealth' but I can't figure out what's wrong. I have siphealth defined via another trigger and currenthealth is defined right at the beginning of this one, so they're not nil values. Obviously, though, I'm doing something wrong. What can I do to make this work?
Sibrint
QUOTE (Rire @ Mar 26 2009, 10:26 AM) *
I'm trying to make a prompt trigger that will set my current health points, and if they're lower than my siphealth variable send the command 'sip health' to the game and turn my elixar balance off.

CODE
^(\d{1,4})h, (\d{1,4})m \w*-

executes
CODE
SetVariable("currenthealth", %1)
SetVariable("currentmana", %2)

if currenthealth < siphealth and healbalance == "1" then
send("siphealth")
SetVariable("healbalance", 1)
end

and I get the error
CODE
[string "Trigger: "]:4: attempt to compare two nil values
stack traceback:
     [string "Trigger: "]:4: in main chunk

which I think has something to do with the 'if currenthealth < siphealth' but I can't figure out what's wrong. I have siphealth defined via another trigger and currenthealth is defined right at the beginning of this one, so they're not nil values. Obviously, though, I'm doing something wrong. What can I do to make this work?


Use @siphealth, not just @siphealth. I had the same problem with some of my stuff when I started. I believe it'd be the same with currenthealth and healbalance, but it might be %whatever. I think my triggers and aliases all use variables from other places.
Rire
ok I just tried
CODE
if currenthealth < siphealth and healbalance == "1" then

and got
CODE
[string "Trigger: "]:4: unexpected symbol near '@'

also tried putting @ in front of just one or the other, same thing
Rire
Ahahaha.... I just needed to add '@' and check expand variables. glare.gif

thanks!
shalishaska
Ninja'd
Rire
Well ok my trigger has changed quite a bit, and my sipper is working for the most part. One last issue is that when my health gets to 999 or less it just stops sipping. Here's my new prompt trigger

CODE
^(\d+)h, (\d+)m, \d+e, \d+w ([cexkdb@]*)-

executes:
SetVariable("currenthealth", %1)
SetVariable("currentmana", %2)
Execute("HEAL")

And HEAL is just
CODE
local currenthealth = GetVariable("currenthealth")
local siphealth     = GetVariable("siphealth")
local healbalance   = GetVariable("healbalance")
local sipping       = GetVariable("sipping")

if healbalance == "1" and sipping == "0" then

if currenthealth < siphealth then

  Send("sip health")
  SetVariable("sipping", 1)

end

end


I'm also trying to add timers as a fail safe for certain situations, but that's a whole other issue, and I'll get to that when I (you) fix this one. biggrin.gif
Gorlasintan
What do you have set up to set sipping and healbalance back to their defaults (0 and 1, respectively)? The code you have here looks fine, so I'm assuming the problem will be elsewhere.
Rire
QUOTE (Gorlasintan @ Apr 2 2009, 11:31 AM) *
What do you have set up to set sipping and healbalance back to their defaults (0 and 1, respectively)? The code you have here looks fine, so I'm assuming the problem will be elsewhere.


CODE
^The elixir heals and soothes you\.$

executes:
SetVariable("healbalance", 0)
SetVariable("sipping", 0)


CODE
^You may drink another health or mana elixir\.$

executes:
SetVariable("healbalance", 1)
SetVariable("sipping", 0)
shalishaska
Post the trigger which sets @siphealth as well. There's nothing wrong that I can see in the code you've posted so far.
Rire
QUOTE (shalishaska @ Apr 2 2009, 02:51 PM) *
Post the trigger which sets @siphealth as well. There's nothing wrong that I can see in the code you've posted so far.

CODE
^Health:\s+\d{1,4}\s/\s(\d{4})\s{5}Mana:\s+\d{1,4}\s/\s(\d{4})$

executes:
SetVariable("maxhealth", %1)
SetVariable("siphealth", %1-750)
Rire
This is me right now

Penquin
QUOTE (Rire @ Apr 2 2009, 02:42 PM) *
QUOTE (Gorlasintan @ Apr 2 2009, 11:31 AM) *
What do you have set up to set sipping and healbalance back to their defaults (0 and 1, respectively)? The code you have here looks fine, so I'm assuming the problem will be elsewhere.


CODE
^The elixir heals and soothes you\.$

executes:
SetVariable("healbalance", 0)
SetVariable("sipping", 0)


CODE
^You may drink another health or mana elixir\.$

executes:
SetVariable("healbalance", 1)
SetVariable("sipping", 0)




QUOTE (Rire @ Apr 2 2009, 05:56 PM) *
QUOTE (shalishaska @ Apr 2 2009, 02:51 PM) *
Post the trigger which sets @siphealth as well. There's nothing wrong that I can see in the code you've posted so far.

CODE
^Health:\s+\d{1,4}\s/\s(\d{4})\s{5}Mana:\s+\d{1,4}\s/\s(\d{4})$

executes:
SetVariable("maxhealth", %1)
SetVariable("siphealth", %1-750)




You need quotations around your setvariable variables.
CODE
SetVariable("maxhealth", "%1")
SetVariable("siphealth", %1-750)<--- wrong. %1 is a string, you can't subtract 750 from a string


I think lua uses tonumber() and tostring to convert, so do the following:
CODE
SetVariable("siphealth", tonumber(%1)-750)


Also, you need to actuall group your variables in the trigger:
CODE
^Health\:\s+\d+\s+\/\s+(\d+)\s+Mana\:\s+\d+\s+\/\s+(\d+)$


SetVariable("maxhealth", "%1")
SetVariable("siphealth", tonumber("%1")-750)
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.