diff --git a/minetest.conf b/minetest.conf index a3482e3..4bca7d1 100644 --- a/minetest.conf +++ b/minetest.conf @@ -38,9 +38,12 @@ weather_enable = true # if pvp is enabled enable_pvp = true -# tnt is enabledxx +# tnt is enabled tnt_enable = true +# if testing stuff is enabled +testing_enable = false + # server max_users = 16 max_block_generate_distance = 4 diff --git a/mods/default/init.lua b/mods/default/init.lua index 18f430d..01abda4 100644 --- a/mods/default/init.lua +++ b/mods/default/init.lua @@ -10,7 +10,11 @@ default.WATER_VISC = 1 default.LIGHT_MAX = 14 function default.log(text, type) - print("Pixture ["..type.."] "..text) + minetest.log("Pixture ["..type.."] "..text) +end + +function default.dumpvec(v) + return v.x..":"..v.y..":"..v.z end minetest.nodedef_default.stack_max = 60 diff --git a/mods/music/init.lua b/mods/music/init.lua index f306b75..a5650b3 100644 --- a/mods/music/init.lua +++ b/mods/music/init.lua @@ -9,7 +9,7 @@ music.players = {} -- music players if minetest.setting_getbool("music_enable") then function music.stop(pos) - local dp = dump(pos) + local dp = default.dumpvec(pos) local meta = minetest.get_meta(pos) meta:set_string("infotext", "Music player(Off)") @@ -22,7 +22,7 @@ if minetest.setting_getbool("music_enable") then end function music.start(pos) - local dp = dump(pos) + local dp = default.dumpvec(pos) local meta = minetest.get_meta(pos) meta:set_string("infotext", "Music player(On)") @@ -52,7 +52,7 @@ if minetest.setting_getbool("music_enable") then end function music.update(pos) - local dp = dump(pos) + local dp = default.dumpvec(pos) if music.players[dp] ~= nil then local node = minetest.get_node(pos) @@ -70,7 +70,7 @@ if minetest.setting_getbool("music_enable") then end function music.toggle(pos) - local dp = dump(pos) + local dp = default.dumpvec(pos) if music.players[dp] == nil then music.start(pos) @@ -128,7 +128,7 @@ if minetest.setting_getbool("music_enable") then chance = 1, interval = 1, action = function(pos, node) - if music.players[dump(pos)] == nil then + if music.players[default.dumpvec(pos)] == nil then local meta = minetest.get_meta(pos) if meta:get_int("music_player_enabled") == 1 then music.start(pos) diff --git a/mods/testing/README.txt b/mods/testing/README.txt new file mode 100644 index 0000000..438ebcf --- /dev/null +++ b/mods/testing/README.txt @@ -0,0 +1,7 @@ +Testing mod +=========== +By Kaadmy + +Adds some testing stuff + +Source license: WTFPL diff --git a/mods/testing/depends.txt b/mods/testing/depends.txt new file mode 100644 index 0000000..4ad96d5 --- /dev/null +++ b/mods/testing/depends.txt @@ -0,0 +1 @@ +default diff --git a/mods/testing/init.lua b/mods/testing/init.lua new file mode 100644 index 0000000..11e332f --- /dev/null +++ b/mods/testing/init.lua @@ -0,0 +1,30 @@ +-- +-- Testing mod +-- By Kaadmy, for Pixture +-- + +if minetest.setting_getbool("testing_enable") then + local t1 = os.clock() + for i = 1, 10000 do + dump({x=0,y=50,z=100}) + end + print(string.format("10000 iterations with dump({x=0,y=50,z=100}) took %.2fms", (os.clock() - t1) * 1000)) + + local t2 = os.clock() + for i = 1, 10000 do + tostring({x=0,y=50,z=100}) + end + print(string.format("10000 iterations with tostring({x=0,y=50,z=100}) took %.2fms", (os.clock() - t2) * 1000)) + + local t3 = os.clock() + for i = 1, 10000 do + minetest.serialize({x=0,y=50,z=100}) + end + print(string.format("10000 iterations with minetest.serialize({x=0,y=50,z=100}) took %.2fms", (os.clock() - t3) * 1000)) + + local t4 = os.clock() + for i = 1, 10000 do + default.dumpvec({x=0,y=50,z=100}) + end + print(string.format("10000 iterations with(custom function) default.dumpvec({x=0,y=50,z=100}) took %.2fms", (os.clock() - t4) * 1000)) +end \ No newline at end of file diff --git a/mods/village/generate.lua b/mods/village/generate.lua index 5a12df9..312339a 100644 --- a/mods/village/generate.lua +++ b/mods/village/generate.lua @@ -207,15 +207,15 @@ function village.spawn_road(pos, houses, built, roads, depth, pr) nextpos.x = nextpos.x + 12 end - if built[dump(nextpos)] == nil then - built[dump(nextpos)] = true + if built[default.dumpvec(nextpos)] == nil then + built[default.dumpvec(nextpos)] = true if depth <= 0 or pr:next(1, 8) < 6 then - houses[dump(nextpos)] = {pos = nextpos, front = pos} + houses[default.dumpvec(nextpos)] = {pos = nextpos, front = pos} local structure = util.choice_element(village.chunktypes, pr) village.spawn_chunk(nextpos, orient, {}, pr, structure) else - roads[dump(nextpos)] = {pos = nextpos} + roads[default.dumpvec(nextpos)] = {pos = nextpos} village.spawn_road(nextpos, houses, built, roads, depth - 1, pr) end end @@ -237,18 +237,18 @@ function village.spawn_village(pos, pr) local built = {} local roads = {} - built[dump(pos)] = true + built[default.dumpvec(pos)] = true village.spawn_road(pos, houses, built, roads, depth, pr) local function connects(pos, nextpos) - if houses[dump(nextpos)] ~= nil then - if vector.equals(houses[dump(nextpos)].front, pos) then + if houses[default.dumpvec(nextpos)] ~= nil then + if vector.equals(houses[default.dumpvec(nextpos)].front, pos) then return true end end - if roads[dump(nextpos)] ~= nil then + if roads[default.dumpvec(nextpos)] ~= nil then return true end