tracks paths reworked, snow added to them

master
Och Noe 2019-06-19 04:54:26 +02:00
parent 616412caa2
commit bf08d13fd6
1 changed files with 69 additions and 36 deletions

105
init.lua
View File

@ -166,44 +166,75 @@ local woodpath_lengths = {
{ 25,25 }, { 25,25 },
} }
local path_names = { "wood", "cobble", "stonebrick" }
local tile_name = { "default_wood.png" , "default_cobble.png", "default_stone_brick.png"} -- path crossing track
local sound_name = { default.node_sound_wood_defaults() ,
default.node_sound_stone_defaults(), local snowdef = minetest.registered_nodes['default:snowblock']
default.node_sound_stone_defaults(), } local node_sound_snow_default = nil
local full_wood = { "default:wood", "default:cobble", "default:stonebrick" } if snowdef then
local half_wood = { "stairs:slab_wood" , "stairs:slab_cobble", node_sound_snow_default = snowdef.sounds
"stairs:slab_stonebrick" } end
-- nodelist
nodelist = {}
-- nodelist:insert( { name = "", tile = ".png",
-- sound = ,
-- full = "", half = "" } )
table.insert(nodelist, { name = "wood",
tile = "default_wood.png",
sound = default.node_sound_wood_defaults(),
full = "default:wood",
half = "stairs:slab_wood" } )
table.insert(nodelist, { name = "cobble",
tile = "default_cobble.png",
sound = default.node_sound_stone_defaults(),
full = "default:cobble",
half = "stairs:slab_cobble" } )
table.insert(nodelist, { name = "stonebrick",
tile = "default_stone_brick.png",
sound = default.node_sound_stone_defaults(),
full = "default:stonebrick",
half = "stairs:slab_stonebrick" } )
table.insert(nodelist, { name = "snow", tile = "default_snow.png",
sound = node_sound_snow_default,
full = "default:snowblock",
half = "stairs:slab_snowblock" } )
local adv_track = "advtrains:dtrack_placer" local adv_track = "advtrains:dtrack_placer"
if minetest.get_modpath("moreblocks") then if minetest.get_modpath("moreblocks") then
table.insert(path_names, "tar" ) table.insert(nodelist, { name = "tar",
table.insert(path_names, "stone tile" ) tile = "moreblocks_tar.png",
table.insert(tile_name, "moreblocks_tar.png" ) sound = default.node_sound_stone_defaults(),
table.insert(tile_name, "moreblocks_stone_tile.png" ) full = "moreblocks:tar",
table.insert(sound_name, default.node_sound_stone_defaults() ) half = "moreblocks:slab_tar" } )
table.insert(sound_name, default.node_sound_stone_defaults() ) table.insert(nodelist, { name = "stone tile",
table.insert(full_wood, "moreblocks:tar" ) tile = "moreblocks_stone_tile.png",
table.insert(full_wood, "moreblocks:stone_tile" ) sound = default.node_sound_stone_defaults(),
table.insert(half_wood, "moreblocks:slab_tar" ) full = "moreblocks:stone_tile",
table.insert(half_wood, "moreblocks:slab_stone_tile" ) half = "moreblocks:slab_stone_tile" } )
end end
for nr = 1,#path_names do
for _,entry in pairs(nodelist) do
for _,lengths in pairs(woodpath_lengths) do for _,lengths in pairs(woodpath_lengths) do
local b = lengths[1] -- "back" in 1/10 nodes local b = lengths[1] -- "back" in 1/10 nodes
local f = lengths[2] -- "front" in 1/10 nodes local f = lengths[2] -- "front" in 1/10 nodes
local h = string.format(":"..path_names[nr]:gsub(" ","_") .."path_track_%02d%02d",b,f) local h = string.format(":"..entry.name:gsub(" ","_") .."path_track_%02d%02d",b,f)
local d = string.format(path_names[nr] .." level crossing %02d-%02d",b,f) local d = string.format(entry.name .." level crossing %02d-%02d",b,f)
local h2 = string.format(":"..path_names[nr]:gsub(" ","_") .."path_track_narrow_%02d%02d",b,f) local h2 = string.format(":"..entry.name:gsub(" ","_") .."path_track_narrow_%02d%02d",b,f)
local d2 = string.format(path_names[nr] .." level crossing (narrow) %02d-%02d",b,f) local d2 = string.format(entry.name .." level crossing (narrow) %02d-%02d",b,f)
minetest.register_node(own_name..h, minetest.register_node(own_name..h,
{ {
tiles = { tile_name[nr], }, tiles = { entry.tile, },
description = d, description = d,
drawtype = "nodebox", drawtype = "nodebox",
paramtype = "light", paramtype = "light",
@ -215,16 +246,17 @@ for nr = 1,#path_names do
{-0.5, -0.5, b/-10, 0.5, -0.4, f/10}, {-0.5, -0.5, b/-10, 0.5, -0.4, f/10},
} }
}, },
groups = {choppy = 2, oddly_breakable_by_hand = 2, groups = {choppy = 2, not_blocking_trains = 1,
not_blocking_trains = 1}, oddly_breakable_by_hand = 2,
sounds = sound_name[nr], },
sounds = entry.sound,
on_place = minetest.rotate_node, on_place = minetest.rotate_node,
}) })
minetest.register_node(own_name..h2, minetest.register_node(own_name..h2,
{ {
tiles = { tile_name[nr], }, tiles = { entry.tile, },
description = d2, description = d2,
drawtype = "nodebox", drawtype = "nodebox",
paramtype = "light", paramtype = "light",
@ -237,9 +269,10 @@ for nr = 1,#path_names do
} }
}, },
groups = {choppy = 2, oddly_breakable_by_hand = 2, groups = {choppy = 2, not_blocking_trains = 1,
not_blocking_trains = 1}, oddly_breakable_by_hand = 2,
sounds = sound_name[nr], },
sounds = entry.sound,
on_place = minetest.rotate_node, on_place = minetest.rotate_node,
}) })
@ -254,7 +287,7 @@ for nr = 1,#path_names do
if (b>=5) and (f>=5) then if (b>=5) and (f>=5) then
b = b-5 b = b-5
f = f-5 f = f-5
craft[y][2] = full_wood[nr] craft[y][2] = entry.full
end end
end end
@ -262,17 +295,17 @@ for nr = 1,#path_names do
do do
if (b>=10) then if (b>=10) then
b = b-10 b = b-10
craft[y][1] = full_wood[nr] craft[y][1] = entry.full
elseif (b>=5) then elseif (b>=5) then
b = b-5 b = b-5
craft[y][1] = half_wood[nr] craft[y][1] = entry.half
end end
if (f>=10) then if (f>=10) then
f = f-10 f = f-10
craft[y][3] = full_wood[nr] craft[y][3] = entry.full
elseif (f>=5) then elseif (f>=5) then
f = f-5 f = f-5
craft[y][3] = half_wood[nr] craft[y][3] = entry.half
end end
end end