Trigger/Printing table to Geyser box

Post Reply
Zindarg
Posts: 4
Joined: Fri Sep 08, 2017 12:12 am

Trigger/Printing table to Geyser box

Post by Zindarg » Fri Jun 14, 2019 12:24 am

Hello,
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.
The Currently set triggers seem to work are:

Code: Select all

^You fire your (.+) and hit (.+) with (.*) in the (.*), (.*).$
^You fire your (.+) and hit (.+) (.*) in the (.*), (.*).$
(There are two due to how the MUD displays hit strength as adjectives depending on the hit descriptor.)

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
The question is, is there a better way to parse this information, and display it statically to a GUI. Box with some semblance of formatting?
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))
Moderator edit by SlySven: - added [ code] ... [ /code] formatting tags.

Zindarg
Posts: 4
Joined: Fri Sep 08, 2017 12:12 am

Re: Trigger/Printing table to Geyser box

Post by Zindarg » Tue Aug 06, 2019 1:53 am

So - I have changed things around and tried recreating from scratch after re-reading wiki and re-watching help videos.
I think I am close, I just have a two (three?) issues.

I have a table for my permenant values and am using table.save but for whatever reason it doesn't seem to be working.

The Load Code on trigger

Code: Select all

PermHitStrength = PermHitStrength or {}
table.load("C:/Users/Hunter/.config/mudlet/profiles/Icesus", PermHitStrength)
The Save Code on alias

Code: Select all

table.save("C:/Users/Hunter/.config/mudlet/profiles/Icesus", PermHitStrength)
This is one(two) thing(s) I am stuck on.

One other thing I am stuck on, is that I have labels in containers with the variables in them, and the variables are working and updating! But the labels do not update to the currently stored variables until I click on the scripts for them which then updates them.
Is there a refresh label/container/scripts function I can include in my triggers to ensure the relevant information in the relevant label updates? Or a better method for having real time updating?

Thanks! :)

User avatar
demonnic
Posts: 569
Joined: Sat Dec 05, 2009 3:19 pm

Re: Trigger/Printing table to Geyser box

Post by demonnic » Tue Aug 06, 2019 12:58 pm

You're close! In the table.save and table.load calls you only have the directory, you're missing the filename, so table.save("C:/Users/Hunter/.config/mudlet/profiles/Icesus/PermHitStrength.lua", PermHitStrength) and likewise for the table.load.

As for the Labels issue, the line where you echo the information to the label in your scripts should also go in the triggers which update the information in the variables. So if you have a label which displays your current hit count, and a trigger which updates the variable containing your hit count, you'll want to add the echo to the trigger right after setting the variable, and not just in the script.

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 8 guests