2021-01-18 13:34:00 -05:00
|
|
|
-----------------------------------
|
2018-12-16 23:20:37 -07:00
|
|
|
-- func: getmobflags <optional MobID>
|
|
|
|
|
-- desc: Used to get a mob's entity flags for testing.
|
|
|
|
|
-- MUST either target a mob first or else specify a Mob ID.
|
2021-01-18 13:34:00 -05:00
|
|
|
-----------------------------------
|
2024-08-25 10:54:45 -04:00
|
|
|
---@type TCommand
|
2023-09-02 07:01:35 -04:00
|
|
|
local commandObj = {}
|
2018-12-16 23:20:37 -07:00
|
|
|
|
2023-09-02 07:01:35 -04:00
|
|
|
commandObj.cmdprops =
|
2018-12-16 23:20:37 -07:00
|
|
|
{
|
|
|
|
|
permission = 1,
|
2023-08-28 21:02:28 -04:00
|
|
|
parameters = 'i'
|
2018-12-16 23:20: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('!getmobflags (mob ID)')
|
2018-12-16 23:20:37 -07:00
|
|
|
end
|
|
|
|
|
|
2023-09-02 07:01:35 -04:00
|
|
|
commandObj.onTrigger = function(player, target)
|
2018-12-16 23:20:37 -07:00
|
|
|
-- validate target
|
|
|
|
|
local targ
|
|
|
|
|
if not target then
|
|
|
|
|
targ = player:getCursorTarget()
|
2018-12-16 23:44:35 -07:00
|
|
|
if not targ or not targ:isMob() then
|
2023-08-28 21:02:28 -04:00
|
|
|
error(player, 'You must either supply a mob ID or target a mob.')
|
2018-12-16 23:20:37 -07:00
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
targ = GetMobByID(target)
|
|
|
|
|
if not targ then
|
2023-08-28 21:02:28 -04:00
|
|
|
error(player, 'Invalid mob ID.')
|
2018-12-16 23:20:37 -07:00
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- set flags
|
|
|
|
|
local flags = targ:getMobFlags()
|
2023-08-28 21:02:28 -04:00
|
|
|
local hex = '0x' .. string.format('%08x', flags)
|
2023-12-09 23:54:00 +00:00
|
|
|
player:printToPlayer(string.format('%s\'s flags: %s (%u)', targ:getName(), hex, flags))
|
2020-03-19 18:41:42 -07:00
|
|
|
end
|
2023-09-02 07:01:35 -04:00
|
|
|
|
|
|
|
|
return commandObj
|