lua scripting help

Posted by Shou on Sun 19 Dec 2010 11:25 PM — 7 posts, 27,376 views.

USA #0
ok, i need some help with some math in a trigger.
the actual line is


You glance over Kaem and see that his health is at 310(1) of a possible 310(2).

(added in there)

i'm trying to find out a way to make the trigger do... lets say "kick kaem" when (1) is at 50% of (2). Does anyone know how i would be able to do this?
Australia Forum Administrator #1
Something along these lines would do it:


<triggers>
  <trigger
   enabled="y"
   match="You glance over * and see that his health is at * of a possible *."
   send_to="12"
   sequence="100"
  >
  <send>

local target = "%1"
local health = %2
local max_health = %3

if health / max_health &lt;= 0.5 then
  Send ("kick " .. target)
end -- if

</send>
  </trigger>
</triggers>



Template:pasting
For advice on how to copy the above, and paste it into MUSHclient, please see Pasting XML.
Amended on Mon 20 Dec 2010 05:44 AM by Nick Gammon
USA #2
ok, thats really good, i tried it out and realized i needed something else. is there a way to also make it trigger when it is below 50%, not just at 50%?
Australia Forum Administrator #3
The one I gave above, once pasted using the instructions on the link, actually reads:


if health / max_health <= 0.5 then
  Send ("kick " .. target)
end -- if



That is, less than, or equal to 0.5 (50%).
#4
I'm using this trigger: * condition stands at */* health and */* mana.

and the following script:

<triggers>
<trigger
enabled="y"
match="* condition stands at */* health and */* mana."
send_to="12"
sequence="100"
>
<send>

local target = "%1"
local health = %2
local max_health = %3
local mana = %4
local_mana = %5

if health / max_health <= 0.5 then
Send ("incinerate " .. target)
end -- if

</send>
</trigger>
</triggers>

And i keep on getting this:

Kalcova's condition stands at 361/361 health and 274/274 mana.
Compile error
World: Imperian
Immediate execution
[string "Trigger: "]:1: unexpected symbol near '<'

So what exactly do i need to fix?
Australia Forum Administrator #5
What are you doing exactly? Did you paste all that into the Send box?

Can you show exactly your trigger?

Template:copying
For advice on how to copy aliases, timers or triggers from within MUSHclient, and paste them into a forum message, please see Copying XML.


What you pasted isn't a "script" it is an entire trigger.

Let's put it like this, this is what should be in the "send" box:


local target = "%1"
local health = %2
local max_health = %3
local mana = %4
local_mana = %5

if health / max_health <= 0.5 then
  Send ("incinerate " .. target)
end -- if

#6
sorry I had excess BS in the trigger, thanks for clearing it up