Page 1 of 1

Need help with code

Posted: Wed Feb 24, 2016 6:57 pm
by holypickle
Basically I'm trying to create a trigger that will trip when my health is below 50%

How would I go about making an array, or a set of numbers in between x and y? Or in my case, 1-50.

Trigger Pattern: HP :

If HP<=50%

then
send(drink vial)

whoever helps me will get a really awesome cat photo

Re: Need help with code

Posted: Wed Feb 24, 2016 11:19 pm
by Havastus
You basically just answered your own question.

The trigger line would have to be a 'perl regex' type trigger, as you want to extract data from it (in this case, what your HP percentage is). It would look something like this:

^HP\: (\d+)\%$

For the script part of your trigger, it would go something like this:

local hpPercentage = tonumber(matches[2])

if hpPercentage <= 50 then
send("drink vial")
end

I would suggest looking into a Perl Regex tutorial, so you can learn what all of those archaic symbols mean. I would also look into a basic Lua tutorial so you can learn how to program this stuff yourself. It'll help in the long run!

Re: Need help with code

Posted: Wed Feb 24, 2016 11:55 pm
by holypickle
Thanks man, works perfectly