Register forum user name Search FAQ

Gammon Forum

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 ➜ Lua ➜ lua scripting help

lua scripting help

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Shou   USA  (30 posts)  Bio
Date Sun 19 Dec 2010 11:25 PM (UTC)
Message
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?

My computer once beat me at chess, but it was no match for me at kickboxing.
Top

Posted by Nick Gammon   Australia  (23,165 posts)  Bio   Forum Administrator
Date Reply #1 on Mon 20 Dec 2010 05:30 AM (UTC)

Amended on Mon 20 Dec 2010 05:44 AM (UTC) by Nick Gammon

Message
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.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Shou   USA  (30 posts)  Bio
Date Reply #2 on Mon 20 Dec 2010 07:08 AM (UTC)
Message
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%?

My computer once beat me at chess, but it was no match for me at kickboxing.
Top

Posted by Nick Gammon   Australia  (23,165 posts)  Bio   Forum Administrator
Date Reply #3 on Mon 20 Dec 2010 10:02 AM (UTC)
Message
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%).

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by This_Guy   (13 posts)  Bio
Date Reply #4 on Sat 25 Dec 2010 07:34 PM (UTC)
Message
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?
Top

Posted by Nick Gammon   Australia  (23,165 posts)  Bio   Forum Administrator
Date Reply #5 on Sat 25 Dec 2010 10:06 PM (UTC)
Message
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


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by This_Guy   (13 posts)  Bio
Date Reply #6 on Sat 25 Dec 2010 11:57 PM (UTC)
Message
sorry I had excess BS in the trigger, thanks for clearing it up
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.


22,868 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.