Nevermind, looking back over it, stats.xxxxx is the information being received and converted into a number to set the variables in the function. I feel stupid.
However I'm still having a problem calling them...
I've gotten a basic alias down for setting the sip_hp:
<aliases>
<alias
name="Test_sip_hp"
match="^HH (.*?)$"
enabled="y"
regexp="y"
send_to="12"
sequence="100"
>
<send>
if %1 > 99 then
Note ("error: sip_per ust be a value between 1 and 99")
else
SetVariable ("sip_per", %1)
SetVariable ("sip_hp", GetVariable ("max_hp") * GetVariable ("sip_per") * 0.01)
Note ("Sipping at " .. GetVariable ("sip_hp") .. " health")
end
</send>
</alias>
</aliases>
((I know you two can read that like a book, but for those interested in the process))
I made this alias by multiplying the variables "max_hp" (max health) and "sip_per" (The % health you want to start sipping at, commonly 80% but sometimes differing. Done in % because health values constantly change, and therefor sip_hp should too) and multiplying the resulting number by 0.01 (the equivalent of dividing by 100). This gives us a percent of the max health at which a person will start sipping. I'm not worried about remainders right now, because in my code the remainder just means the number is rounded up.
Now I have a few problems. I want to convert this alias into a script, so that it will automatically update the max_hp and the sip_hp every time max_hp changes, instead of having to go back and retype HH * every time.
Next, I'm having problems setting max_hp using the snippet of code Nick gave me, I'm currently trying and failing to do this:
function OnPluginBroadcast (msg, id, name, text)
if id == "85f72d0e263d75df7bde6f00" then
if msg == 1 then
got_vitals (text)
end -- if
end -- if ATCP message
end
function got_vitals (s)
stats.health, stats.maxhealth,
stats.mana, stats.maxmana,
stats.endurance, stats.maxendurance,
stats.willpower, stats.maxwillpower,
stats.exp, stats.maxexp =
string.match (s, "^" ..
"H:(%d+)/(%d+) " ..
"M:(%d+)/(%d+) " ..
"E:(%d+)/(%d+) " ..
"W:(%d+)/(%d+) " ..
"NL:(%d+)/(%d+)")
if stats.health then
hp, max_hp = tonumber (stats.health), tonumber (stats.maxhealth)
mana, max_mana = tonumber (stats.mana), tonumber (stats.maxmana)
endurance, max_endurance = tonumber (stats.endurance), tonumber (stats.maxendurance)
willpower, max_willpower = tonumber (stats.willpower), tonumber (stats.maxwillpower)
exp, max_exp = tonumber (stats.exp), tonumber (stats.maxexp)
SetVariable ("max_hp", max_hp)
end -- if
end -- function got_vitals
function sipper ()
sip_hp = GetVariable ("sip_hp")
sip_bal = GetVariable ("sip_bal")
if hp < sip_hp and sip_bal == "1" then
Send ("sip health")
SetVariable ("sip_bal", ".5")
end -- if
end -- function
I'm trying to set the client variable max_hp to align with the script variable max_hp so that the variable will be constantly up-to-date, but something is wrong and the variable isn't changing...
Edit: also, function sipper () serves no purpose yet, just laying down a sort of skeleton for that part. |