Fix inconsistent config set behavior, add checks for input, ensure newlines exist on cechos
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
ee3bbdb2f8
commit
89848ef20b
@ -1,11 +1,11 @@
|
||||
if not Bashmatic.death.event then
|
||||
cecho("<firebrick>Bashmatic: You must configure the death trigger first. Please see bm help for more info.")
|
||||
cecho("\n<firebrick>Bashmatic: You must configure the death trigger first. Please see bm help for more info.")
|
||||
else
|
||||
if Bashmatic.enemies.group then
|
||||
-- grouping enemies by area
|
||||
local area = GetRoomAreaName(GetRoomArea(GetPlayerRoom())) or nil
|
||||
if area == nil then
|
||||
cecho("<firebrick>Bashmatic: We tried to add that enemy but got a bad area.\nGot: " .. area .. "<reset>")
|
||||
cecho("\n<firebrick>Bashmatic: We tried to add that enemy but got a bad area.\nGot: " .. area .. "<reset>")
|
||||
else
|
||||
inlineAddTarget(matches[2], area)
|
||||
end
|
||||
|
@ -5,16 +5,16 @@ bmDisable()
|
||||
if Bashmatic.enemies.group then
|
||||
local area = GetRoomAreaName(GetRoomArea(GetPlayerRoom())) or nil
|
||||
if area == nil then
|
||||
cecho("<firebrick>Bashmatic: Attempted to clear area targets but got a bad area.\nGot: " .. area .. "<reset>")
|
||||
cecho("\n<firebrick>Bashmatic: Attempted to clear area targets but got a bad area.\nGot: " .. area .. "<reset>")
|
||||
return
|
||||
end
|
||||
if not table.contains(Bashmatic.enemies.targets, area) then
|
||||
cecho("<firebrick>Bashmatic: You don't have any enemies for the area " .. area .. "<reset>")
|
||||
cecho("\n<firebrick>Bashmatic: You don't have any enemies for the area " .. area .. "<reset>")
|
||||
return
|
||||
end
|
||||
Bashmatic.enemies.targets.area = nil
|
||||
cecho("<DarkSlateBlue>Bashmatic: Cleared target list for area " .. area .. "<reset>")
|
||||
cecho("\n<DarkSlateBlue>Bashmatic: Cleared target list for area " .. area .. "<reset>")
|
||||
else
|
||||
Bashmatic.enemies.targets = {}
|
||||
cecho("<DarkSlateBlue>Bashmatic: Cleared target list.<reset>")
|
||||
cecho("\n<DarkSlateBlue>Bashmatic: Cleared target list.<reset>")
|
||||
end
|
@ -7,52 +7,62 @@ if which == "phrase" then
|
||||
end
|
||||
Bashmatic.death.phrase = matches[3]
|
||||
Bashmatic.death.event = tempRegexTrigger(".*" .. Bashmatic.death.phrase .. ".*",handleMobDeath)
|
||||
cecho("<DarkSlateBlue>Bashmatic: Reset the death event trigger phrase to " .. matches[3] .. ".<reset>")
|
||||
cecho("\n<DarkSlateBlue>Bashmatic: Reset the death event trigger phrase to " .. matches[3] .. ".<reset>")
|
||||
elseif which == "start" then
|
||||
-- starting battle command
|
||||
Bashmatic.commands.start = matches[3]
|
||||
cecho("<DarkSlateBlue>Bashmatic: Set battle start command to " .. matches[3] .. " target.<reset>")
|
||||
cecho("\n<DarkSlateBlue>Bashmatic: Set battle start command to " .. matches[3] .. " target.<reset>")
|
||||
elseif which == "before" then
|
||||
-- before battle command
|
||||
Bashmatic.commands.before = matches[3]
|
||||
cecho("<DarkSlateBlue>Bashmatic: Will send " .. matches[3] .. " before battle start.<reset>")
|
||||
cecho("\n<DarkSlateBlue>Bashmatic: Will send " .. matches[3] .. " before battle start.<reset>")
|
||||
elseif which == "during" then
|
||||
-- during battle command
|
||||
Bashmatic.comands.during = matches[3]
|
||||
cecho("<DarkSlateBlue>Bashmatic: Will send " .. matches[3] .. " during battle every " .. Bashmatic.commands.duringTime .. " seconds.<reset>")
|
||||
cecho("\n<DarkSlateBlue>Bashmatic: Will send " .. matches[3] .. " during battle every " .. Bashmatic.commands.duringTime .. " seconds.<reset>")
|
||||
elseif which == "duringTime" then
|
||||
-- during battle command time frame
|
||||
Bashmatic.commands.duringTime = tonumber(mathces[3])
|
||||
cecho("<DarkSlateBlue>Bashmatic: Will send " .. Bashmatic.commands.during .. " during battle every " .. tonumber(matches[3]) .. " seconds.<reset>")
|
||||
cecho("\n<DarkSlateBlue>Bashmatic: Will send " .. Bashmatic.commands.during .. " during battle every " .. tonumber(matches[3]) .. " seconds.<reset>")
|
||||
elseif which == "after" then
|
||||
-- after battle command
|
||||
Bashmatic.commands.after = matches[3]
|
||||
cecho("<DarkSlateBlue>Bashmatic: Will send " .. matches[3] .. " after combat.<reset>")
|
||||
cecho("\n<DarkSlateBlue>Bashmatic: Will send " .. matches[3] .. " after combat.<reset>")
|
||||
elseif which == "lowercase" then
|
||||
-- Converting target to lowercase in battle start command
|
||||
Bashmatic.enemies.lowercase = not Bashmatic.enemies.lowercase
|
||||
if not table.contains({"yes", "no"}, matches[3]:lower()) then
|
||||
cecho("\n<firebrick>Bashmatic: You need to set lowercase target conversion to yes or no.")
|
||||
return
|
||||
end
|
||||
if matches[3]:lower() == "yes" then Bashmatic.enemies.lowercase = true end
|
||||
if matches[3]:lower() == "no" then Bashmatic.enemies.lowercase = false end
|
||||
if Bashmatic.enemies.lowercase then
|
||||
cecho("<DarkSlateBlue>Bashmatic: Will now convert targets to lowercase in starting command.")
|
||||
cecho("\n<DarkSlateBlue>Bashmatic: Will now convert targets to lowercase in starting command.")
|
||||
else
|
||||
cecho("<DarkSlateBlue>Bashmatic: Will no longer convert targets to lowercase in starting command.")
|
||||
cecho("\n<DarkSlateBlue>Bashmatic: Will no longer convert targets to lowercase in starting command.")
|
||||
end
|
||||
elseif which == "group" then
|
||||
-- group by area
|
||||
if #getRooms() == 0 then
|
||||
Bashmatic.enemies.group = false
|
||||
cecho("<firebrick>Bashmatic: No map detected. Did you make one? You need at least one room to use this feature.<reset>")
|
||||
cecho("\n<firebrick>Bashmatic: No map detected. Did you make one? You need at least one room to use this feature.<reset>")
|
||||
else
|
||||
Bashmatic.enemies.group = not Bashmatic.enemies.group
|
||||
if not table.contains({"yes", "no"}, matches[3]:lower()) then
|
||||
cecho("\n<firebrick>Bashmatic: You need to set enemy grouping by area to either yes or no.<reset>")
|
||||
return
|
||||
end
|
||||
if matches[3]:lower() == "yes" then Bashmatic.enemies.group = true end
|
||||
if matches[3]:lower() == "no" then Bashmatic.enemies.group = false end
|
||||
if Bashmatic.enemies.group then
|
||||
-- we've just turned on enemy grouping
|
||||
Bashmatic.enemies.targets = {}
|
||||
cecho("<DarkSlateBlue>Bashmatic: Now grouping enemies by areas. Cleared previous enemies.<reset>")
|
||||
cecho("\n<DarkSlateBlue>Bashmatic: Now grouping enemies by areas. Cleared previous enemies.<reset>")
|
||||
else
|
||||
-- we've just turned off enemy grouping
|
||||
squashTargetGroups()
|
||||
cecho("<DarkSlateBlue>Bashmatic: No longer grouping enemies by areas. Squashed previous enemies into one large table.\nYou can bm clear to erase them.<reset>")
|
||||
cecho("\n<DarkSlateBlue>Bashmatic: No longer grouping enemies by areas. Squashed previous enemies into one large table.\nYou can bm clear to erase them.<reset>")
|
||||
end
|
||||
end
|
||||
else
|
||||
cecho("<firebrick>Bashmatic: Unrecognized option " .. matches[3] .. ". See bm help for a list of options.")
|
||||
cecho("\n<firebrick>Bashmatic: Unrecognized option " .. matches[3] .. ". See bm help for a list of options.")
|
||||
end
|
@ -3,26 +3,26 @@ local ourIndex = tonumber(matches[2])
|
||||
if Bashmatic.enemies.group then
|
||||
local area = GetRoomAreaName(GetRoomArea(GetPlayerRoom())) or nil
|
||||
if area == nil then
|
||||
cecho("<firebrick>Bashmatic: Attempted to clear area targets but got a bad area.\nGot: " .. area .. "<reset>")
|
||||
cecho("\n<firebrick>Bashmatic: Attempted to clear area targets but got a bad area.\nGot: " .. area .. "<reset>")
|
||||
return
|
||||
end
|
||||
if not table.contains(Bashmatic.enemies.targets, area) then
|
||||
cecho("<firebrick>Bashmatic: You don't have any enemies for the area " .. area .. "<reset>")
|
||||
cecho("\n<firebrick>Bashmatic: You don't have any enemies for the area " .. area .. "<reset>")
|
||||
return
|
||||
end
|
||||
local size = table.size(Bashmatic.enemies.targets.area)
|
||||
if ourIndex > size then
|
||||
cecho("<firebrick>Bashmatic: Index out of range for this area. There are only " .. size .. " targets stored.<reset>")
|
||||
cecho("\n<firebrick>Bashmatic: Index out of range for this area. There are only " .. size .. " targets stored.<reset>")
|
||||
return
|
||||
end
|
||||
table.remove(Bashmatic.enemies.targets.area, ourIndex)
|
||||
cecho("<DarkSlateBlue>Bashmatic: Removed target from the area list.<reset>")
|
||||
cecho("\n<DarkSlateBlue>Bashmatic: Removed target from the area list.<reset>")
|
||||
else
|
||||
local size = table.size(Bashmatic.enemies.targets)
|
||||
if ourIndex > size then
|
||||
cecho("<firebrick>Bashmatic: Index out of range. There are only " .. size .. " targets stored.<reset>")
|
||||
cecho("\n<firebrick>Bashmatic: Index out of range. There are only " .. size .. " targets stored.<reset>")
|
||||
return
|
||||
end
|
||||
table.remove(Bashmatic.enemies.targets, ourIndex)
|
||||
cecho("<DarkSlateBlue>Bashmatic: Removed target from the list.<reset>")
|
||||
cecho("\n<DarkSlateBlue>Bashmatic: Removed target from the list.<reset>")
|
||||
end
|
@ -1,4 +1,4 @@
|
||||
cecho([[<SteelBlue>
|
||||
cecho([[<DarkSlateBlue>
|
||||
Bashmatic Help File
|
||||
Let's Bash some Mobs!
|
||||
|
||||
@ -22,7 +22,7 @@ bmc during - commands to execute during combat.
|
||||
bmc duringTime - time delay between during command execution. Default 2 seconds. Wants a number.
|
||||
bmc after - commands to execute after the death trigger fires.
|
||||
bmc group - set to yes or no to toggle grouping enemies by mudlet mapper areas on or off
|
||||
bmc lowercase - This will convert your target to lowercase before starting the fight (So Kill Rat becomes Kill rat)
|
||||
bmc lowercase - set to yes or no to toggle converting your target to lowercase before starting the fight (So Kill Rat becomes Kill rat)
|
||||
|
||||
Aliases Available
|
||||
-----------------
|
||||
|
@ -2,16 +2,16 @@ if Bashmatic.enemies.group then
|
||||
-- grouped by areas
|
||||
local area = GetRoomAreaName(GetRoomArea(GetPlayerRoom())) or nil
|
||||
if area == nil then
|
||||
cecho("<firebrick>Bashmatic: We got an invalid area.\nWe Got: " .. area .. "<reset>")
|
||||
cecho("\n<firebrick>Bashmatic: We got an invalid area.\nWe Got: " .. area .. "<reset>")
|
||||
return
|
||||
end
|
||||
if not table.contains(Bashmatic.enemies.targets, area) then
|
||||
cecho("<firebrick>Bashmatic: No enemies added from the area " .. area .. "<reset>")
|
||||
cecho("\n<firebrick>Bashmatic: No enemies added from the area " .. area .. "<reset>")
|
||||
return
|
||||
end
|
||||
local size = table.size(Bashmatic.enemies.targets.area)
|
||||
if size == 0 then
|
||||
cecho("<firebrick>Bashmatic: No enemies added from the area " .. area .. "<reset>")
|
||||
cecho("\n<firebrick>Bashmatic: No enemies added from the area " .. area .. "<reset>")
|
||||
return
|
||||
end
|
||||
if size <= 15 then
|
||||
@ -26,7 +26,7 @@ else
|
||||
-- not grouped by area
|
||||
local size = table.size(Bashmatic.enemies.targets)
|
||||
if size == 0 then
|
||||
cecho("<firebrick>Bashmatic: No enemies added.<reset>")
|
||||
cecho("\n<firebrick>Bashmatic: No enemies added.<reset>")
|
||||
return
|
||||
end
|
||||
if size <= 15 then
|
||||
|
@ -2,16 +2,16 @@ if Bashmatic.enemies.group then
|
||||
-- grouped by areas
|
||||
local area = GetRoomAreaName(GetRoomArea(GetPlayerRoom())) or nil
|
||||
if area == nil then
|
||||
cecho("<firebrick>Bashmatic: We got an invalid area.\nWe Got: " .. area .. "<reset>")
|
||||
cecho("\n<firebrick>Bashmatic: We got an invalid area.\nWe Got: " .. area .. "<reset>")
|
||||
return
|
||||
end
|
||||
if not table.contains(Bashmatic.enemies.targets, area) then
|
||||
cecho("<firebrick>Bashmatic: No enemies added from the area " .. area .. "<reset>")
|
||||
cecho("\n<firebrick>Bashmatic: No enemies added from the area " .. area .. "<reset>")
|
||||
return
|
||||
end
|
||||
local size = table.size(Bashmatic.enemies.targets.area)
|
||||
if size == 0 then
|
||||
cecho("<firebrick>Bashmatic: No enemies added from the area " .. area .. "<reset>")
|
||||
cecho("\n<firebrick>Bashmatic: No enemies added from the area " .. area .. "<reset>")
|
||||
return
|
||||
end
|
||||
if size <= 15 then
|
||||
@ -21,7 +21,7 @@ if Bashmatic.enemies.group then
|
||||
-- paginator
|
||||
local pages = math.floor(size/15)+1
|
||||
if tonumber(matches[2]) > pages then
|
||||
cecho("<firebrick>Bashmatic: There aren't that many pages. There are only " .. pages .. " pages.<reset>")
|
||||
cecho("\n<firebrick>Bashmatic: There aren't that many pages. There are only " .. pages .. " pages.<reset>")
|
||||
return
|
||||
end
|
||||
local startIndex = ((tonumber(matches[2]) - 1)*15)+1
|
||||
@ -33,7 +33,7 @@ else
|
||||
-- not grouped by area
|
||||
local size = table.size(Bashmatic.enemies.targets)
|
||||
if size == 0 then
|
||||
cecho("<firebrick>Bashmatic: No enemies added.<reset>")
|
||||
cecho("\n<firebrick>Bashmatic: No enemies added.<reset>")
|
||||
return
|
||||
end
|
||||
if size <= 15 then
|
||||
@ -43,7 +43,7 @@ else
|
||||
-- paginator
|
||||
local pages = math.floor(size/15)+1
|
||||
if tonumber(matches[2]) > pages then
|
||||
cecho("<firebrick>Bashmatic: There aren't that many pages. There are only " .. pages .. " pages.<reset>")
|
||||
cecho("\n<firebrick>Bashmatic: There aren't that many pages. There are only " .. pages .. " pages.<reset>")
|
||||
return
|
||||
end
|
||||
local startIndex = ((tonumber(matches[2]) - 1)*15)+1
|
||||
|
@ -3,5 +3,5 @@ Bashmatic.enabled = not Bashmatic.enabled
|
||||
if Bashmatic.enabled and table.size(Bashmatic.hunting.events) == 0 and table.size(Bashmatic.enemies.targets) > 0 then
|
||||
-- we just turned ourself on, we have targets, and no triggers are running
|
||||
recreateTriggers()
|
||||
cecho("<DarkSlateBlue>Bashmatic: Bashmatic turned on. Let's go bash some mobs.<reset>")
|
||||
cecho("\n<DarkSlateBlue>Bashmatic: Bashmatic turned on. Let's go bash some mobs.<reset>")
|
||||
end
|
@ -52,7 +52,7 @@ function handleLoadEvent()
|
||||
Bashmatic.death.event = tempRegexTrigger(".*" .. Bashmatic.death.phrase .. ".*",handleMobDeath)
|
||||
end
|
||||
|
||||
cecho("<DarkSlateBlue>Bashmatic: Loaded settings. Let's bash some mobs.")
|
||||
cecho("\n<DarkSlateBlue>Bashmatic: Loaded settings. Let's bash some mobs.")
|
||||
|
||||
end
|
||||
registerAnonymousEventHandler("sysLoadEvent", handleLoadEvent)
|
||||
@ -110,14 +110,14 @@ end
|
||||
|
||||
function inlineAddTarget(target, area)
|
||||
if area == nil then
|
||||
cecho("<DarkSlateBlue>Bashmatic: Added " .. target .. " to hunting targets.<reset>")
|
||||
cecho("\n<DarkSlateBlue>Bashmatic: Added " .. target .. " to hunting targets.<reset>")
|
||||
if not table.contains(Bashmatic.enemies.targets, target) then
|
||||
table.insert(Bashmatic.enemies.targets, target)
|
||||
end
|
||||
end
|
||||
|
||||
if area ~= nil then
|
||||
cecho("<DarkSlateBlue>Bashmatic: Added " .. target .. " to hunting targets in " .. area .. ".<reset>")
|
||||
cecho("\n<DarkSlateBlue>Bashmatic: Added " .. target .. " to hunting targets in " .. area .. ".<reset>")
|
||||
if table.contains(Bashmatic.enemies.targets, area) then
|
||||
table.insert(Bashmatic.enemies.targets.area, target)
|
||||
else
|
||||
@ -136,11 +136,11 @@ function recreateTriggers()
|
||||
-- Grouping enemies by areas
|
||||
local thisArea = GetRoomAreaName(GetRoomArea(GetPlayerRoom())) or nil
|
||||
if thisArea == nil then
|
||||
cecho("<firebrick>Bashmatic: We attempted to locate your area but failed.\nGot: " .. thisArea .. "<reset>")
|
||||
cecho("\n<firebrick>Bashmatic: We attempted to locate your area but failed.\nGot: " .. thisArea .. "<reset>")
|
||||
return
|
||||
end
|
||||
if not table.contains(Bashmatic.enemies.targets, thisArea) then
|
||||
cecho("<firebrick>Bashmatic: You haven't added any enemies for the area " .. thisArea .. "<reset>")
|
||||
cecho("\n<firebrick>Bashmatic: You haven't added any enemies for the area " .. thisArea .. "<reset>")
|
||||
return
|
||||
end
|
||||
for _, keyword in ipairs(Bashmatic.enemies.targets.thisArea) do
|
||||
@ -189,7 +189,7 @@ function displayTargetList(start, endi, page, pages)
|
||||
end
|
||||
cecho(thisTable:assemble())
|
||||
if page ~= nil then
|
||||
cecho("<DarkSlateBlue>Displaying " .. start .. " to " .. endi .. " (Page " .. page .. " of " .. pages .. ")<reset>")
|
||||
cecho("\n<DarkSlateBlue>Displaying " .. start .. " to " .. endi .. " (Page " .. page .. " of " .. pages .. ")<reset>")
|
||||
end
|
||||
end
|
||||
|
||||
@ -217,9 +217,9 @@ function displayAreaTargetList(area, start, endi, page, pages)
|
||||
Bashmatic.enemies.targets.area[i]
|
||||
})
|
||||
end
|
||||
cecho("<MediumPurple>Target Listing for area " .. area .. "<reset>")
|
||||
cecho("\n<MediumPurple>Target Listing for area " .. area .. "<reset>")
|
||||
if page ~= nil then
|
||||
cecho("<DarkSlateBlue>Displaying " .. start .. " to " .. endi .. " (Page " .. page .. " of " .. pages .. ")<reset>")
|
||||
cecho("\n<DarkSlateBlue>Displaying " .. start .. " to " .. endi .. " (Page " .. page .. " of " .. pages .. ")<reset>")
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user