Compare commits
5 Commits
ad0d3fe10d
...
8ecbbb5716
Author | SHA1 | Date |
---|---|---|
Beha | 8ecbbb5716 | |
Beha | 85a47b7049 | |
Beha | c72eb46d3f | |
Beha | 173ff7e654 | |
Beha | 0c76ad5105 |
15
init.lua
15
init.lua
|
@ -116,24 +116,31 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||
local pos = vector.add(use, def.offset)
|
||||
minetest.place_schematic(pos, def.schematic, "random")
|
||||
|
||||
-- Very Hacky Solution due to minetest.place_schematic carrying the replacements parameter between calls.
|
||||
-- This parses the schematic file manually, then replaces appropriate nodes between all possible positions.
|
||||
local schematic_size = {}
|
||||
|
||||
-- Open the schematic and read the three size integers into schematic_size.
|
||||
local sf = io.open(def.schematic, "rb")
|
||||
sf:read(6)
|
||||
schematic_size.x = string.byte(sf:read(1)) * 256 + string.byte(sf:read(1))
|
||||
schematic_size.y = string.byte(sf:read(1)) * 256 + string.byte(sf:read(1))
|
||||
schematic_size.z = string.byte(sf:read(1)) * 256 + string.byte(sf:read(1))
|
||||
sf:close()
|
||||
|
||||
local mid = vector.add(pos, vector.divide(schematic_size, 2))
|
||||
|
||||
-- Replace appropriate nodes in the possible schematic area.
|
||||
for k,v in pairs(r) do
|
||||
local positions = minetest.find_nodes_in_area(vector.subtract(pos, schematic_size), vector.add(maxp, schematic_size), {k})
|
||||
local positions = minetest.find_nodes_in_area(vector.subtract(mid, schematic_size), vector.add(mid, schematic_size), {k})
|
||||
if positions then
|
||||
for _,p in ipairs(positions) do
|
||||
minetest.set_node(p, {name=v})
|
||||
end
|
||||
end
|
||||
end
|
||||
-- End Very Hacky Solution
|
||||
|
||||
if def.special then
|
||||
def.special(pos, mid, schematic_size)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
130
structures.lua
130
structures.lua
|
@ -132,16 +132,132 @@ ancient_world.register("ancient_world:water_tower_1", {
|
|||
},
|
||||
})
|
||||
|
||||
ancient_world.register("ancient_world:magic_hovel_2", {
|
||||
schematic = minetest.get_modpath("ancient_world") .. "/schematics/magic_hovel_2.mts",
|
||||
if rawget(_G, 'kingdoms') then
|
||||
kingdoms.at_mod_load("magic", function()
|
||||
ancient_world.register("ancient_world:magic_hovel_2", {
|
||||
schematic = minetest.get_modpath("ancient_world") .. "/schematics/magic_hovel_2.mts",
|
||||
type = "decoration",
|
||||
on = {"default:dirt_with_grass"},
|
||||
offset = {
|
||||
x = 0,
|
||||
y = -3,
|
||||
z = 0,
|
||||
},
|
||||
random_replacements = {
|
||||
["ancient_world:placeholder_1"] = true,
|
||||
},
|
||||
})
|
||||
end)
|
||||
end
|
||||
|
||||
ancient_world.register("ancient_world:hidden_bush_1", {
|
||||
schematic = minetest.get_modpath("ancient_world") .. "/schematics/hidden_bush_1.mts",
|
||||
type = "decoration",
|
||||
on = {"default:dirt_with_grass"},
|
||||
offset = {
|
||||
x = 0,
|
||||
y = -3,
|
||||
z = 0,
|
||||
},
|
||||
random_replacements = {
|
||||
["ancient_world:placeholder_1"] = true,
|
||||
},
|
||||
})
|
||||
|
||||
if rawget(_G, 'kingdoms') then
|
||||
kingdoms.at_mod_load("magic", function()
|
||||
ancient_world.register("ancient_world:underground_lab_1", {
|
||||
schematic = minetest.get_modpath("ancient_world") .. "/schematics/underground_lab_1.mts",
|
||||
type = "decoration",
|
||||
limit_y = {
|
||||
max = -512,
|
||||
min = -31000,
|
||||
},
|
||||
offset = {
|
||||
x = 0,
|
||||
y = -16,
|
||||
z = 0,
|
||||
},
|
||||
on = {"default:stone"},
|
||||
replacements = {
|
||||
["ancient_world:placeholder_2"] = "air",
|
||||
},
|
||||
random_replacements = {
|
||||
["ancient_world:placeholder_1"] = true,
|
||||
},
|
||||
})
|
||||
end)
|
||||
end
|
||||
|
||||
ancient_world.register("ancient_world:mine_1", {
|
||||
schematic = minetest.get_modpath("ancient_world") .. "/schematics/mine_1.mts",
|
||||
type = "decoration",
|
||||
on = {"default:dirt_with_grass", "default:dirt_with_dry_grass"},
|
||||
offset = {
|
||||
x = 0,
|
||||
y = -48,
|
||||
z = 0,
|
||||
},
|
||||
limit_y = {
|
||||
max = 8,
|
||||
min = -31000,
|
||||
},
|
||||
replacements = {
|
||||
["ancient_world:placeholder_2"] = "air",
|
||||
},
|
||||
random_replacements = {
|
||||
["ancient_world:placeholder_1"] = true,
|
||||
["ancient_world:placeholder_3"] = (rawget(_G, 'kingdoms') and
|
||||
{"default:stone_with_gold", "default:stone_with_copper", "default:stone_with_iron", "kingdoms:stone_with_silver"} or
|
||||
{"default:stone_with_gold", "default:stone_with_copper", "default:stone_with_iron"}),
|
||||
},
|
||||
})
|
||||
|
||||
ancient_world.register("ancient_world:meteor_1", {
|
||||
schematic = minetest.get_modpath("ancient_world") .. "/schematics/meteor_1.mts",
|
||||
type = "decoration",
|
||||
on = {"default:dirt_with_grass", "default:dirt_with_dry_grass"},
|
||||
offset = {
|
||||
x = 0,
|
||||
y = -2,
|
||||
z = 0,
|
||||
},
|
||||
limit_y = {
|
||||
max = 31000,
|
||||
min = -32,
|
||||
},
|
||||
replacements = {
|
||||
["ancient_world:placeholder_1"] = "fire:basic_flame",
|
||||
},
|
||||
special = function(pos, mid, schematic_size)
|
||||
local want = {
|
||||
["default:dirt_with_dry_grass"] = true,
|
||||
["default:dirt_with_grass"] = true,
|
||||
["default:stone"] = true,
|
||||
}
|
||||
local t = vector.add(mid, schematic_size)
|
||||
t.y = t.y - 4
|
||||
local positions = minetest.find_nodes_in_area(vector.subtract(mid, schematic_size), t, {"air"})
|
||||
if positions then
|
||||
for _,p in ipairs(positions) do
|
||||
if math.random(1, 100) <= 10 then
|
||||
local hit = p
|
||||
local tries = 1
|
||||
while true do
|
||||
hit = vector.add(hit, {x=0, y=-1, z=0})
|
||||
if want[minetest.get_node(vector.add(hit, {x=0, y=-1, z=0})).name] then
|
||||
break
|
||||
end
|
||||
if want[minetest.get_node(vector.add(hit, {x=0, y=-1, z=0})).name] == "ignore" then
|
||||
hit = nil
|
||||
break
|
||||
end
|
||||
if tries > 16 then
|
||||
hit = nil
|
||||
break
|
||||
end
|
||||
tries = tries + 1
|
||||
end
|
||||
if hit then
|
||||
minetest.set_node(hit, {name="default:dirt"})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue