mirror of
https://gitlab.com/hoggit/developers/hoggit.git
synced 2025-11-10 15:43:28 +00:00
Added debug_text function, established debug flag
This commit is contained in:
parent
004536f4d5
commit
a23baf00e8
23
hoggit.lua
23
hoggit.lua
@ -1,14 +1,25 @@
|
|||||||
-- Development mode. This module is defined and configured with a base config
|
-- Development mode. This module is defined and configured with a base config
|
||||||
-- in the game install Scripts folder in development mode.
|
-- in the game install Scripts folder in development mode.
|
||||||
if HOGGIT and HOGGIT.script_base then
|
if HOGGIT and HOGGIT.script_base then
|
||||||
dofile(HOGGIT.script_base..[[\HOGGIT\lib\error_handling.lua]])
|
dofile(HOGGIT.script_base..[[\HOGGIT\hoggit\error_handling.lua]])
|
||||||
dofile(HOGGIT.script_base..[[\HOGGIT\lib\logging.lua]])
|
dofile(HOGGIT.script_base..[[\HOGGIT\hoggit\logging.lua]])
|
||||||
dofile(HOGGIT.script_base..[[\HOGGIT\lib\utils.lua]])
|
dofile(HOGGIT.script_base..[[\HOGGIT\hoggit\utils.lua]])
|
||||||
dofile(HOGGIT.script_base..[[\HOGGIT\lib\spawner.lua]])
|
dofile(HOGGIT.script_base..[[\HOGGIT\hoggit\spawner.lua]])
|
||||||
dofile(HOGGIT.script_base..[[\HOGGIT\lib\communication.lua]])
|
dofile(HOGGIT.script_base..[[\HOGGIT\hoggit\communication.lua]])
|
||||||
dofile(HOGGIT.script_base..[[\HOGGIT\lib\group.lua]])
|
dofile(HOGGIT.script_base..[[\HOGGIT\hoggit\group.lua]])
|
||||||
else
|
else
|
||||||
-- The dist version of this framework starts with this file in the minification, so we need to define the top
|
-- The dist version of this framework starts with this file in the minification, so we need to define the top
|
||||||
-- level module right here.
|
-- level module right here.
|
||||||
HOGGIT = {}
|
HOGGIT = {}
|
||||||
|
end
|
||||||
|
|
||||||
|
if trigger.misc.getUserFlag(9999) then
|
||||||
|
trigger.action.outText("DEBUG MODE ON", 10)
|
||||||
|
HOGGIT.debug = true
|
||||||
|
HOGGIT.debug_text = function(text, time)
|
||||||
|
trigger.action.outText(text, time)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
HOGGIT.debug = false
|
||||||
|
HOGGIT.debug_text = function()end
|
||||||
end
|
end
|
||||||
@ -61,7 +61,7 @@ HOGGIT.Spawner = function(grpName)
|
|||||||
SpawnedGroups[added_grp] = true
|
SpawnedGroups[added_grp] = true
|
||||||
if zombie then
|
if zombie then
|
||||||
HOGGIT.setZombie(added_grp, self, true)
|
HOGGIT.setZombie(added_grp, self, true)
|
||||||
trigger.action.outText("Spawned new zombie " .. added_grp:getName(), 3)
|
HOGGIT.debug_text("Spawned new zombie " .. added_grp:getName(), 3)
|
||||||
end
|
end
|
||||||
return added_grp
|
return added_grp
|
||||||
end,
|
end,
|
||||||
@ -89,7 +89,7 @@ HOGGIT.Spawner = function(grpName)
|
|||||||
if zombie then HOGGIT.setZombie(added_grp, self, true) end
|
if zombie then HOGGIT.setZombie(added_grp, self, true) end
|
||||||
return added_grp
|
return added_grp
|
||||||
else
|
else
|
||||||
trigger.action.outText("Error spawning " .. grpName, 15)
|
HOGGIT.debug_text("Error spawning " .. grpName, 15)
|
||||||
end
|
end
|
||||||
|
|
||||||
end,
|
end,
|
||||||
@ -194,48 +194,48 @@ end
|
|||||||
|
|
||||||
HOGGIT._deathHandler = function(event)
|
HOGGIT._deathHandler = function(event)
|
||||||
if event.id ~= world.event.S_EVENT_DEAD then return end
|
if event.id ~= world.event.S_EVENT_DEAD then return end
|
||||||
trigger.action.outText("SOMETHING DEAD YO", 10)
|
HOGGIT.debug_text("SOMETHING DEAD YO", 10)
|
||||||
if not event.initiator then return end
|
if not event.initiator then return end
|
||||||
if not event.initiator.getGroup then return end
|
if not event.initiator.getGroup then return end
|
||||||
|
|
||||||
local grp = event.initiator:getGroup():getName()
|
local grp = event.initiator:getGroup():getName()
|
||||||
if grp then
|
if grp then
|
||||||
trigger.action.outText("FOUND GROUP", 10)
|
HOGGIT.debug_text("FOUND GROUP", 10)
|
||||||
if HOGGIT.zombies[grp] then
|
if HOGGIT.zombies[grp] then
|
||||||
trigger.action.outText("CONFIRMED ZOMBIE", 10)
|
HOGGIT.debug_text("CONFIRMED ZOMBIE", 10)
|
||||||
local spawner = HOGGIT.zombies[grp]
|
local spawner = HOGGIT.zombies[grp]
|
||||||
trigger.action.outText("FOUND SPAWNER", 10)
|
HOGGIT.debug_text("FOUND SPAWNER", 10)
|
||||||
if HOGGIT.zombie_checks[spawner] then
|
if HOGGIT.zombie_checks[spawner] then
|
||||||
trigger.action.outText("FOUND SPAWNER CHECK", 10)
|
HOGGIT.debug_text("FOUND SPAWNER CHECK", 10)
|
||||||
local s_func_id = HOGGIT.zombie_checks[spawner]
|
local s_func_id = HOGGIT.zombie_checks[spawner]
|
||||||
mist.removeFunction(s_func_id)
|
mist.removeFunction(s_func_id)
|
||||||
trigger.action.outText("Removing dead check id ".. s_func_id .." for group: " .. grp, 10)
|
HOGGIT.debug_text("Removing dead check id ".. s_func_id .." for group: " .. grp, 10)
|
||||||
end
|
end
|
||||||
local new_func_id = mist.scheduleFunction(function()
|
local new_func_id = mist.scheduleFunction(function()
|
||||||
trigger.action.outText("STARTING DEAD CHECK", 10)
|
HOGGIT.debug_text("STARTING DEAD CHECK", 10)
|
||||||
local needs_respawn = false
|
local needs_respawn = false
|
||||||
local partial_respawn = false
|
local partial_respawn = false
|
||||||
if not HOGGIT.GroupIsAlive(grp) then
|
if not HOGGIT.GroupIsAlive(grp) then
|
||||||
needs_respawn = true
|
needs_respawn = true
|
||||||
trigger.action.outText("THEY DEAD, RESPAWNIN", 10)
|
HOGGIT.debug_text("THEY DEAD, RESPAWNIN", 10)
|
||||||
elseif spawner:GetPartialDeathThresholdPercent() then
|
elseif spawner:GetPartialDeathThresholdPercent() then
|
||||||
trigger.action.outText("CHECKING PERCENT", 10)
|
HOGGIT.debug_text("CHECKING PERCENT", 10)
|
||||||
local group_obj = Group.getByName(grp)
|
local group_obj = Group.getByName(grp)
|
||||||
local group_size = group_obj:getSize()
|
local group_size = group_obj:getSize()
|
||||||
local initial_size = group_obj:getInitialSize()
|
local initial_size = group_obj:getInitialSize()
|
||||||
local percent_alive = group_size / initial_size * 100
|
local percent_alive = group_size / initial_size * 100
|
||||||
trigger.action.outText(percent_alive .. " percent alive. Threshold is " .. spawner:GetPartialDeathThresholdPercent(), 10)
|
HOGGIT.debug_text(percent_alive .. " percent alive. Threshold is " .. spawner:GetPartialDeathThresholdPercent(), 10)
|
||||||
if (100 - percent_alive) >= spawner:GetPartialDeathThresholdPercent() then
|
if (100 - percent_alive) >= spawner:GetPartialDeathThresholdPercent() then
|
||||||
trigger.action.outText("TRIGGERING PARTIAL RESPAWNING", 10)
|
HOGGIT.debug_text("TRIGGERING PARTIAL RESPAWNING", 10)
|
||||||
needs_respawn = true
|
needs_respawn = true
|
||||||
partial_respawn = true
|
partial_respawn = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if needs_respawn then
|
if needs_respawn then
|
||||||
trigger.action.outText("GROUP NEEDS RESPAWNING", 10)
|
HOGGIT.debug_text("GROUP NEEDS RESPAWNING", 10)
|
||||||
local delay = spawner:GetRespawnDelay(partial_respawn)
|
local delay = spawner:GetRespawnDelay(partial_respawn)
|
||||||
trigger.action.outText("DELAY OF " .. delay, 10)
|
HOGGIT.debug_text("DELAY OF " .. delay, 10)
|
||||||
HOGGIT.zombies[grp] = nil
|
HOGGIT.zombies[grp] = nil
|
||||||
|
|
||||||
mist.scheduleFunction(function()
|
mist.scheduleFunction(function()
|
||||||
@ -246,19 +246,11 @@ HOGGIT._deathHandler = function(event)
|
|||||||
|
|
||||||
end, {}, timer.getTime() + 10)
|
end, {}, timer.getTime() + 10)
|
||||||
|
|
||||||
trigger.action.outText("Scheduled NEW dead check id ".. new_func_id .." for group: " .. grp, 10)
|
HOGGIT.debug_text("Scheduled NEW dead check id ".. new_func_id .." for group: " .. grp, 10)
|
||||||
HOGGIT.zombie_checks[spawner] = new_func_id
|
HOGGIT.zombie_checks[spawner] = new_func_id
|
||||||
else
|
else
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
mist.scheduleFunction(function()
|
|
||||||
trigger.action.outText("Showing current zombies", 10)
|
|
||||||
for i,data in pairs(HOGGIT.zombies) do
|
|
||||||
if HOGGIT.zombies[i] then trigger.action.outText("TOOOO", 10) end
|
|
||||||
if HOGGIT.zombies['IRAN gnd 1'] then trigger.action.outText("DOOOOOO", 10) end
|
|
||||||
end
|
|
||||||
|
|
||||||
end, {}, timer.getTime() + 40)
|
|
||||||
mist.addEventHandler(HOGGIT._deathHandler)
|
mist.addEventHandler(HOGGIT._deathHandler)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user