use custom dump function
This commit is contained in:
parent
4eca91857b
commit
d42ef6e74c
@ -38,9 +38,12 @@ weather_enable = true
|
|||||||
# if pvp is enabled
|
# if pvp is enabled
|
||||||
enable_pvp = true
|
enable_pvp = true
|
||||||
|
|
||||||
# tnt is enabledxx
|
# tnt is enabled
|
||||||
tnt_enable = true
|
tnt_enable = true
|
||||||
|
|
||||||
|
# if testing stuff is enabled
|
||||||
|
testing_enable = false
|
||||||
|
|
||||||
# server
|
# server
|
||||||
max_users = 16
|
max_users = 16
|
||||||
max_block_generate_distance = 4
|
max_block_generate_distance = 4
|
||||||
|
@ -10,7 +10,11 @@ default.WATER_VISC = 1
|
|||||||
default.LIGHT_MAX = 14
|
default.LIGHT_MAX = 14
|
||||||
|
|
||||||
function default.log(text, type)
|
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
|
end
|
||||||
|
|
||||||
minetest.nodedef_default.stack_max = 60
|
minetest.nodedef_default.stack_max = 60
|
||||||
|
@ -9,7 +9,7 @@ music.players = {} -- music players
|
|||||||
|
|
||||||
if minetest.setting_getbool("music_enable") then
|
if minetest.setting_getbool("music_enable") then
|
||||||
function music.stop(pos)
|
function music.stop(pos)
|
||||||
local dp = dump(pos)
|
local dp = default.dumpvec(pos)
|
||||||
|
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
meta:set_string("infotext", "Music player(Off)")
|
meta:set_string("infotext", "Music player(Off)")
|
||||||
@ -22,7 +22,7 @@ if minetest.setting_getbool("music_enable") then
|
|||||||
end
|
end
|
||||||
|
|
||||||
function music.start(pos)
|
function music.start(pos)
|
||||||
local dp = dump(pos)
|
local dp = default.dumpvec(pos)
|
||||||
|
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
meta:set_string("infotext", "Music player(On)")
|
meta:set_string("infotext", "Music player(On)")
|
||||||
@ -52,7 +52,7 @@ if minetest.setting_getbool("music_enable") then
|
|||||||
end
|
end
|
||||||
|
|
||||||
function music.update(pos)
|
function music.update(pos)
|
||||||
local dp = dump(pos)
|
local dp = default.dumpvec(pos)
|
||||||
|
|
||||||
if music.players[dp] ~= nil then
|
if music.players[dp] ~= nil then
|
||||||
local node = minetest.get_node(pos)
|
local node = minetest.get_node(pos)
|
||||||
@ -70,7 +70,7 @@ if minetest.setting_getbool("music_enable") then
|
|||||||
end
|
end
|
||||||
|
|
||||||
function music.toggle(pos)
|
function music.toggle(pos)
|
||||||
local dp = dump(pos)
|
local dp = default.dumpvec(pos)
|
||||||
|
|
||||||
if music.players[dp] == nil then
|
if music.players[dp] == nil then
|
||||||
music.start(pos)
|
music.start(pos)
|
||||||
@ -128,7 +128,7 @@ if minetest.setting_getbool("music_enable") then
|
|||||||
chance = 1,
|
chance = 1,
|
||||||
interval = 1,
|
interval = 1,
|
||||||
action = function(pos, node)
|
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)
|
local meta = minetest.get_meta(pos)
|
||||||
if meta:get_int("music_player_enabled") == 1 then
|
if meta:get_int("music_player_enabled") == 1 then
|
||||||
music.start(pos)
|
music.start(pos)
|
||||||
|
7
mods/testing/README.txt
Normal file
7
mods/testing/README.txt
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
Testing mod
|
||||||
|
===========
|
||||||
|
By Kaadmy
|
||||||
|
|
||||||
|
Adds some testing stuff
|
||||||
|
|
||||||
|
Source license: WTFPL
|
1
mods/testing/depends.txt
Normal file
1
mods/testing/depends.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
default
|
30
mods/testing/init.lua
Normal file
30
mods/testing/init.lua
Normal file
@ -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
|
@ -207,15 +207,15 @@ function village.spawn_road(pos, houses, built, roads, depth, pr)
|
|||||||
nextpos.x = nextpos.x + 12
|
nextpos.x = nextpos.x + 12
|
||||||
end
|
end
|
||||||
|
|
||||||
if built[dump(nextpos)] == nil then
|
if built[default.dumpvec(nextpos)] == nil then
|
||||||
built[dump(nextpos)] = true
|
built[default.dumpvec(nextpos)] = true
|
||||||
if depth <= 0 or pr:next(1, 8) < 6 then
|
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)
|
local structure = util.choice_element(village.chunktypes, pr)
|
||||||
village.spawn_chunk(nextpos, orient, {}, pr, structure)
|
village.spawn_chunk(nextpos, orient, {}, pr, structure)
|
||||||
else
|
else
|
||||||
roads[dump(nextpos)] = {pos = nextpos}
|
roads[default.dumpvec(nextpos)] = {pos = nextpos}
|
||||||
village.spawn_road(nextpos, houses, built, roads, depth - 1, pr)
|
village.spawn_road(nextpos, houses, built, roads, depth - 1, pr)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -237,18 +237,18 @@ function village.spawn_village(pos, pr)
|
|||||||
local built = {}
|
local built = {}
|
||||||
local roads = {}
|
local roads = {}
|
||||||
|
|
||||||
built[dump(pos)] = true
|
built[default.dumpvec(pos)] = true
|
||||||
|
|
||||||
village.spawn_road(pos, houses, built, roads, depth, pr)
|
village.spawn_road(pos, houses, built, roads, depth, pr)
|
||||||
|
|
||||||
local function connects(pos, nextpos)
|
local function connects(pos, nextpos)
|
||||||
if houses[dump(nextpos)] ~= nil then
|
if houses[default.dumpvec(nextpos)] ~= nil then
|
||||||
if vector.equals(houses[dump(nextpos)].front, pos) then
|
if vector.equals(houses[default.dumpvec(nextpos)].front, pos) then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if roads[dump(nextpos)] ~= nil then
|
if roads[default.dumpvec(nextpos)] ~= nil then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user