I have mutli-line and conditional triggers down. And I can get very basic aliases to work, though only when using send to script and the Send() function.
These seem to be working now
CODE
<alias name="Targetting" match="^t (\w+)$" enabled="y" echo_alias="n" group="General" regexp="y" send_to="12" expand_variables="y">
<send>SetVariable("target", "%1")\nworld.Send("st t %1")</send></alias>
<alias name="Garrote" match="^g$" enabled="y" echo_alias="n" group="General" regexp="y" send_to="12" expand_variables="y">
<send>world.Send("garrote @target")</send></alias>
but when I try to do anything more complex with a variable it doesn't store.<send>SetVariable("target", "%1")\nworld.Send("st t %1")</send></alias>
<alias name="Garrote" match="^g$" enabled="y" echo_alias="n" group="General" regexp="y" send_to="12" expand_variables="y">
<send>world.Send("garrote @target")</send></alias>
I prefer to build systems in Textpad and import them because it's easier for me to follow. I've been attempting to build a plugin that will take care of the basic things I do in Zmud, but it's been difficult.
I've tried copying the methods of other Lua plugins, but for some reason I can't manipulate variables.
These are the bits I'm working with right now
CODE
<trigger
name="prompt"
match="^(\d+)h\, (\d+)m [cexkdb@]*\-"
enabled="y"
group="Basic"
regexp="y"
send_to="12"
sequence="100"
expand_variables="y"
keep_evaluating="y">
<send>
stats.health = %1
stats.mana = %2
sip ()
</send>
</trigger>
<trigger
name="GainSipBalance"
match="You may drink another health or mana elixir\.$"
enabled="y"
group="AutoSipper"
regexp="y"
send_to="14"
sequence="100"
expand_variables="y">
<send>
Note("Setting sip balance true.")
balances.hm = true
Note("@balances.hm")
</send>
</trigger>
<script>
<![CDATA[
stats = {
health = 1, maxhealth = 1,
mana = 1, maxmana = 1,
}
balances = {
hm = true,
}
function sip ()
Note("Entered sip function")
if stats.heatlh == nil then
Note("stats.health is nil")
end -- if
local health = GetVariable("stats.health")
local mana = GetVariable("stats.mana")
local balance = GetVariable("balances.hm")
Note("Sip: set local variables")
if health == nil then
Note("health is nil")
else
Note("health is:" .. health)
Note("mana is:" .. mana)
Note("balances.hm is:" .. balance)
end -- if
if balance and health<2800 then
Send("drink health")
Note("drink health")
elseif balance and mana<3100 then
Send("drink mana")
Note("drink mana")
end -- if
Note("After if")
end -- function sip
]]>
</script>
name="prompt"
match="^(\d+)h\, (\d+)m [cexkdb@]*\-"
enabled="y"
group="Basic"
regexp="y"
send_to="12"
sequence="100"
expand_variables="y"
keep_evaluating="y">
<send>
stats.health = %1
stats.mana = %2
sip ()
</send>
</trigger>
<trigger
name="GainSipBalance"
match="You may drink another health or mana elixir\.$"
enabled="y"
group="AutoSipper"
regexp="y"
send_to="14"
sequence="100"
expand_variables="y">
<send>
Note("Setting sip balance true.")
balances.hm = true
Note("@balances.hm")
</send>
</trigger>
<script>
<![CDATA[
stats = {
health = 1, maxhealth = 1,
mana = 1, maxmana = 1,
}
balances = {
hm = true,
}
function sip ()
Note("Entered sip function")
if stats.heatlh == nil then
Note("stats.health is nil")
end -- if
local health = GetVariable("stats.health")
local mana = GetVariable("stats.mana")
local balance = GetVariable("balances.hm")
Note("Sip: set local variables")
if health == nil then
Note("health is nil")
else
Note("health is:" .. health)
Note("mana is:" .. mana)
Note("balances.hm is:" .. balance)
end -- if
if balance and health<2800 then
Send("drink health")
Note("drink health")
elseif balance and mana<3100 then
Send("drink mana")
Note("drink mana")
end -- if
Note("After if")
end -- function sip
]]>
</script>
But testing it in Mushclient only produces
CODE
You may drink another health or mana elixir.
Setting sip balance true.
.hm
2000h, 3894m exd-
Entered sip function
stats.health is nil
Sip: set local variables
health is nil
After if
Setting sip balance true.
.hm
2000h, 3894m exd-
Entered sip function
stats.health is nil
Sip: set local variables
health is nil
After if
What am I doing wrong with Lua's tables that prevents them from holding data?
And, is this table of send #'s still correct? I'm sending things to speedwalk and it's executing scripts.
CODE
1 world (the MUD)
2 command (the command window)
3 output (directly to the output window, as a note to yourself)
4 status (to the status line)
5 notepad - new (create a new notepad window)
6 notepad - append (append to a notepad window)
7 log file (directly to the log file)
8 notepad - replace (replace an existing notepad window)
9 world - speedwalk delay (queue for delayed send at the speedwalk rate)
10 variable (set a variable, whose name you provide in the variable box)
11 execute (execute through normal command parser, so aliases, speedwalks etc. will be executed)
12 speedwalk (send to world after converting speedwalk string)
13 script (execute as a script command in the current scripting language)
14 world - immediate (to the MUD immediately, even if you are speedwalking)
2 command (the command window)
3 output (directly to the output window, as a note to yourself)
4 status (to the status line)
5 notepad - new (create a new notepad window)
6 notepad - append (append to a notepad window)
7 log file (directly to the log file)
8 notepad - replace (replace an existing notepad window)
9 world - speedwalk delay (queue for delayed send at the speedwalk rate)
10 variable (set a variable, whose name you provide in the variable box)
11 execute (execute through normal command parser, so aliases, speedwalks etc. will be executed)
12 speedwalk (send to world after converting speedwalk string)
13 script (execute as a script command in the current scripting language)
14 world - immediate (to the MUD immediately, even if you are speedwalking)
