2023-09-02 07:01:35 -04:00
|
|
|
-----------------------------------
|
2021-07-16 14:57:37 -07:00
|
|
|
-- func: getmobmod <modID>
|
|
|
|
|
-- desc: gets a mod by ID on the player or cursor target
|
2023-09-02 07:01:35 -04:00
|
|
|
-----------------------------------
|
2024-08-25 10:54:45 -04:00
|
|
|
---@type TCommand
|
2023-09-02 07:01:35 -04:00
|
|
|
local commandObj = {}
|
|
|
|
|
|
|
|
|
|
commandObj.cmdprops =
|
2021-07-16 14:57:37 -07:00
|
|
|
{
|
|
|
|
|
permission = 1,
|
2023-08-28 21:02:28 -04:00
|
|
|
parameters = 's'
|
2021-07-16 14:57:37 -07:00
|
|
|
}
|
|
|
|
|
|
2023-09-02 07:01:35 -04:00
|
|
|
local function error(player, msg)
|
2023-12-09 23:54:00 +00:00
|
|
|
player:printToPlayer(msg)
|
|
|
|
|
player:printToPlayer('!getmod <modID>')
|
2021-07-16 14:57:37 -07:00
|
|
|
end
|
|
|
|
|
|
2023-09-02 07:01:35 -04:00
|
|
|
commandObj.onTrigger = function(player, id)
|
2022-05-28 12:49:18 -06:00
|
|
|
-- invert xi.mobMod table
|
2021-07-16 14:57:37 -07:00
|
|
|
local modNameByNum = {}
|
2022-05-28 12:49:18 -06:00
|
|
|
for k, v in pairs(xi.mobMod) do
|
2022-10-23 10:54:18 -04:00
|
|
|
modNameByNum[v] = k
|
2021-07-16 14:57:37 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- validate modID
|
|
|
|
|
id = string.upper(id)
|
|
|
|
|
local modId = tonumber(id)
|
2022-05-28 13:58:04 -06:00
|
|
|
local modName
|
2021-07-16 14:57:37 -07:00
|
|
|
|
2022-05-28 13:58:04 -06:00
|
|
|
if modId then
|
|
|
|
|
if modNameByNum[modId] then
|
2021-07-16 14:57:37 -07:00
|
|
|
modName = modNameByNum[modId]
|
|
|
|
|
end
|
2022-05-28 13:58:04 -06:00
|
|
|
elseif xi.mobMod[id] then
|
2022-05-28 12:49:18 -06:00
|
|
|
modId = xi.mobMod[id]
|
2021-07-16 14:57:37 -07:00
|
|
|
modName = id
|
|
|
|
|
end
|
2022-11-22 14:39:00 -05:00
|
|
|
|
2022-05-28 13:58:04 -06:00
|
|
|
if not modName or not modId then
|
2023-08-28 21:02:28 -04:00
|
|
|
error(player, 'Invalid modMobID.')
|
2021-07-16 14:57:37 -07:00
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- validate target
|
|
|
|
|
local effectTarget = player:getCursorTarget()
|
2022-05-28 13:58:04 -06:00
|
|
|
if not effectTarget or not effectTarget:isMob() then
|
2023-08-28 21:02:28 -04:00
|
|
|
error(player, 'Current target is not a MOB, which can not have mob mods.')
|
2021-07-16 14:57:37 -07:00
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
|
2023-12-09 23:54:00 +00:00
|
|
|
player:printToPlayer(string.format('%s\'s Mod %i (%s) is %i', effectTarget:getName(), modId, modName, effectTarget:getMobMod(modId)))
|
2021-07-16 14:57:37 -07:00
|
|
|
end
|
2023-09-02 07:01:35 -04:00
|
|
|
|
|
|
|
|
return commandObj
|