I am trying to write a script that will allow me to detect an enemy's style and change my style accordingly. The script is as follows:
When I type
<aliases>
<alias
name="astyle"
match="^(c|r)?as(d|t|ty|tyl|tyle)(?: )?([kar|kick|aik|kung])?(?: )?([0-9]{1,3})?(?: )?([0-9]{1,3})?$"
enabled="y"
group="combat"
regexp="y"
send_to="12"
sequence="100"
>
<send>-- This chunk is to assert all the variables haven't somehow been corrupted between uses.
if (GetVariable("style") == nil) or (GetVariable("style") ~= "kar" and GetVariable("style") ~= "kick" and GetVariable("style") ~= "aik" and GetVariable(")style ~= "kung") then
SetVariable("style", "kar")
end -- if
if GetVariable("strength") == nil or tonumber(GetVariable("str")) > 200 or tonumber(GetVariable("str")) < 1 then
SetVariable("strength", 100)
end -- if
if GetVariable("speed") == nil or tonumber(GetVariable("spd")) > 200 or tonumber(GetVariable("spd")) < 1 then
SetVariable("speed", 100)
end -- if
if "$1" == "c" then -- see "current" astyle
Note("You are now using " .. GetVariable("style") .. " at " .. GetVariable("strength") .. "% strength and " .. GetVariable("speed") .. "% speed.")
elseif "$1" == "r" then -- "reset" style to defaults
SetVariable("style", "kar")
SetVariable("strength", 100)
SetVariable("speed", 100)
Note("Style has been reset to defaults.")
elseif "%2" == "d" then -- "detect" opponent's style
Send("astyle detect strength")
Send("astyle detect speed")
else -- actually change your style
if "%3" == "" then -- use default style if none is provided
SetVariable("style", "kar")
elseif "%3" ~= GetVariable("style") then -- update style
SetVariable("style", "%3")
end -- if
if "%5" ~= "" and "%5" ~= nil then -- require both str and spd to be used to change them
SetVariable("strength", tonumber("%4"))
SetVariable("speed", tonumber("%5"))
end -- if
Execute("castyle")
Send("astyle " .. GetVariable("style") .. " " .. GetVariable("str") .. " " .. GetVariable("spd"))
end -- if
</send>
</alias>
</aliases>When I type
castyle, instead of showing me my current style, it changes my style to default 20 times (I counted). Furthermore, it doesn't recognize anything other than castyle (which it mishandles) and asd (which it actually handles correctly). Can anyone explain this and possibly help me to fix it?