I am hoping to get some assistance with a hodgepodge script I have assembled.
So I am adapting some script from a kill counter that was used to echo table information into the display, and trying to get it to work by displaying it into a geyser box, GUI.Box 4 to be exact.
The trigger text is:
Code: Select all
You fire your bow and hit Monster with IMMENSE force in the head, nastily shredding his nose.
Code: Select all
^You fire your (.+) and hit (.+) with (.*) in the (.*), (.*).$
^You fire your (.+) and hit (.+) (.*) in the (.*), (.*).$
The problem I am having is that the script below seems to parse correctly, at least for the hit strength, but doesn't seem to format it correctly.
I was originally trying to echo directly to GUIBox but it seemed to just overwrite each other, I am sure due to the original nature this script was created to just echo as an alias command instead of a static display.
I changed it to echo and at least get the modifiers to print, with no separation as seen below:
Code: Select all
IMMENSE force x 1head x 1
Or am I 'almost' there in terms of getting this functioning as desired? I seem to not be getting something in these loops for outputting the data.
Thanks in advance for any information!
The script is as follows:
Code: Select all
hit_strength = hit_strength or {} --makes hit strength table
strength_mods = matches[4] --the hit strength descriptor
hit_strength [strength_mods] = hit_strength [strength_mods] or {count = 0 } --add 1 to strength_mods
hit_strength [strength_mods].count = hit_strength [strength_mods].count + 1
hit_location = hit_location or {} --makes location table
target_locations = matches[5] --the hit target locations
hit_location [target_locations] = hit_location [target_locations] or {count = 0} --add 1 to target_locations
hit_location [target_locations].count = hit_location [target_locations].count + 1
if not hit_strength or next (hit_strength) == nil then
echo ("No hits recorded yet.")
return
end -- if nothing
-- go through each one
count = 0
for k, v in pairs (hit_strength) do
echo (string.format ("%-30s x %i",
k,
v.count
))
count = count + v.count
end -- for loop
if not hit_location or next (hit_location) == nil then
echo ("No hits recorded yet")
return
end -- if nothing
-- go through each one
count = 0
for k, v in pairs (hit_location) do
echo (string.format ("%-30s x %i",
k,
v.count
))
count = count + v.count
end -- for loop
-- show total
echo (string.format ("%5i hits recorded.", count))