performance tweaks
This commit is contained in:
parent
e8178108c7
commit
d405bbd848
82
mapgen.lua
82
mapgen.lua
@ -1,5 +1,6 @@
|
||||
local nethermod = minetest.get_modpath("nether")
|
||||
local is_50 = minetest.has_feature("object_use_texture_alpha")
|
||||
local mp = minetest.get_modpath("nssb")
|
||||
|
||||
nssb.mymapgenis = tonumber(minetest.settings:get("mymapgenis")) or 7
|
||||
|
||||
@ -71,7 +72,7 @@ function nssb_register_buildings(
|
||||
|
||||
minetest.register_on_generated(function(minp, maxp, seed)
|
||||
|
||||
if underground == false and maxp and maxp.y > 0 then
|
||||
if underground == false and minp and maxp and maxp.y > 0 then
|
||||
|
||||
local flag = 0
|
||||
local i, j, k, posd, pos1, pos2, pos3, n, u, d
|
||||
@ -87,31 +88,41 @@ function nssb_register_buildings(
|
||||
|
||||
n = minetest.get_node(pos1).name
|
||||
|
||||
if downblock == nil then
|
||||
u = nil
|
||||
else
|
||||
u = minetest.get_node(pos2).name
|
||||
end
|
||||
-- only continue if first node met and random chance is 1
|
||||
-- random chance is here to save on future get_node's for performance
|
||||
if n == posschem and random(rand) == 1 then
|
||||
|
||||
if aboveblock == nil then
|
||||
d = nil
|
||||
else
|
||||
d = minetest.get_node(pos3).name
|
||||
end
|
||||
if downblock == nil then
|
||||
u = nil
|
||||
else
|
||||
u = minetest.get_node(pos2).name
|
||||
end
|
||||
|
||||
if n == posschem and u == downblock and d == aboveblock and flag == 0
|
||||
and random(rand) == 1 then
|
||||
-- continue if 2nd node met
|
||||
if u == downblock then
|
||||
|
||||
if minetest.find_node_near(pos3, radius, near) then
|
||||
if aboveblock == nil then
|
||||
d = nil
|
||||
else
|
||||
d = minetest.get_node(pos3).name
|
||||
end
|
||||
|
||||
minetest.place_schematic(pos1, minetest.get_modpath("nssb")
|
||||
.. "/schems/" .. build .. ".mts", "0", {}, true)
|
||||
-- continue if 3rd node met
|
||||
if d == aboveblock then
|
||||
|
||||
-- continue if node nearby met
|
||||
if minetest.find_node_near(pos3, radius, near) then
|
||||
|
||||
minetest.place_schematic(pos1, mp
|
||||
.. "/schems/" .. build .. ".mts", "0", {}, true)
|
||||
|
||||
-- minetest.chat_send_all("Added schematic in "..(minetest.pos_to_string(pos1)))
|
||||
|
||||
posd = pos1
|
||||
flag = 1
|
||||
break -- schem placed, loop can be ended
|
||||
posd = pos1
|
||||
flag = 1
|
||||
break -- schem placed, loop can be ended
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -185,12 +196,10 @@ function nssb_register_buildings(
|
||||
|
||||
minetest.chat_send_all("name prima di place_schematic:.."..name)
|
||||
|
||||
minetest.place_schematic(posplace,
|
||||
minetest.get_modpath("nssb")
|
||||
.. "/schems/memoportal.mts", "0", {}, true)
|
||||
minetest.place_schematic(posplace, mp
|
||||
.. "/schems/memoportal.mts", "0", {}, true)
|
||||
|
||||
-- minetest.place_schematic(posplace,
|
||||
minetest.get_modpath("nssb")
|
||||
-- minetest.place_schematic(posplace, mp
|
||||
.. "/schems/memoportal.mts", "0", {}, true)
|
||||
|
||||
--minetest.chat_send_all("3")
|
||||
@ -202,16 +211,15 @@ function nssb_register_buildings(
|
||||
end, posplace)
|
||||
end
|
||||
|
||||
minetest.place_schematic(posplace, minetest.get_modpath("nssb")
|
||||
.. "/schems/memoportal.mts", "0", {}, true)
|
||||
minetest.place_schematic(posplace, mp
|
||||
.. "/schems/memoportal.mts", "0", {}, true)
|
||||
end
|
||||
|
||||
]]--
|
||||
end
|
||||
|
||||
else --underground == true
|
||||
|
||||
if minp and minp.y < 0 then
|
||||
if maxp and minp and minp.y < 0 then
|
||||
|
||||
-- minetest.chat_send_all("Posmin: " .. (minetest.pos_to_string(minp)).." Posmax: " .. (minetest.pos_to_string(maxp)))
|
||||
|
||||
@ -244,11 +252,14 @@ function nssb_register_buildings(
|
||||
else
|
||||
if n == posschem and random(rand) == 1 then
|
||||
|
||||
minetest.place_schematic(pos1, minetest.get_modpath("nssb")
|
||||
.. "/schems/" .. build .. ".mts", "0", {}, true)
|
||||
-- error checking
|
||||
if pos1.x and pos1.y and pos1.z then
|
||||
|
||||
minetest.place_schematic(pos1, mp
|
||||
.. "/schems/" .. build .. ".mts", "0", {}, true)
|
||||
|
||||
-- minetest.chat_send_all("Added schematic in "..(minetest.pos_to_string(pos1)))
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -900,8 +911,9 @@ if posplace then
|
||||
|
||||
minetest.after(5, function(posplace)
|
||||
|
||||
minetest.place_schematic(posplace, minetest.get_modpath("nssb")
|
||||
.. "/schems/memoportal.mts", 0, {}, true)
|
||||
minetest.place_schematic(posplace, mp
|
||||
.. "/schems/memoportal.mts", 0, {}, true)
|
||||
|
||||
end, posplace)
|
||||
end
|
||||
|
||||
@ -917,8 +929,6 @@ if posarena then
|
||||
-- teleport the player
|
||||
minetest.after(5, function(posarena)
|
||||
|
||||
local mp = minetest.get_modpath("nssb")
|
||||
|
||||
minetest.place_schematic(posarena, mp .. "/schems/arena51.mts", "0", {}, true)
|
||||
|
||||
minetest.place_schematic({x = posarena.x, y = level - 96, z = posarena.z-9},
|
||||
@ -983,8 +993,6 @@ minetest.register_abm({
|
||||
|
||||
-- minetest.chat_send_all("Ciao ciao pirloni")
|
||||
|
||||
local mp = minetest.get_modpath("nssb")
|
||||
|
||||
minetest.place_schematic(posarena, mp .. "/schems/arena51.mts", "0", {}, true)
|
||||
|
||||
minetest.place_schematic({x = posarena.x, y = level - 96, z = posarena.z-9},
|
||||
|
Loading…
x
Reference in New Issue
Block a user