Need help with code

Share your scripts and packages with other Mudlet users.
Post Reply
holypickle
Posts: 10
Joined: Sun Feb 14, 2016 1:06 pm

Need help with code

Post 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

Havastus
Posts: 4
Joined: Thu Nov 19, 2015 2:24 am

Re: Need help with code

Post 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!

holypickle
Posts: 10
Joined: Sun Feb 14, 2016 1:06 pm

Re: Need help with code

Post by holypickle »

Thanks man, works perfectly

Post Reply