From 643b63e91a416b2bbd0a55d1db815240e4704608 Mon Sep 17 00:00:00 2001 From: Juraj Vajda Date: Tue, 12 Jan 2016 22:26:44 +0100 Subject: [PATCH] performance tweaks and config beginning --- config.lua | 25 +++++++++++++++++++++++++ init.lua | 23 +++++++++++++++++------ 2 files changed, 42 insertions(+), 6 deletions(-) create mode 100644 config.lua diff --git a/config.lua b/config.lua new file mode 100644 index 0000000..eda7c79 --- /dev/null +++ b/config.lua @@ -0,0 +1,25 @@ +-- mod what should be enabled and loded +ENABLED_MODS = {"mobs", "pyramids", "creatures"} + +-- mobs properties - setup all you mobs here +MOBS_PROPS = { + ["mobs"] = { + {name = "mobs name 1"}, + {name = "mobs name 2"}, + {name = "mobs name 3"}, + }, + + ["pyramids"] = { + {name = "pyramids name 1"}, + {name = "pyramids name 2"}, + {name = "pyramids name 3"} + }, + + + ["creatures"] = { + {name = "creatures name 1"}, + {name = "creatures name 2"}, + {name = "creatures name 3"} + } + +} diff --git a/init.lua b/init.lua index feb73d2..554e21d 100644 --- a/init.lua +++ b/init.lua @@ -1,11 +1,22 @@ +-- user settings local max_obj_per_mapblock = tonumber(minetest.setting_get("max_objects_per_block")) - +dofile(minetest.get_modpath("spawners").."/config.lua") -- main table spawners = {} -- list of mods spawners.mob_mods = {"mobs", "pyramids", "creatures"} -- table holding all mobs info spawners.mob_tables = {} +for k, mod1 in ipairs(ENABLED_MODS) do + print("********************** key: "..k..", val: "..mod1) + + for j, mobs1 in ipairs(MOBS_PROPS[mod1]) do + print(mobs1.name) + + + + end +end -- check if mods exists and build tables for k, v in ipairs(spawners.mob_mods) do @@ -90,7 +101,7 @@ function spawners.check_around_radius(pos) local player_near = false local radius = 21 - for _,obj in ipairs(minetest.get_objects_inside_radius(pos, radius)) do + for _,obj in ipairs(minetest.get_objects_inside_radius(pos, radius)) do if obj:is_player() then player_near = true end @@ -300,6 +311,7 @@ function spawners.create(mob_name, mod_prefix, size, offset, mesh, texture, nigh light_source = 2, drawtype = "allfaces", walkable = true, + catch_up = false, damage_per_second = 4, sunlight_propagates = true, tiles = {"spawners_spawner.png^[colorize:#FF000030"}, @@ -318,10 +330,9 @@ function spawners.create(mob_name, mod_prefix, size, offset, mesh, texture, nigh minetest.register_abm({ nodenames = {"spawners:"..mod_prefix.."_"..mob_name.."_spawner", "spawners:"..mod_prefix.."_"..mob_name.."_spawner_active", "spawners:"..mod_prefix.."_"..mob_name.."_spawner_overheat", "spawners:"..mod_prefix.."_"..mob_name.."_spawner_waiting"}, neighbors = {"air"}, - interval = 2.0, - chance = 20, + interval = 5.0, + chance = 8, action = function(pos, node, active_object_count, active_object_count_wider) - local random_pos, waiting = spawners.check_node_status(pos, mob_name, night_only) @@ -398,4 +409,4 @@ for i, mob_table in ipairs(spawners.mob_tables) do end end -print ("[MOD] Spawners 0.2 Loaded.") \ No newline at end of file +print ("[MOD] Spawners 0.3 Loaded.") \ No newline at end of file