Hello all,
I'm currently writing a script and am trying to capture some output from the game, then perform some math with it. Obviously the script keeps executing before the mud returns the line I'm waiting for. I read the FAQ about waiting for a trigger line, but apparently I'm doing something wrong. Here's my code for the wait, along with what string I'm trying to match and a few lines after the wait function.
The trigger captures the variables fine (I check after the error happens, and the variables are set), unfortunately, the script errors because the trigger doesn't set them fast enough. It appears that the wait isn't working to me. The error I get is that TemperDamage is a nil value. There is, literally, no pause whatsoever. Anyone have any tips for making this work? Just need the script to sit and loop/pause long enough to allow the trigger to set the variables.
I'm currently writing a script and am trying to capture some output from the game, then perform some math with it. Obviously the script keeps executing before the mud returns the line I'm waiting for. I read the FAQ about waiting for a trigger line, but apparently I'm doing something wrong. Here's my code for the wait, along with what string I'm trying to match and a few lines after the wait function.
EnableTrigger("temper_base_capture", true)
function cr ()
repeat
Send ("wp " .. TemperWeapon)
line, wildcards =
wait.regexp ("^\s*Damage:\s+(\d+)\s+Precision:\s+(\d+)\s+Speed:\s+(\d+)\s*$")
until string.find (line, "Speed")
wait.time (5)
Note ("Hopefully variables are set")
end
wait.make (cr)
EnableTrigger("temper_base_capture", false)
TemperDamage = GetVariable("temper_damage_base")
TemperPrecision = GetVariable("temper_precision_base")
TemperSpeed = GetVariable("temper_speed_base")
TemperWeapon = "axe"
TemperSrc = GetVariable("temper_source")
local FinalDamage
local FinalPrecision
local FinalSpeed
FinalDamage = GetVariable("temper_damage")
FinalPrecision = GetVariable("temper_precision")
FinalSpeed = GetVariable("temper_speed")
local DamageDifference
local PrecisionDifference
local SpeedDifference
DamageDifference = FinalDamage - TemperDamage
<trigger
expand_variables="y"
enabled="y"
group="Lil_Forger_Suite"
ignore_case="y"
keep_evaluating="y"
match="^\s*Damage:\s+(\d+)\s+Precision:\s+(\d+)\s+Speed:\s+(\d+)\s*$"
name="temper_base_capture"
regexp="y"
send_to="12"
sequence="100"
>
<send>
SetVariable("temper_damage_base", %1)
SetVariable("temper_precision_base", %2)
SetVariable("temper_speed_base", %3)
</send>
</trigger>
The trigger captures the variables fine (I check after the error happens, and the variables are set), unfortunately, the script errors because the trigger doesn't set them fast enough. It appears that the wait isn't working to me. The error I get is that TemperDamage is a nil value. There is, literally, no pause whatsoever. Anyone have any tips for making this work? Just need the script to sit and loop/pause long enough to allow the trigger to set the variables.