From 15256967eb8bc1db7e99906ab20c4184d7bf5bc9 Mon Sep 17 00:00:00 2001 From: davedevils Date: Fri, 3 Jul 2015 06:57:09 +0200 Subject: [PATCH] Adding timer for look how many time need for load --- mods/DOM/watch/init.lua | 5 +- mods/WorldEdit/worldedit/init.lua | 4 +- mods/boat/init.lua | 4 +- mods/chat_rewirte/init.lua | 4 +- mods/default/functions.lua | 7 +- mods/default/init.lua | 17 ++- mods/doors/init.lua | 4 +- mods/farming/hoes.lua | 19 +-- mods/fences/init.lua | 3 + mods/fire/init.lua | 7 +- mods/fire/init.lua~ | 195 ++++++++++++++++++++++++++++++ mods/flowers/init.lua | 4 +- mods/hardened_clay/init.lua | 4 + mods/inventory/init.lua | 4 + mods/mobs/init.lua | 15 ++- mods/redstone/mesecons/init.lua | 8 +- mods/stairs/init.lua | 5 +- 17 files changed, 272 insertions(+), 37 deletions(-) create mode 100644 mods/fire/init.lua~ diff --git a/mods/DOM/watch/init.lua b/mods/DOM/watch/init.lua index e858c0592..31640ae79 100644 --- a/mods/DOM/watch/init.lua +++ b/mods/DOM/watch/init.lua @@ -4,6 +4,7 @@ Original from Echo, here: http://forum.minetest.net/viewtopic.php?id=3795 ]]-- +local init = os.clock() --Rotinas usadas pelo mod dofile(minetest.get_modpath("watch").."/rotinas.lua") @@ -11,5 +12,5 @@ dofile(minetest.get_modpath("watch").."/rotinas.lua") --Declarações dos objetos dofile(minetest.get_modpath("watch").."/itens.lua") --- Apenas para indicar que este módulo foi completamente carregado. -DOM_mb(minetest.get_current_modname(),minetest.get_modpath(minetest.get_current_modname())) +local time_to_load= os.clock() - init +print(string.format("[MOD] "..minetest.get_current_modname().." loaded in %.4f s", time_to_load)) diff --git a/mods/WorldEdit/worldedit/init.lua b/mods/WorldEdit/worldedit/init.lua index 91cbf4758..7c8e03983 100644 --- a/mods/WorldEdit/worldedit/init.lua +++ b/mods/WorldEdit/worldedit/init.lua @@ -1,3 +1,4 @@ +local init = os.clock() worldedit = {} worldedit.version = {major=1, minor=0} worldedit.version_string = "1.0" @@ -22,4 +23,5 @@ loadmodule(path .. "/serialization.lua") loadmodule(path .. "/code.lua") loadmodule(path .. "/compatibility.lua") -print("[MOD] WorldEdit loaded!") +local time_to_load= os.clock() - init +print(string.format("[MOD] "..minetest.get_current_modname().." loaded in %.4f s", time_to_load)) diff --git a/mods/boat/init.lua b/mods/boat/init.lua index 11bfbbf97..cfcdc4c8b 100644 --- a/mods/boat/init.lua +++ b/mods/boat/init.lua @@ -1,6 +1,7 @@ -- -- Helper functions -- +local init = os.clock() local function is_water(pos) local nn = minetest.get_node(pos).name @@ -173,4 +174,5 @@ minetest.register_craft({ }, }) -minetest.debug("[boat] Mod loaded") \ No newline at end of file +local time_to_load= os.clock() - init +print(string.format("[MOD] "..minetest.get_current_modname().." loaded in %.4f s", time_to_load)) diff --git a/mods/chat_rewirte/init.lua b/mods/chat_rewirte/init.lua index 47dce771a..e604a1aae 100644 --- a/mods/chat_rewirte/init.lua +++ b/mods/chat_rewirte/init.lua @@ -1,4 +1,4 @@ - +local init = os.clock() -- config zone {{{ formats = { -- ["MATCH"] = {"FORMAT" COLOR PRIV}, -- @@ -106,3 +106,5 @@ minetest.register_on_chat_message(function(name, message) return true end) +local time_to_load= os.clock() - init +print(string.format("[MOD] "..minetest.get_current_modname().." loaded in %.4f s", time_to_load)) diff --git a/mods/default/functions.lua b/mods/default/functions.lua index 62c2f0003..c964b0f49 100644 --- a/mods/default/functions.lua +++ b/mods/default/functions.lua @@ -553,10 +553,13 @@ minetest.register_abm({ interval = 30, chance = 20, action = function(pos) + if pos == nil then + return + end local can_change = 0 for i=1,4 do - p = {x=pos.x, y=pos.y+i, z=pos.z} - n = minetest.env:get_node(p) + local p = {x=pos.x, y=pos.y+i, z=pos.z} + local n = minetest.env:get_node(p) -- On verifie si il y a de l'air if (n.name=="air") then can_change = can_change + 1 diff --git a/mods/default/init.lua b/mods/default/init.lua index a562f3102..d27d7b8e2 100644 --- a/mods/default/init.lua +++ b/mods/default/init.lua @@ -1,6 +1,6 @@ -- Minetest 0.4 mod: default -- See README.txt for licensing and other information. - +local init = os.clock() -- The API documentation in here was moved into doc/lua_api.txt WATER_ALPHA = 160 @@ -8,6 +8,16 @@ WATER_VISC = 1 LAVA_VISC = 7 LIGHT_MAX = 20 +-- Show the ModPack Name :D +print(" __ __ _ _____ _ ___ ___ _ _ ") +print("| \\/ (_) / ____| | / _ \\ |__ \\| || | ") +print("| \\ / |_ _ __ ___| | | | ___ _ __ ___ __ _| | | | ) | || |_ ") +print("| |\\/| | | '_ \\ / _ \\ | | |/ _ \\| '_ \\ / _ \\ \\ \\ / / | | | / /|__ _|") +print("| | | | | | | | __/ |____| | (_) | | | | __/ \\ V /| |_| | / /_ | | ") +print("|_| |_|_|_| |_|\\___|\\_____|_|\\___/|_| |_|\\___| \\_/ \\___(_)____| |_| ") + + + -- Definitions made by this mod that other mods can use too default = {} @@ -24,4 +34,7 @@ dofile(minetest.get_modpath("default").."/player.lua") minetest.register_alias("default:desert_sand", "default:sand") minetest.register_alias("default:desert_stone", "default:sandstone") minetest.register_alias("default:iron_lump", "default:stone_with_iron") -minetest.register_alias("default:gold_lump", "default:stone_with_gold") \ No newline at end of file +minetest.register_alias("default:gold_lump", "default:stone_with_gold") + +local time_to_load= os.clock() - init +print(string.format("[MOD] "..minetest.get_current_modname().." loaded in %.4f s", time_to_load)) diff --git a/mods/doors/init.lua b/mods/doors/init.lua index 391091c90..b33e788f1 100644 --- a/mods/doors/init.lua +++ b/mods/doors/init.lua @@ -1,3 +1,4 @@ +local init = os.clock() doors = {} -- Registers a door @@ -638,4 +639,5 @@ minetest.register_craft({ } }) -print('[OK] Doors loaded!') \ No newline at end of file +local time_to_load= os.clock() - init +print(string.format("[MOD] "..minetest.get_current_modname().." loaded in %.4f s", time_to_load)) diff --git a/mods/farming/hoes.lua b/mods/farming/hoes.lua index 9b9542382..5041a56b3 100644 --- a/mods/farming/hoes.lua +++ b/mods/farming/hoes.lua @@ -1,4 +1,4 @@ -local function create_soil(pos, inv, p) +local function create_soil(pos, inv) if pos == nil then return false end @@ -9,13 +9,6 @@ local function create_soil(pos, inv, p) if above.name == "air" then node.name = "farming:soil" minetest.env:set_node(pos, node) - if inv and p and name == "default:dirt_with_grass" then - for name,rarity in pairs(farming.seeds) do - if math.random(1, rarity-p) == 1 then - inv:add_item("main", ItemStack(name)) - end - end - end return true end end @@ -26,7 +19,7 @@ minetest.register_tool("farming:hoe_wood", { description = "Wood Hoe", inventory_image = "farming_tool_woodhoe.png", on_place = function(itemstack, user, pointed_thing) - if create_soil(pointed_thing.under, user:get_inventory(), 0) then + if create_soil(pointed_thing.under, user:get_inventory()) then if not minetest.setting_getbool("creative_mode") then itemstack:add_wear(65535/30) end @@ -48,7 +41,7 @@ minetest.register_tool("farming:hoe_stone", { description = "Stone Hoe", inventory_image = "farming_tool_stonehoe.png", on_place = function(itemstack, user, pointed_thing) - if create_soil(pointed_thing.under, user:get_inventory(), 5) then + if create_soil(pointed_thing.under, user:get_inventory()) then if not minetest.setting_getbool("creative_mode") then itemstack:add_wear(65535/50) end @@ -70,7 +63,7 @@ minetest.register_tool("farming:hoe_steel", { description = "Steel Hoe", inventory_image = "farming_tool_steelhoe.png", on_place = function(itemstack, user, pointed_thing) - if create_soil(pointed_thing.under, user:get_inventory(), 10) then + if create_soil(pointed_thing.under, user:get_inventory()) then if not minetest.setting_getbool("creative_mode") then itemstack:add_wear(65535/80) end @@ -92,7 +85,7 @@ minetest.register_tool("farming:hoe_gold", { description = "Gold Hoe", inventory_image = "farming_tool_goldhoe.png", on_place = function(itemstack, user, pointed_thing) - if create_soil(pointed_thing.under, user:get_inventory(), 7) then + if create_soil(pointed_thing.under, user:get_inventory()) then if not minetest.setting_getbool("creative_mode") then itemstack:add_wear(65535/60) end @@ -114,7 +107,7 @@ minetest.register_tool("farming:hoe_diamond", { description = "Diamond Hoe", inventory_image = "farming_tool_diamondhoe.png", on_place = function(itemstack, user, pointed_thing) - if create_soil(pointed_thing.under, user:get_inventory(), 15) then + if create_soil(pointed_thing.under, user:get_inventory()) then if not minetest.setting_getbool("creative_mode") then itemstack:add_wear(65535/120) end diff --git a/mods/fences/init.lua b/mods/fences/init.lua index 11d4e0693..8dc87e745 100644 --- a/mods/fences/init.lua +++ b/mods/fences/init.lua @@ -1,3 +1,4 @@ +local init = os.clock() local override_original = true --change to "true" if you want original and placed fences replaced local function dockable(nodename) @@ -690,3 +691,5 @@ if override_original == true then end }) end +local time_to_load= os.clock() - init +print(string.format("[MOD] "..minetest.get_current_modname().." loaded in %.4f s", time_to_load)) diff --git a/mods/fire/init.lua b/mods/fire/init.lua index b9dedbe01..2a67ffe3a 100644 --- a/mods/fire/init.lua +++ b/mods/fire/init.lua @@ -1,5 +1,5 @@ -- minetest/fire/init.lua - +local init = os.clock() minetest.register_node("fire:basic_flame", { description = "Fire", drawtype = "plantlike", @@ -156,6 +156,7 @@ minetest.register_abm({ chance = 2, action = function(p0, node, _, _) -- If there is water or stuff like that around flame, remove flame + if fire.flame_should_extinguish(p0) then minetest.remove_node(p0) fire.on_flame_remove_at(p0) @@ -190,3 +191,7 @@ minetest.register_abm({ end, }) +local time_to_load= os.clock() - init +print(string.format("[MOD] "..minetest.get_current_modname().." loaded in %.4f s", time_to_load)) + + diff --git a/mods/fire/init.lua~ b/mods/fire/init.lua~ new file mode 100644 index 000000000..6dccf6be3 --- /dev/null +++ b/mods/fire/init.lua~ @@ -0,0 +1,195 @@ +-- minetest/fire/init.lua +local init = os.clock() +minetest.register_node("fire:basic_flame", { + description = "Fire", + drawtype = "plantlike", + tiles = {{ + name="fire_basic_flame_animated.png", + animation={type="vertical_frames", aspect_w=32, aspect_h=32, length=1}, + }}, + inventory_image = "fire_basic_flame.png", + light_source = 14, + groups = {igniter=2,dig_immediate=3,hot=3,dig_by_water=1}, + drop = '', + walkable = false, + buildable_to = true, + damage_per_second = 4, + + after_place_node = function(pos, placer) + fire.on_flame_add_at(pos) + end, + + after_dig_node = function(pos, oldnode, oldmetadata, digger) + fire.on_flame_remove_at(pos) + end, +}) + +fire = {} +fire.D = 6 +-- key: position hash of low corner of area +-- value: {handle=sound handle, name=sound name} +fire.sounds = {} + +function fire.get_area_p0p1(pos) + local p0 = { + x=math.floor(pos.x/fire.D)*fire.D, + y=math.floor(pos.y/fire.D)*fire.D, + z=math.floor(pos.z/fire.D)*fire.D, + } + local p1 = { + x=p0.x+fire.D-1, + y=p0.y+fire.D-1, + z=p0.z+fire.D-1 + } + return p0, p1 +end + +function fire.update_sounds_around(pos) + local p0, p1 = fire.get_area_p0p1(pos) + local cp = {x=(p0.x+p1.x)/2, y=(p0.y+p1.y)/2, z=(p0.z+p1.z)/2} + local flames_p = minetest.find_nodes_in_area(p0, p1, {"fire:basic_flame"}) + --print("number of flames at "..minetest.pos_to_string(p0).."/" + -- ..minetest.pos_to_string(p1)..": "..#flames_p) + local should_have_sound = (#flames_p > 0) + local wanted_sound = nil + if #flames_p >= 9 then + wanted_sound = {name="fire_large", gain=1.5} + elseif #flames_p > 0 then + wanted_sound = {name="fire_small", gain=1.5} + end + local p0_hash = minetest.hash_node_position(p0) + local sound = fire.sounds[p0_hash] + if not sound then + if should_have_sound then + fire.sounds[p0_hash] = { + handle = minetest.sound_play(wanted_sound, {pos=cp, loop=true}), + name = wanted_sound.name, + } + end + else + if not wanted_sound then + minetest.sound_stop(sound.handle) + fire.sounds[p0_hash] = nil + elseif sound.name ~= wanted_sound.name then + minetest.sound_stop(sound.handle) + fire.sounds[p0_hash] = { + handle = minetest.sound_play(wanted_sound, {pos=cp, loop=true}), + name = wanted_sound.name, + } + end + end +end + +function fire.on_flame_add_at(pos) + --print("flame added at "..minetest.pos_to_string(pos)) + fire.update_sounds_around(pos) +end + +function fire.on_flame_remove_at(pos) + --print("flame removed at "..minetest.pos_to_string(pos)) + fire.update_sounds_around(pos) +end + +function fire.find_pos_for_flame_around(pos) + return minetest.find_node_near(pos, 1, {"air"}) +end + +function fire.flame_should_extinguish(pos) + if minetest.setting_getbool("disable_fire") then return true end + --return minetest.find_node_near(pos, 1, {"group:puts_out_fire"}) + local p0 = {x=pos.x-2, y=pos.y, z=pos.z-2} + local p1 = {x=pos.x+2, y=pos.y, z=pos.z+2} + local ps = minetest.find_nodes_in_area(p0, p1, {"group:puts_out_fire"}) + return (#ps ~= 0) +end + +-- Ignite neighboring nodes +minetest.register_abm({ + nodenames = {"group:flammable"}, + neighbors = {"group:igniter"}, + interval = 1, + chance = 2, + action = function(p0, node, _, _) + -- If there is water or stuff like that around flame, don't ignite + if fire.flame_should_extinguish(p0) then + return + end + local p = fire.find_pos_for_flame_around(p0) + if p then + minetest.set_node(p, {name="fire:basic_flame"}) + fire.on_flame_add_at(p) + end + end, +}) + +-- Rarely ignite things from far +minetest.register_abm({ + nodenames = {"group:igniter"}, + neighbors = {"air"}, + interval = 2, + chance = 10, + action = function(p0, node, _, _) + local reg = minetest.registered_nodes[node.name] + if not reg or not reg.groups.igniter or reg.groups.igniter < 2 then + return + end + local d = reg.groups.igniter + local p = minetest.find_node_near(p0, d, {"group:flammable"}) + if p then + -- If there is water or stuff like that around flame, don't ignite + if fire.flame_should_extinguish(p) then + return + end + local p2 = fire.find_pos_for_flame_around(p) + if p2 then + minetest.set_node(p2, {name="fire:basic_flame"}) + fire.on_flame_add_at(p2) + end + end + end, +}) + +-- Remove flammable nodes and flame +minetest.register_abm({ + nodenames = {"fire:basic_flame"}, + interval = 1, + chance = 2, + action = function(p0, node, _, _) + -- If there is water or stuff like that around flame, remove flame + +local time_to_load= os.clock() - init +print(string.format("[MOD] "..minetest.get_current_modname().." loaded in %.4f s", time_to_load)) + if fire.flame_should_extinguish(p0) then + minetest.remove_node(p0) + fire.on_flame_remove_at(p0) + return + end + -- Make the following things rarer + if math.random(1,3) == 1 then + return + end + -- If there are no flammable nodes around flame, remove flame + if not minetest.find_node_near(p0, 1, {"group:flammable"}) then + minetest.remove_node(p0) + fire.on_flame_remove_at(p0) + return + end + if math.random(1,3) == 1 then + -- remove a flammable node around flame + local p = minetest.find_node_near(p0, 1, {"group:flammable"}) + if p then + -- If there is water or stuff like that around flame, don't remove + if fire.flame_should_extinguish(p0) then + return + end + minetest.remove_node(p) + nodeupdate(p) + end + else + -- remove flame + minetest.remove_node(p0) + fire.on_flame_remove_at(p0) + end + end, +}) + diff --git a/mods/flowers/init.lua b/mods/flowers/init.lua index 4aecdf600..e08dfd7d3 100644 --- a/mods/flowers/init.lua +++ b/mods/flowers/init.lua @@ -1,6 +1,6 @@ -- Minetest 0.4 mod: default -- See README.txt for licensing and other information. - +local init = os.clock() flower_tmp={} @@ -361,4 +361,6 @@ minetest.register_node("flowers:pot",{ end, }) +local time_to_load= os.clock() - init +print(string.format("[MOD] "..minetest.get_current_modname().." loaded in %.4f s", time_to_load)) diff --git a/mods/hardened_clay/init.lua b/mods/hardened_clay/init.lua index 274616ba8..031779776 100644 --- a/mods/hardened_clay/init.lua +++ b/mods/hardened_clay/init.lua @@ -1,3 +1,4 @@ +local init = os.clock() local clay = {} clay.dyes = { @@ -58,3 +59,6 @@ for _, row in ipairs(clay.dyes) do end end +local time_to_load= os.clock() - init +print(string.format("[MOD] "..minetest.get_current_modname().." loaded in %.4f s", time_to_load)) + diff --git a/mods/inventory/init.lua b/mods/inventory/init.lua index c1f817729..bdd7a7cba 100644 --- a/mods/inventory/init.lua +++ b/mods/inventory/init.lua @@ -1,3 +1,4 @@ +local init = os.clock() local path = minetest.get_modpath(minetest.get_current_modname()) local filepath = minetest.get_worldpath() @@ -277,3 +278,6 @@ minetest.register_on_placenode(function(pos, newnode, placer, oldnode, itemstack end) minetest.register_privilege("gamemode", "Permission to use /gamemode.") +local time_to_load= os.clock() - init +print(string.format("[MOD] "..minetest.get_current_modname().." loaded in %.4f s", time_to_load)) + diff --git a/mods/mobs/init.lua b/mods/mobs/init.lua index 4ad18682f..33fd8ef75 100644 --- a/mods/mobs/init.lua +++ b/mods/mobs/init.lua @@ -1,3 +1,5 @@ +local init = os.clock() + dofile(minetest.get_modpath("mobs").."/api.lua") -- Items @@ -23,11 +25,10 @@ dofile(minetest.get_modpath("mobs").."/herobrine.lua") ---mobs:register_spawn(name, description, nodes, max_light, min_light, chance, active_object_count, max_height, spawn_func) -if not minetest.setting_getbool("creative_mode") then - if minetest.setting_getbool("spawn_friendly_mobs") ~= false then -- “If not defined or set to true then” +if minetest.setting_getbool("spawn_friendly_mobs") ~= false then -- “If not defined or set to true then” mobs:register_spawn("mobs:sheep", "Sheep", {"default:dirt_with_grass"},16, 8, 2, 250, 100) - end - if minetest.setting_getbool("spawn_hostile_mobs") ~= false then -- “If not defined or set to true then” +end +if minetest.setting_getbool("spawn_hostile_mobs") ~= false then -- “If not defined or set to true then” mobs:register_spawn("mobs:slime", "Slime", { "default:dirt_with_grass"}, 20, 1, 11, 80, 0) mobs:register_spawn("mobs:herobrine", "Herobrine", {"head:herobine"}, 20, -1, 100, 1, 0) mobs:register_spawn("mobs:zombie", "Zombie", {"default:stone", "default:dirt", "default:dirt_with_grass", "default:sand"}, 1, -1, 7, 80, 0) @@ -38,7 +39,9 @@ if not minetest.setting_getbool("creative_mode") then -- mobs:register_spawn("mobs:tree_monster", "a tree monster", {"default:stone", "default:desert_stone"}, 1, -1, 25000, 2, 0) -- mobs:register_spawn("mobs:dungeon_master", "a dungeon master", {"default:stone", "default:desert_stone"}, 1, -1, 25000, 2, -50) -- mobs:register_spawn("mobs:rhino", "a rhino", {"default:stone", "default:desert_stone"}, 1, -1, 25000, 2, 0) - end end -print('[OK] Mobs loaded!') + +local time_to_load= os.clock() - init +print(string.format("[MOD] "..minetest.get_current_modname().." loaded in %.4f s", time_to_load)) + diff --git a/mods/redstone/mesecons/init.lua b/mods/redstone/mesecons/init.lua index 7f6fe5d8e..4771f3c98 100644 --- a/mods/redstone/mesecons/init.lua +++ b/mods/redstone/mesecons/init.lua @@ -39,7 +39,7 @@ -- } --} - +local init = os.clock() -- PUBLIC VARIABLES mesecon={} -- contains all functions and all global variables mesecon.actions_on={} -- Saves registered function callbacks for mesecon on | DEPRECATED @@ -104,11 +104,11 @@ function mesecon:receptor_off(pos, rules) end end - -print("[OK] Mesecons") - --The actual wires dofile(minetest.get_modpath("mesecons").."/wires.lua"); --Services like turnoff receptor on dignode and so on dofile(minetest.get_modpath("mesecons").."/services.lua"); + +local time_to_load= os.clock() - init +print(string.format("[MOD] "..minetest.get_current_modname().." loaded in %.4f s", time_to_load)) diff --git a/mods/stairs/init.lua b/mods/stairs/init.lua index 2c3c8de01..12c8d80b5 100644 --- a/mods/stairs/init.lua +++ b/mods/stairs/init.lua @@ -1,6 +1,6 @@ -- Minetest 0.4 mod: stairs -- See README.txt for licensing and other information. - +local init = os.clock() stairs = {} -- Node will be called stairs:stair_ @@ -285,4 +285,5 @@ stairs.register_slab("quartzstair", "default:quartz_pillar", default.node_sound_stone_defaults() ) -print('[OK] Stairs loaded') \ No newline at end of file +local time_to_load= os.clock() - init +print(string.format("[MOD] "..minetest.get_current_modname().." loaded in %.4f s", time_to_load))