[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Lua
. . -> [Subject]  lua scripting help

lua scripting help

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


Posted by Shou   USA  (30 posts)  [Biography] 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.
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] 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
[Go to top] top

Posted by Shou   USA  (30 posts)  [Biography] 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.
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] 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
[Go to top] top

Posted by This_Guy   (13 posts)  [Biography] 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?
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] 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
[Go to top] top

Posted by This_Guy   (13 posts)  [Biography] 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
[Go to top] 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.


17,137 views.

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

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]