Add wooden platforms for rails
parent
6294dc3dd8
commit
1d890a6ae0
25
init.lua
25
init.lua
|
@ -74,6 +74,16 @@ local function CanBuild(pos)
|
|||
return minetest.registered_nodes[minetest.get_node(pos).name].is_ground_content
|
||||
end
|
||||
|
||||
-- Checks if the node is empty space which requires to be filled by a platform
|
||||
local function NeedsPlatform(pos)
|
||||
local node = minetest.get_node(pos)
|
||||
local node2 = minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z})
|
||||
local nodedef = minetest.registered_nodes[node.name]
|
||||
local node2def = minetest.registered_nodes[node2.name]
|
||||
return nodedef.is_ground_content and nodedef.walkable == false
|
||||
and node2def.is_ground_content and node2def.walkable == false
|
||||
end
|
||||
|
||||
-- Würfel…
|
||||
-- Cube…
|
||||
local function Cube(p, radius, node)
|
||||
|
@ -88,6 +98,16 @@ local function Cube(p, radius, node)
|
|||
end
|
||||
end
|
||||
|
||||
local function Platform(p, radius, node)
|
||||
for zi = p.z-radius, p.z+radius do
|
||||
for xi = p.x-radius, p.x+radius do
|
||||
if NeedsPlatform({x=xi,y=p.y-(radius+1),z=zi}) then
|
||||
minetest.set_node({x=xi,y=p.y-(radius+1),z=zi}, node)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Random chest items
|
||||
-- Zufälliger Kisteninhalt
|
||||
local function rci()
|
||||
|
@ -179,6 +199,10 @@ local function corridor_part(start_point, segment_vector, segment_count)
|
|||
end
|
||||
for segmentindex = 0, segment_count-1 do
|
||||
Cube(p, 1, {name="air"})
|
||||
-- Add wooden platform, if neccessary. To avoid floating rails
|
||||
if segment_vector.y == 0 then
|
||||
Platform(p, 1, node_wood)
|
||||
end
|
||||
-- Diese komischen Holz-Konstruktionen
|
||||
-- These strange wood structs
|
||||
if segmentindex % 2 == 1 and segment_vector.y == 0 then
|
||||
|
@ -214,7 +238,6 @@ local function corridor_part(start_point, segment_vector, segment_count)
|
|||
minetest.set_node({x=calc[5], y=p.y+1, z=calc[6]}, {name=walltorchtype, param2=torchdir[1]})
|
||||
minetest.set_node({x=calc[7], y=p.y+1, z=calc[8]}, {name=walltorchtype, param2=torchdir[2]})
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-- nächster Punkt durch Vektoraddition
|
||||
|
|
Loading…
Reference in New Issue