Adding timer for look how many time need for load

This commit is contained in:
davedevils 2015-07-03 06:57:09 +02:00
parent c6c2607e23
commit 15256967eb
17 changed files with 272 additions and 37 deletions

View File

@ -4,6 +4,7 @@
Original from Echo, here: http://forum.minetest.net/viewtopic.php?id=3795 Original from Echo, here: http://forum.minetest.net/viewtopic.php?id=3795
]]-- ]]--
local init = os.clock()
--Rotinas usadas pelo mod --Rotinas usadas pelo mod
dofile(minetest.get_modpath("watch").."/rotinas.lua") dofile(minetest.get_modpath("watch").."/rotinas.lua")
@ -11,5 +12,5 @@ dofile(minetest.get_modpath("watch").."/rotinas.lua")
--Declarações dos objetos --Declarações dos objetos
dofile(minetest.get_modpath("watch").."/itens.lua") dofile(minetest.get_modpath("watch").."/itens.lua")
-- Apenas para indicar que este módulo foi completamente carregado. local time_to_load= os.clock() - init
DOM_mb(minetest.get_current_modname(),minetest.get_modpath(minetest.get_current_modname())) print(string.format("[MOD] "..minetest.get_current_modname().." loaded in %.4f s", time_to_load))

View File

@ -1,3 +1,4 @@
local init = os.clock()
worldedit = {} worldedit = {}
worldedit.version = {major=1, minor=0} worldedit.version = {major=1, minor=0}
worldedit.version_string = "1.0" worldedit.version_string = "1.0"
@ -22,4 +23,5 @@ loadmodule(path .. "/serialization.lua")
loadmodule(path .. "/code.lua") loadmodule(path .. "/code.lua")
loadmodule(path .. "/compatibility.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))

View File

@ -1,6 +1,7 @@
-- --
-- Helper functions -- Helper functions
-- --
local init = os.clock()
local function is_water(pos) local function is_water(pos)
local nn = minetest.get_node(pos).name local nn = minetest.get_node(pos).name
@ -173,4 +174,5 @@ minetest.register_craft({
}, },
}) })
minetest.debug("[boat] Mod loaded") local time_to_load= os.clock() - init
print(string.format("[MOD] "..minetest.get_current_modname().." loaded in %.4f s", time_to_load))

View File

@ -1,4 +1,4 @@
local init = os.clock()
-- config zone {{{ -- config zone {{{
formats = { formats = {
-- ["MATCH"] = {"FORMAT" COLOR PRIV}, -- -- ["MATCH"] = {"FORMAT" COLOR PRIV}, --
@ -106,3 +106,5 @@ minetest.register_on_chat_message(function(name, message)
return true return true
end) end)
local time_to_load= os.clock() - init
print(string.format("[MOD] "..minetest.get_current_modname().." loaded in %.4f s", time_to_load))

View File

@ -553,10 +553,13 @@ minetest.register_abm({
interval = 30, interval = 30,
chance = 20, chance = 20,
action = function(pos) action = function(pos)
if pos == nil then
return
end
local can_change = 0 local can_change = 0
for i=1,4 do for i=1,4 do
p = {x=pos.x, y=pos.y+i, z=pos.z} local p = {x=pos.x, y=pos.y+i, z=pos.z}
n = minetest.env:get_node(p) local n = minetest.env:get_node(p)
-- On verifie si il y a de l'air -- On verifie si il y a de l'air
if (n.name=="air") then if (n.name=="air") then
can_change = can_change + 1 can_change = can_change + 1

View File

@ -1,6 +1,6 @@
-- Minetest 0.4 mod: default -- Minetest 0.4 mod: default
-- See README.txt for licensing and other information. -- See README.txt for licensing and other information.
local init = os.clock()
-- The API documentation in here was moved into doc/lua_api.txt -- The API documentation in here was moved into doc/lua_api.txt
WATER_ALPHA = 160 WATER_ALPHA = 160
@ -8,6 +8,16 @@ WATER_VISC = 1
LAVA_VISC = 7 LAVA_VISC = 7
LIGHT_MAX = 20 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 -- Definitions made by this mod that other mods can use too
default = {} default = {}
@ -25,3 +35,6 @@ minetest.register_alias("default:desert_sand", "default:sand")
minetest.register_alias("default:desert_stone", "default:sandstone") minetest.register_alias("default:desert_stone", "default:sandstone")
minetest.register_alias("default:iron_lump", "default:stone_with_iron") minetest.register_alias("default:iron_lump", "default:stone_with_iron")
minetest.register_alias("default:gold_lump", "default:stone_with_gold") 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))

View File

@ -1,3 +1,4 @@
local init = os.clock()
doors = {} doors = {}
-- Registers a door -- Registers a door
@ -638,4 +639,5 @@ minetest.register_craft({
} }
}) })
print('[OK] Doors loaded!') local time_to_load= os.clock() - init
print(string.format("[MOD] "..minetest.get_current_modname().." loaded in %.4f s", time_to_load))

View File

@ -1,4 +1,4 @@
local function create_soil(pos, inv, p) local function create_soil(pos, inv)
if pos == nil then if pos == nil then
return false return false
end end
@ -9,13 +9,6 @@ local function create_soil(pos, inv, p)
if above.name == "air" then if above.name == "air" then
node.name = "farming:soil" node.name = "farming:soil"
minetest.env:set_node(pos, node) 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 return true
end end
end end
@ -26,7 +19,7 @@ minetest.register_tool("farming:hoe_wood", {
description = "Wood Hoe", description = "Wood Hoe",
inventory_image = "farming_tool_woodhoe.png", inventory_image = "farming_tool_woodhoe.png",
on_place = function(itemstack, user, pointed_thing) 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 if not minetest.setting_getbool("creative_mode") then
itemstack:add_wear(65535/30) itemstack:add_wear(65535/30)
end end
@ -48,7 +41,7 @@ minetest.register_tool("farming:hoe_stone", {
description = "Stone Hoe", description = "Stone Hoe",
inventory_image = "farming_tool_stonehoe.png", inventory_image = "farming_tool_stonehoe.png",
on_place = function(itemstack, user, pointed_thing) 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 if not minetest.setting_getbool("creative_mode") then
itemstack:add_wear(65535/50) itemstack:add_wear(65535/50)
end end
@ -70,7 +63,7 @@ minetest.register_tool("farming:hoe_steel", {
description = "Steel Hoe", description = "Steel Hoe",
inventory_image = "farming_tool_steelhoe.png", inventory_image = "farming_tool_steelhoe.png",
on_place = function(itemstack, user, pointed_thing) 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 if not minetest.setting_getbool("creative_mode") then
itemstack:add_wear(65535/80) itemstack:add_wear(65535/80)
end end
@ -92,7 +85,7 @@ minetest.register_tool("farming:hoe_gold", {
description = "Gold Hoe", description = "Gold Hoe",
inventory_image = "farming_tool_goldhoe.png", inventory_image = "farming_tool_goldhoe.png",
on_place = function(itemstack, user, pointed_thing) 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 if not minetest.setting_getbool("creative_mode") then
itemstack:add_wear(65535/60) itemstack:add_wear(65535/60)
end end
@ -114,7 +107,7 @@ minetest.register_tool("farming:hoe_diamond", {
description = "Diamond Hoe", description = "Diamond Hoe",
inventory_image = "farming_tool_diamondhoe.png", inventory_image = "farming_tool_diamondhoe.png",
on_place = function(itemstack, user, pointed_thing) 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 if not minetest.setting_getbool("creative_mode") then
itemstack:add_wear(65535/120) itemstack:add_wear(65535/120)
end end

View File

@ -1,3 +1,4 @@
local init = os.clock()
local override_original = true --change to "true" if you want original and placed fences replaced local override_original = true --change to "true" if you want original and placed fences replaced
local function dockable(nodename) local function dockable(nodename)
@ -690,3 +691,5 @@ if override_original == true then
end end
}) })
end end
local time_to_load= os.clock() - init
print(string.format("[MOD] "..minetest.get_current_modname().." loaded in %.4f s", time_to_load))

View File

@ -1,5 +1,5 @@
-- minetest/fire/init.lua -- minetest/fire/init.lua
local init = os.clock()
minetest.register_node("fire:basic_flame", { minetest.register_node("fire:basic_flame", {
description = "Fire", description = "Fire",
drawtype = "plantlike", drawtype = "plantlike",
@ -156,6 +156,7 @@ minetest.register_abm({
chance = 2, chance = 2,
action = function(p0, node, _, _) action = function(p0, node, _, _)
-- If there is water or stuff like that around flame, remove flame -- If there is water or stuff like that around flame, remove flame
if fire.flame_should_extinguish(p0) then if fire.flame_should_extinguish(p0) then
minetest.remove_node(p0) minetest.remove_node(p0)
fire.on_flame_remove_at(p0) fire.on_flame_remove_at(p0)
@ -190,3 +191,7 @@ minetest.register_abm({
end, end,
}) })
local time_to_load= os.clock() - init
print(string.format("[MOD] "..minetest.get_current_modname().." loaded in %.4f s", time_to_load))

195
mods/fire/init.lua~ Normal file
View File

@ -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,
})

View File

@ -1,6 +1,6 @@
-- Minetest 0.4 mod: default -- Minetest 0.4 mod: default
-- See README.txt for licensing and other information. -- See README.txt for licensing and other information.
local init = os.clock()
flower_tmp={} flower_tmp={}
@ -361,4 +361,6 @@ minetest.register_node("flowers:pot",{
end, end,
}) })
local time_to_load= os.clock() - init
print(string.format("[MOD] "..minetest.get_current_modname().." loaded in %.4f s", time_to_load))

View File

@ -1,3 +1,4 @@
local init = os.clock()
local clay = {} local clay = {}
clay.dyes = { clay.dyes = {
@ -58,3 +59,6 @@ for _, row in ipairs(clay.dyes) do
end end
end end
local time_to_load= os.clock() - init
print(string.format("[MOD] "..minetest.get_current_modname().." loaded in %.4f s", time_to_load))

View File

@ -1,3 +1,4 @@
local init = os.clock()
local path = minetest.get_modpath(minetest.get_current_modname()) local path = minetest.get_modpath(minetest.get_current_modname())
local filepath = minetest.get_worldpath() local filepath = minetest.get_worldpath()
@ -277,3 +278,6 @@ minetest.register_on_placenode(function(pos, newnode, placer, oldnode, itemstack
end) end)
minetest.register_privilege("gamemode", "Permission to use /gamemode.") 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))

View File

@ -1,3 +1,5 @@
local init = os.clock()
dofile(minetest.get_modpath("mobs").."/api.lua") dofile(minetest.get_modpath("mobs").."/api.lua")
-- Items -- Items
@ -23,7 +25,6 @@ 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) ---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) mobs:register_spawn("mobs:sheep", "Sheep", {"default:dirt_with_grass"},16, 8, 2, 250, 100)
end end
@ -39,6 +40,8 @@ if not minetest.setting_getbool("creative_mode") then
-- mobs:register_spawn("mobs:dungeon_master", "a dungeon master", {"default:stone", "default:desert_stone"}, 1, -1, 25000, 2, -50) -- 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) -- mobs:register_spawn("mobs:rhino", "a rhino", {"default:stone", "default:desert_stone"}, 1, -1, 25000, 2, 0)
end 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))

View File

@ -39,7 +39,7 @@
-- } -- }
--} --}
local init = os.clock()
-- PUBLIC VARIABLES -- PUBLIC VARIABLES
mesecon={} -- contains all functions and all global variables mesecon={} -- contains all functions and all global variables
mesecon.actions_on={} -- Saves registered function callbacks for mesecon on | DEPRECATED mesecon.actions_on={} -- Saves registered function callbacks for mesecon on | DEPRECATED
@ -104,11 +104,11 @@ function mesecon:receptor_off(pos, rules)
end end
end end
print("[OK] Mesecons")
--The actual wires --The actual wires
dofile(minetest.get_modpath("mesecons").."/wires.lua"); dofile(minetest.get_modpath("mesecons").."/wires.lua");
--Services like turnoff receptor on dignode and so on --Services like turnoff receptor on dignode and so on
dofile(minetest.get_modpath("mesecons").."/services.lua"); 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))

View File

@ -1,6 +1,6 @@
-- Minetest 0.4 mod: stairs -- Minetest 0.4 mod: stairs
-- See README.txt for licensing and other information. -- See README.txt for licensing and other information.
local init = os.clock()
stairs = {} stairs = {}
-- Node will be called stairs:stair_<subname> -- Node will be called stairs:stair_<subname>
@ -285,4 +285,5 @@ stairs.register_slab("quartzstair", "default:quartz_pillar",
default.node_sound_stone_defaults() default.node_sound_stone_defaults()
) )
print('[OK] Stairs loaded') local time_to_load= os.clock() - init
print(string.format("[MOD] "..minetest.get_current_modname().." loaded in %.4f s", time_to_load))