Add CHAR_STATE constants to GMCPHandler, update existing GMCP checks to use those

main
AreiaAard 4 years ago
parent a7540a61cc
commit f43158cdbd

@ -66,8 +66,8 @@ function Main.initialize()
end end
function Main.kill(alias, line, wc) function Main.kill(alias, line, wc)
local state = tonumber(gmcp("char.status.state")) local state = GMCPHandler.get_char_state()
if not (state == 3 or state == 8) then if not (state == GMCPHandler.CHAR_STATE.ACTIVE or state == GMCPHandler.CHAR_STATE.FIGHTING) then
Utility.print("Character's state does not allow kill.") Utility.print("Character's state does not allow kill.")
return return
end end
@ -92,8 +92,8 @@ function Main.kill(alias, line, wc)
end end
function Main.kill_all(alias, line, wc) function Main.kill_all(alias, line, wc)
local state = tonumber(gmcp("char.status.state")) local state = GMCPHandler.get_char_state()
if not (state == 3 or state == 8) then if not (state == GMCPHandler.CHAR_STATE.ACTIVE or state == GMCPHandler.CHAR_STATE.FIGHTING) then
Utility.print("Character's state does not allow kill.") Utility.print("Character's state does not allow kill.")
return return
end end
@ -406,8 +406,8 @@ function Consider.clear()
end end
function Consider.start() function Consider.start()
local state = tonumber(gmcp("char.status.state")) local state = GMCPHandler.get_char_state()
if not (state == 3 or state == 8) then -- neither active nor in combat if not (state == GMCPHandler.CHAR_STATE.ACTIVE or state == GMCPHandler.CHAR_STATE.FIGHTING) then
Utility.print("Character state does not allow consider.") Utility.print("Character state does not allow consider.")
return return
end end
@ -518,10 +518,20 @@ end
GMCPHandler = {} GMCPHandler = {}
function GMCPHandler.initialize() function GMCPHandler.initialize()
GMCPHandler.CHAR_STATE = {
["LOGIN"] = 1, ["MOTD"] = 2, ["ACTIVE"] = 3, ["AFK"] = 4, ["NOTE"] = 5,
["BUILDING"] = 6, ["PAGER"] = 7, ["FIGHTING"] = 8, ["SLEEPING"] = 9,
["SITTING"] = 11, ["RUNNING"] = 12,
}
GMCPHandler.gmcpInitialized = false GMCPHandler.gmcpInitialized = false
GMCPHandler.prevRoom = {} GMCPHandler.prevRoom = {}
end end
function GMCPHandler.get_char_state()
return tonumber(gmcp("char.status.state"))
end
function GMCPHandler.received_room(room) function GMCPHandler.received_room(room)
GMCPHandler.prevRoom = room GMCPHandler.prevRoom = room
end end

Loading…
Cancel
Save