Add sloped rail

This commit is contained in:
teknomunk 2024-03-29 19:53:13 +00:00
parent 478c488c85
commit 75f394e5ab
3 changed files with 63 additions and 2 deletions

View file

@ -0,0 +1,15 @@
# hand-made Wavefront .OBJ file for sloped rail
mtllib mcl_minecarts_rail.mtl
o sloped_rail.001
v -0.500000 -0.500000 -0.500000
v -0.500000 0.500000 0.500000
v 0.500000 0.500000 0.500000
v 0.500000 -0.500000 -0.500000
vt 1.000000 0.000000
vt 1.000000 1.000000
vt 0.000000 1.000000
vt 0.000000 0.000000
vn 0.707106 0.707106 0.000000
usemtl None
s off
f 1/1/1 2/2/1 3/3/1 4/4/1

View file

@ -80,7 +80,6 @@ local function register_rail_v2(itemstring, def)
if def.groups then table_merge(groups, def.groups) end if def.groups then table_merge(groups, def.groups) end
def.groups = groups def.groups = groups
-- Build the node definition -- Build the node definition
local ndef = { local ndef = {
drawtype = "nodebox", drawtype = "nodebox",
@ -106,6 +105,49 @@ local function register_rail_v2(itemstring, def)
end end
mod.register_rail = register_rail_v2 mod.register_rail = register_rail_v2
local function register_rail_sloped(itemstring, def)
assert(def.tiles)
-- Build rail groups
local groups = table.copy(RAIL_DEFAULT_GROUPS)
if def.groups then table_merge(groups, def.groups) end
def.groups = groups
-- Build the node definition
local ndef = table.copy(RAIL_DEFAULTS)
table_merge(ndef,{
drawtype = "mesh",
mesh = "sloped_track.obj",
collision_box = {
type = "fixed",
fixed = {
{ -0.5, -0.5, -0.5, 0.5, 0.0, 0.5 },
{ -0.5, 0.0, 0.0, 0.5, 0.5, 0.5 }
}
},
selection_box = {
type = "fixed",
fixed = {
{ -0.5, -0.5, -0.5, 0.5, 0.0, 0.5 },
{ -0.5, 0.0, 0.0, 0.5, 0.5, 0.5 }
}
}
})
table_merge(ndef, def)
-- Add sensible defaults
if not ndef.inventory_image then ndef.inventory_image = ndef.tiles[1] end
if not ndef.wield_image then ndef.wield_image = ndef.tiles[1] end
print("registering sloped rail "..itemstring.." with definition: "..dump(ndef))
-- Make registrations
minetest.register_node(itemstring, ndef)
if craft then minetest.register_craft(craft) end
end
mod.register_rail_sloped = register_rail_sloped
-- Setup shared text -- Setup shared text
local railuse = S( local railuse = S(
"Place them on the ground to build your railway, the rails will automatically connect to each other and will".. "Place them on the ground to build your railway, the rails will automatically connect to each other and will"..

View file

@ -94,7 +94,7 @@ mod.update_rail_connections = update_rail_connections
-- Now get the translator after we have finished using S for other things -- Now get the translator after we have finished using S for other things
local S = minetest.get_translator(modname) local S = minetest.get_translator(modname)
local BASE_DEF = { local BASE_DEF = {
description = S("Rail"), description = S("New Rail"), -- Temporary name to make debugging easier
_tt_help = S("Track for minecarts"), _tt_help = S("Track for minecarts"),
_doc_items_longdesc = S("Rails can be used to build transport tracks for minecarts. Normal rails slightly slow down minecarts due to friction."), _doc_items_longdesc = S("Rails can be used to build transport tracks for minecarts. Normal rails slightly slow down minecarts due to friction."),
_doc_items_usagehelp = mod.text.railuse, _doc_items_usagehelp = mod.text.railuse,
@ -161,6 +161,10 @@ local function register_curves_rail(base_name, tiles, def)
} }
} }
})) }))
mod.register_rail_sloped(base_name.."_sloped", table_merge(table.copy(base_def),{
description = S("Sloped Rail"), -- Temporary name to make debugging easier
tiles = { tiles[1] },
}))
-- Cross variant -- Cross variant
--[[ --[[