Add configuration option adv_spawing.debug to show or hide spawner entities

Fix quota overflow calculation
Add rightclick function to show debug info
master
sapier 2014-07-20 18:12:05 +02:00
parent 2adf3a643c
commit fa023f2905
4 changed files with 37 additions and 9 deletions

View File

@ -1,6 +1,6 @@
********************************************************************************
* *
* Advanced spawning mod (adv_spawning) 0.0.5 *
* Advanced spawning mod (adv_spawning) 0.0.6 *
* *
* URL: http://github.com/sapier/adv_spawning *
* Author: sapier *
@ -191,6 +191,11 @@ Statistics:
Changelog:
0.0.6
-add configuration option adv_spawing.debug to show or hide spawner entities
-fix quota overflow calculation
-add rightclick function to show debug info
0.0.5
-fix MIN/MAX to always return a number value
-fix default activity range to use a initial value if not manually configured

View File

@ -8,10 +8,10 @@
--
-------------------------------------------------------------------------------
local version = "0.0.5"
local version = "0.0.6"
if adv_spawning ~= nil then
minetest.log("error","MOD: adv_spawning requires adv_spawning variable to be available")
core.log("error","MOD: adv_spawning requires adv_spawning variable to be available")
end
--------------------------------------------------------------------------------
@ -19,7 +19,9 @@ end
-- -----------------------------------------------------------------------------
adv_spawning = {}
local adv_modpath = minetest.get_modpath("adv_spawning")
adv_spawning.debug = core.setting_get("adv_spawning.debug")
local adv_modpath = core.get_modpath("adv_spawning")
dofile (adv_modpath .. "/internal.lua")
dofile (adv_modpath .. "/spawndef_checks.lua")

View File

@ -212,8 +212,12 @@ function adv_spawning.global_onstep(dtime)
adv_spawning.statistics.session.steps
--reduce following quota by overtime from last step
adv_spawning.quota_left =
adv_spawning.MAX(0,adv_spawning.quota_left+adv_spawning.quota_reload)
if adv_spawning.quota_left < 0 then
adv_spawning.quota_left =
adv_spawning.MAX(0,adv_spawning.quota_left + adv_spawning.quota_reload)
else
adv_spawning.quota_left = adv_spawning.quota_reload
end
if adv_spawning.quota_enter() then
adv_spawning.handle_mapgen_spawning()

View File

@ -113,6 +113,22 @@ function adv_spawning.seed_activate(self)
end
end
--------------------------------------------------------------------------------
-- @function [parent=#adv_spawning] on_rightclick
-- @param self spawner entity
-- @param clicker (unused)
--------------------------------------------------------------------------------
function adv_spawning.on_rightclick(self, clicker)
if adv_spawning.debug then
print("ADV_SPAWNING: Spawner may spawn following mobs:")
local index = 1
for key,value in pairs(self.spawning_data) do
print(string.format("%3d:",index) .. string.format("%30s ",key) .. string.format("%3d s", value))
index = index +1
end
end
end
--------------------------------------------------------------------------------
-- @function [parent=#adv_spawning] seed_initialize
--------------------------------------------------------------------------------
@ -121,10 +137,10 @@ function adv_spawning.seed_initialize()
local spawner_texture = "adv_spawning_invisible.png^[makealpha:128,0,0^[makealpha:128,128,0"
local spawner_collisionbox = { 0.0,0.0,0.0,0.0,0.0,0.0}
--if debug
if adv_spawning.debug then
spawner_texture = "adv_spawning_spawner.png"
spawner_collisionbox = { -0.5,-0.5,-0.5,0.5,0.5,0.5 }
--end
end
minetest.register_entity("adv_spawning:spawn_seed",
{
@ -142,7 +158,8 @@ function adv_spawning.seed_initialize()
on_step = adv_spawning.seed_step,
get_staticdata = function(self)
return minetest.serialize(self.spawning_data)
end
end,
on_rightclick = adv_spawning.on_rightclick
}
)
end