From 56a4b29acfc988bc68f4de095409481130e933f6 Mon Sep 17 00:00:00 2001 From: icecool Date: Fri, 1 Feb 2019 13:25:48 -0600 Subject: [PATCH] Cleaned Up Unnecessary Items Removed unnecessary tables/functions to reduce overall work of script. --- MUSH_dtrack.xml | 72 +++++++++++++++++++------------------------------ 1 file changed, 28 insertions(+), 44 deletions(-) diff --git a/MUSH_dtrack.xml b/MUSH_dtrack.xml index cf925f2..570e64c 100644 --- a/MUSH_dtrack.xml +++ b/MUSH_dtrack.xml @@ -36,7 +36,7 @@ end function trim(s) return (s:gsub("^%s*(.-)%s*$", "%1")) end -function returnStringPosition( item, start, arg ) +function returnStringPosition( item, start, arg ) -- Designed to save on some variable usage in commands local position, _ = string.find(arg, item, start, true) if position then return position @@ -44,24 +44,9 @@ function returnStringPosition( item, start, arg ) return -1 end end - ---[[ Script Stuff ]]-- dtrack = { channel="echo" } dtrack.regular = { start=false, prepend="[dTrack Swings]: " } dtrack.hits = { start=false, prepend="[dTrack Hits]: " } - ---[[ Tables that contain dtrack attacks/hits/etc ]]-- -dtrack_ignore = { - "Rounds", - "Swings", - "Primary", - "Secondary", - "Hits", - "Misses", - "Damage", - "Specials", - "Specials Damage" -} dtrack_track = { ["Swings Per Round"]="swings", ["Hit Percentage"]="hitpercent", @@ -83,15 +68,7 @@ dtrack_hits = { ["Lightspeed"]=false, ["Unarmed"]=false } ---[[ dtrack swings ]]-- -function isIgnored(argument) - for index, value in pairs(dtrack_ignore) do - if value == argument then - return true - end - end - return false -end +--[[ dtrack swings logic ]]-- function isTrackedLine(argument) return ((argument == "Tracked Spell") or (argument == "Tracked Skill")) end @@ -103,9 +80,6 @@ function returnTracked(argument) end return -1 end -function returnSkill(argument) - return string.sub(argument, returnStringPosition("(", 1, argument)+1, returnStringPosition("):", 1, argument)-1) -end function TRIGGER_process_dtrack_line(_, line, _, _) local columnone = trim(string.sub(line, returnStringPosition(":", 1, line)-12, returnStringPosition(":", 1, line)-1)) local columntwo = trim(string.sub(line, returnStringPosition(":", 30, line)-20, returnStringPosition(":", 30, line)-1)) @@ -118,23 +92,18 @@ function TRIGGER_process_dtrack_line(_, line, _, _) EnableTriggerGroup("dtrack_swings", false) reportSwings() end - elseif (isTrackedLine(trim(string.sub(line,1,(1+12))))) then - dtrack.regular["sname"] = returnSkill(line) - elseif (isIgnored(columnone) and isIgnored(columntwo)) then - return -- Both columns are not being tracked, do nothing. + elseif (isTrackedLine(trim(string.sub(line,1,13)))) then + dtrack.regular["sname"] = trim(string.sub(line,returnStringPosition("(",1,line)+1,returnStringPosition("):",1,line)-1)) else if (returnTracked(columnone) ~= -1) then - local value = tonumber(trim(string.sub(line, returnStringPosition("[", 1, line)+1, returnStringPosition("]", 1, line)-1))) - dtrack.regular[returnTracked(columnone)] = ("%0.2f"):format(value) - else + dtrack.regular[returnTracked(columnone)] = ("%0.2f"):format(tonumber(trim(string.sub(line, returnStringPosition("[", 1, line)+1, returnStringPosition("]", 1, line)-1)))) end if (returnTracked(columntwo) ~= -1) then - local value = tonumber(trim(string.sub( line, returnStringPosition("[", 30, line)+1, returnStringPosition("]", 30, line)-1))) - dtrack.regular[returnTracked(columntwo)] = ("%0.2f"):format(value) + dtrack.regular[returnTracked(columntwo)] = ("%0.2f"):format(tonumber(trim(string.sub( line, returnStringPosition("[", 30, line)+1, returnStringPosition("]", 30, line)-1)))) end end end ---[[ dtrack hits ]]-- +--[[ dtrack hits logic ]]-- function isHitsAttack(argument) local calculate=returnStringPosition(":",1,argument)-(returnStringPosition(":",1,argument)-1) local command = trim(string.sub( argument, calculate, returnStringPosition(":",1,argument)-1)) @@ -203,11 +172,17 @@ function reportHits() end --[[ ALIAS command ]]-- function ALIAS_report(name, line, args) - if not (args.channel or args.command) then + if not (args.command) then cnote( "@CSyntax: @Gdreport @R<@wswings|hits@R> <@wchannel@R>@w" ) return end - dtrack.channel = args.channel + if args.command:lower() == "help" then + DREPORT_Help() + return + end + if not (args.channel) then + dtrack.channel = "echo" + end if args.command:lower() == "swings" then EnableTriggerGroup("dtrack_swings", true) SendNoEcho( "dtrack" ) @@ -215,17 +190,26 @@ function ALIAS_report(name, line, args) EnableTriggerGroup("dtrack_hits", true) SendNoEcho( "dtrack hits" ) else - cnote( "@CSyntax: @Gdreport @R<@wswings|hits@R> <@wchannel@R>@w" ) - return + DREPORT_Help() + return end -end +end +--[[ Help File ]]-- +function DREPORT_Help() + cnote("@GdTrack Reports@w") + cnote("@WUsage:@w") + cnote("@G dreport help @w:@W This menu@w") + cnote("@G dreport swings @w:@W Reports the 'dtrack' main screen to a channel@w") + cnote("@G dreport hits @w:@W Reports teh 'dtrack hits' screen to a channel@w") + Note() +end --[[ MUSH Specific functions for saving/loading Plugin information ]]-- -- Anytime a variable (designed to save over) is modified, call SaveState() function afterwards. function OnPluginSaveState () end -- function OnPluginSaveState function OnPluginInstall () + cnote("@GdTrack Reports@w initialized. Check out 'dtrack help' for more information.@w") end -- function OnPluginInstall - ]]>