From f43158cdbdd227bf9a93b7ea833314316811c679 Mon Sep 17 00:00:00 2001 From: AreiaAard Date: Sun, 18 Apr 2021 15:15:56 -0400 Subject: [PATCH] Add CHAR_STATE constants to GMCPHandler, update existing GMCP checks to use those --- areia_consider.xml | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/areia_consider.xml b/areia_consider.xml index 98f83b1..7d90423 100644 --- a/areia_consider.xml +++ b/areia_consider.xml @@ -66,8 +66,8 @@ function Main.initialize() end function Main.kill(alias, line, wc) - local state = tonumber(gmcp("char.status.state")) - if not (state == 3 or state == 8) then + local state = GMCPHandler.get_char_state() + if not (state == GMCPHandler.CHAR_STATE.ACTIVE or state == GMCPHandler.CHAR_STATE.FIGHTING) then Utility.print("Character's state does not allow kill.") return end @@ -92,8 +92,8 @@ function Main.kill(alias, line, wc) end function Main.kill_all(alias, line, wc) - local state = tonumber(gmcp("char.status.state")) - if not (state == 3 or state == 8) then + local state = GMCPHandler.get_char_state() + if not (state == GMCPHandler.CHAR_STATE.ACTIVE or state == GMCPHandler.CHAR_STATE.FIGHTING) then Utility.print("Character's state does not allow kill.") return end @@ -406,8 +406,8 @@ function Consider.clear() end function Consider.start() - local state = tonumber(gmcp("char.status.state")) - if not (state == 3 or state == 8) then -- neither active nor in combat + local state = GMCPHandler.get_char_state() + if not (state == GMCPHandler.CHAR_STATE.ACTIVE or state == GMCPHandler.CHAR_STATE.FIGHTING) then Utility.print("Character state does not allow consider.") return end @@ -518,10 +518,20 @@ end GMCPHandler = {} 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.prevRoom = {} end +function GMCPHandler.get_char_state() + return tonumber(gmcp("char.status.state")) +end + function GMCPHandler.received_room(room) GMCPHandler.prevRoom = room end