From ec33a440864eaaed83eee740c7730adcb23e9265 Mon Sep 17 00:00:00 2001 From: Hume2 Date: Tue, 18 Jun 2019 12:28:59 +0200 Subject: [PATCH] Add slope labels --- labels/init.lua | 257 +++++++++++++++++++++++++++++++++++------------- 1 file changed, 188 insertions(+), 69 deletions(-) diff --git a/labels/init.lua b/labels/init.lua index e8d0624..9388614 100644 --- a/labels/init.lua +++ b/labels/init.lua @@ -226,10 +226,12 @@ minetest.register_node(":streets:printer", { }, }) -streets.register_label = function(friendlyname,name,tex,color,ink_needed,hide) +streets.register_label = function(friendlyname,name,tex,color,ink_needed,hide,slopes,symetrical) local groups = {snappy = 3,attached_node = 1,oddly_breakable_by_hand = 1} if hide then groups.not_in_creative_inventory = 1 end - minetest.register_node(":streets:mark_"..name,{ + local my_name = ":streets:mark_"..name + local myname = "streets:mark_"..name + minetest.register_node(my_name,{ description = streets.S("Marking Overlay: "..friendlyname), tiles = {tex,"streets_rw_transparent.png"}, drawtype = "nodebox", @@ -239,18 +241,7 @@ streets.register_label = function(friendlyname,name,tex,color,ink_needed,hide) sunlight_propagates = true, walkable = false, inventory_image = tex, - wield_image = tex, - after_place_node = function(pos) - local node = minetest.get_node(pos) - local lower_pos = {x = pos.x, y = pos.y-1, z = pos.z} - local lower_node = minetest.get_node(lower_pos) - if lower_node.name == "streets:asphalt" then - lower_node.name = "streets:mark_"..(node.name:sub(14)).."_on_asphalt" - lower_node.param2 = node.param2 - minetest.set_node(lower_pos,lower_node) - minetest.remove_node(pos) - end - end, + wield_image = tex, node_box = { type = "fixed", fixed = {-0.5,-0.5,-0.5,0.5,-0.499,0.5} @@ -261,193 +252,321 @@ streets.register_label = function(friendlyname,name,tex,color,ink_needed,hide) } }) - minetest.register_node(":streets:mark_"..name.."_on_asphalt",{ - description = streets.S("Asphalt With Marking: "..friendlyname), - groups = {cracky=3}, - tiles = {"streets_asphalt.png^"..tex,"streets_asphalt.png","streets_asphalt.png","streets_asphalt.png","streets_asphalt.png^"..tex.."^[transformR180","streets_asphalt.png^"..tex}, - paramtype2 = "facedir" - }) - - minetest.register_craft({ - output = "streets:mark_"..name.."_on_asphalt", - type = "shapeless", - recipe = {"streets:asphalt","streets:mark_"..name} - }) - - if minetest.get_modpath("moreblocks") then - stairsplus:register_all("streets", name, "streets:mark_"..name.."_on_asphalt", { - description = "Asphalt with Marking: "..friendlyname, - tiles = {"streets_asphalt.png^"..tex,"streets_asphalt.png","streets_asphalt.png","streets_asphalt.png","streets_asphalt.png^"..tex.."^[transformR180","streets_asphalt.png^"..tex}, - groups = {cracky=3} + if slopes then + minetest.register_node(my_name.."_slope1", { + description = streets.S("Marking Overlay: "..friendlyname.." (lower slope)"), + tiles = {tex}, + groups = {dig_immediate = 2}, + paramtype = "light", + paramtype2 = "facedir", + drawtype = "mesh", + mesh = "labels_slope_1.obj", + groups = groups, + sunlight_propagates = true, + walkable = false, + inventory_image = tex.."^streets_slope_1.png", + wield_image = tex.."^streets_slope_1.png", + selection_box = { + type = "fixed", + fixed = {-1/2, -1/2, -1/2, 1/2, -1/2+1/16, 1/2} + } }) + + minetest.register_node(my_name.."_slope2", { + description = streets.S("Marking Overlay: "..friendlyname.." (upper slope)"), + tiles = {tex}, + groups = {dig_immediate = 2}, + paramtype = "light", + paramtype2 = "facedir", + drawtype = "mesh", + mesh = "labels_slope_2.obj", + groups = groups, + sunlight_propagates = true, + walkable = false, + inventory_image = tex.."^streets_slope_2.png", + wield_image = tex.."^streets_slope_2.png", + selection_box = { + type = "fixed", + fixed = {-1/2, -1/2, -1/2, 1/2, -1/2+1/16, 1/2} + } + }) + + if not symetrical then + minetest.register_node(my_name.."_slope3", { + description = streets.S("Marking Overlay: "..friendlyname.." (upper slope down)"), + tiles = {tex}, + groups = {dig_immediate = 2}, + paramtype = "light", + paramtype2 = "facedir", + drawtype = "mesh", + mesh = "labels_slope_3.obj", + groups = groups, + sunlight_propagates = true, + walkable = false, + inventory_image = tex.."^streets_slope_3.png", + wield_image = tex.."^streets_slope_3.png", + selection_box = { + type = "fixed", + fixed = {-1/2, -1/2, -1/2, 1/2, -1/2+1/16, 1/2} + } + }) + + minetest.register_node(my_name.."_slope4", { + description = streets.S("Marking Overlay: "..friendlyname.." (lower slope down)"), + tiles = {tex}, + groups = {dig_immediate = 2}, + paramtype = "light", + paramtype2 = "facedir", + drawtype = "mesh", + mesh = "labels_slope_4.obj", + groups = groups, + sunlight_propagates = true, + walkable = false, + inventory_image = tex.."^streets_slope_4.png", + wield_image = tex.."^streets_slope_4.png", + selection_box = { + type = "fixed", + fixed = {-1/2, -1/2, -1/2, 1/2, -1/2+1/16, 1/2} + } + }) + end + + minetest.register_craft({ + output = myname.."_slope1 2", + recipe = {{"","",""}, + {"","",myname}, + {myname,"",""}} + }) + + minetest.register_craft({ + output = myname.."_slope2 2", + recipe = {{"","",myname}, + {myname,"",""}, + {"","",""}} + }) + + minetest.register_craft({ + output = myname, + type = "shapeless", + recipe = {myname.."_slope1"}, + }) + + minetest.register_craft({ + output = myname, + type = "shapeless", + recipe = {myname.."_slope2"}, + }) + + if symetrical then + minetest.register_craft({ + output = myname.."_slope1 2", + recipe = {{"","",""}, + {myname,"",""}, + {"","",myname}} + }) + + minetest.register_craft({ + output = myname.."_slope2 2", + recipe = {{myname,"",""}, + {"","",myname}, + {"","",""}} + }) + else + minetest.register_craft({ + output = myname.."_slope4 2", + recipe = {{"","",""}, + {myname,"",""}, + {"","",myname}} + }) + + minetest.register_craft({ + output = myname.."_slope3 2", + recipe = {{myname,"",""}, + {"","",myname}, + {"","",""}} + }) + + minetest.register_craft({ + output = myname, + type = "shapeless", + recipe = {myname.."_slope3"}, + }) + + minetest.register_craft({ + output = myname, + type = "shapeless", + recipe = {myname.."_slope4"}, + }) + end end + local printdata = {name="streets:mark_"..name,color=color,inkamt=ink_needed} table.insert(labels.printer.marktypes,printdata) end --White Markings -streets.register_label("All-White","all_white","streets_all_white.png","white",9) +streets.register_label("All-White","all_white","streets_all_white.png","white",9,false,true,true) -streets.register_label("Solid White Side Line","solid_white_side_line","streets_asphalt_side.png","white",3) +streets.register_label("Solid White Side Line","solid_white_side_line","streets_asphalt_side.png","white",3,false,true,false) minetest.register_alias("streets:asphalt_side","streets:mark_solid_white_side_line_on_asphalt") minetest.register_alias("streets:asphalt_sideline","streets:mark_solid_white_side_line_on_asphalt") -streets.register_label("Solid White Side Line (rotated)","solid_white_side_line_rotated","streets_asphalt_side.png^[transformR180","white",3,true) +--streets.register_label("Solid White Side Line (rotated)","solid_white_side_line_rotated","streets_asphalt_side.png^[transformR180","white",3,true,true,false) -minetest.register_alias("streets:asphalt_sideline_r","streets:mark_solid_white_side_line_rotated_on_asphalt") +--minetest.register_alias("streets:asphalt_sideline_r","streets:mark_solid_white_side_line_rotated_on_asphalt") -streets.register_label("Solid White Center Line","solid_white_center_line","streets_asphalt_solid_line.png","white",2) +streets.register_label("Solid White Center Line","solid_white_center_line","streets_asphalt_solid_line.png","white",2,false,true,true) minetest.register_alias("streets:asphalt_middle","streets:mark_solid_white_center_line_on_asphalt") minetest.register_alias("streets:asphalt_solid_line","streets:mark_solid_white_center_line_on_asphalt") -streets.register_label("Dashed White Center Line","dashed_white_center_line","streets_asphalt_dashed_line.png","white",1) +streets.register_label("Dashed White Center Line","dashed_white_center_line","streets_asphalt_dashed_line.png","white",1,false,true,true) minetest.register_alias("streets:asphalt_middle_dashed","streets:mark_dashed_white_center_line_on_asphalt") minetest.register_alias("streets:asphalt_dashed_line","streets:mark_dashed_white_center_line_on_asphalt") -streets.register_label("Solid White Side Line (corner)","solid_white_side_line_corner","streets_asphalt_outer_edge.png","white",4) +streets.register_label("Solid White Side Line (corner)","solid_white_side_line_corner","streets_asphalt_outer_edge.png","white",4,false,false,false) minetest.register_alias("streets:asphalt_outer_edge","streets:mark_solid_white_side_line_corner_on_asphalt") -streets.register_label("Solid White Side Line (corner, rotated)","solid_white_side_line_corner_rotated","streets_asphalt_outer_edge.png^[transformR270","white",4,true) +--streets.register_label("Solid White Side Line (corner, rotated)","solid_white_side_line_corner_rotated","streets_asphalt_outer_edge.png^[transformR270","white",4,true,false,false) -minetest.register_alias("streets:asphalt_outer_edge_r","streets:mark_solid_white_side_line_corner_rotated_on_asphalt") +--minetest.register_alias("streets:asphalt_outer_edge_r","streets:mark_solid_white_side_line_corner_rotated_on_asphalt") -streets.register_label("Parking (white)","white_parking","streets_parking.png","white",4) +streets.register_label("Parking (white)","white_parking","streets_parking.png","white",4,false,false,false) minetest.register_alias("streets:asphalt_parking","streets:mark_white_parking_on_asphalt") -streets.register_label("White Arrow (straight)","white_arrow_straight","streets_arrow_straight.png","white",3) +streets.register_label("White Arrow (straight)","white_arrow_straight","streets_arrow_straight.png","white",3,false,true,false) minetest.register_alias("streets:asphalt_arrow_straight","streets:mark_white_arrow_straight_on_asphalt") -streets.register_label("White Arrow (left)","white_arrow_left","streets_arrow_left.png","white",3) +streets.register_label("White Arrow (left)","white_arrow_left","streets_arrow_left.png","white",3,false,true,false) minetest.register_alias("streets:asphalt_arrow_left","streets:mark_white_arrow_left_on_asphalt") -streets.register_label("White Arrow (right)","white_arrow_right","streets_arrow_right.png","white",3) +streets.register_label("White Arrow (right)","white_arrow_right","streets_arrow_right.png","white",3,false,true,false) minetest.register_alias("streets:asphalt_arrow_right","streets:mark_white_arrow_right_on_asphalt") -streets.register_label("White Arrow (left+straight)","white_arrow_left_straight","streets_arrow_straight_left.png","white",4) +streets.register_label("White Arrow (left+straight)","white_arrow_left_straight","streets_arrow_straight_left.png","white",4,false,true,false) minetest.register_alias("streets:asphalt_arrow_straight_left","streets:mark_white_arrow_left_straight_on_asphalt") -streets.register_label("White Arrow (straight+right)","white_arrow_straight_right","streets_arrow_straight_right.png","white",4) +streets.register_label("White Arrow (straight+right)","white_arrow_straight_right","streets_arrow_straight_right.png","white",4,false,true,false) minetest.register_alias("streets:asphalt_arrow_straight_right","streets:mark_white_arrow_straight_right_on_asphalt") -streets.register_label("White Arrow (left+straight+right)","white_arrow_left_straight_right","streets_arrow_alldirs.png","white",5) +streets.register_label("White Arrow (left+straight+right)","white_arrow_left_straight_right","streets_arrow_alldirs.png","white",5,false,true,false) minetest.register_alias("streets:asphalt_arrow_alldirs","streets:mark_white_arrow_left_straight_right_on_asphalt") --Yellow streetsmod markings -streets.register_label("Solid Yellow Center Line","solid_yellow_center_line","streets_rw_solid_line.png","yellow",3) +streets.register_label("Solid Yellow Center Line","solid_yellow_center_line","streets_rw_solid_line.png","yellow",3,false,true,true) minetest.register_alias("streets:rw_asphalt_solid","streets:mark_solid_yellow_center_line") -streets.register_label("Dashed Yellow Center Line","dashed_yellow_center_line","streets_rw_dashed_line.png","yellow",2) +streets.register_label("Dashed Yellow Center Line","dashed_yellow_center_line","streets_rw_dashed_line.png","yellow",2,false,true,true) minetest.register_alias("streets:rw_asphalt_dashed","streets:mark_dashed_yellow_center_line") -streets.register_label("Yellow X","yellow_x","streets_rw_cross.png","yellow",3) +streets.register_label("Yellow X","yellow_x","streets_rw_cross.png","yellow",3,false,true,true) minetest.register_alias("streets:rw_cross","streets:mark_yellow_x") -streets.register_label("Solid Yellow Side Line (corner)","solid_yellow_side_line_corner","streets_rw_outer_edge.png","yellow",4) +streets.register_label("Solid Yellow Side Line (corner)","solid_yellow_side_line_corner","streets_rw_outer_edge.png","yellow",4,false,false,false) minetest.register_alias("streets:rw_outer_edge","streets:solid_yellow_side_line_corner") -streets.register_label("Solid Yellow Side Line (corner,rotated)","solid_yellow_side_line_corner_rotated","streets_rw_outer_edge.png^[transformR270","yellow",5,true) +--streets.register_label("Solid Yellow Side Line (corner,rotated)","solid_yellow_side_line_corner_rotated","streets_rw_outer_edge.png^[transformR270","yellow",5,true,false,false) -minetest.register_alias("streets:rw_outer_edge","streets:solid_yellow_side_line_corner") +--minetest.register_alias("streets:rw_outer_edge","streets:solid_yellow_side_line_corner") -streets.register_label("Parking (yellow)","yellow_parking","streets_rw_parking.png","yellow",4) +streets.register_label("Parking (yellow)","yellow_parking","streets_rw_parking.png","yellow",4,false,false,false) minetest.register_alias("streets:rw_parking","streets:mark_yellow_parking") -streets.register_label("Yellow Arrow (straight)","yellow_arrow_straight","streets_rw_arrow_straight.png","yellow",3) +streets.register_label("Yellow Arrow (straight)","yellow_arrow_straight","streets_rw_arrow_straight.png","yellow",3,false,true,false) minetest.register_alias("streets:rw_straight","streets:mark_yellow_arrow_straight") -streets.register_label("Yellow Arrow (left)","yellow_arrow_left","streets_rw_arrow_left.png","yellow",3) +streets.register_label("Yellow Arrow (left)","yellow_arrow_left","streets_rw_arrow_left.png","yellow",3,false,true,false) minetest.register_alias("streets:rw_left","streets:mark_yellow_arrow_left") -streets.register_label("Yellow Arrow (right)","yellow_arrow_right","streets_rw_arrow_right.png","yellow",3) +streets.register_label("Yellow Arrow (right)","yellow_arrow_right","streets_rw_arrow_right.png","yellow",3,false,true,false) minetest.register_alias("streets:rw_right","streets:mark_yellow_arrow_right") -streets.register_label("Yellow Arrow (left+straight)","yellow_arrow_left_straight","streets_rw_arrow_straight_left.png","yellow",4) +streets.register_label("Yellow Arrow (left+straight)","yellow_arrow_left_straight","streets_rw_arrow_straight_left.png","yellow",4,false,true,false) minetest.register_alias("streets:rw_straight_left","streets:mark_yellow_arrow_left_straight") -streets.register_label("Yellow Arrow (straight+right)","yellow_arrow_straight_right","streets_rw_arrow_straight_right.png","yellow",4) +streets.register_label("Yellow Arrow (straight+right)","yellow_arrow_straight_right","streets_rw_arrow_straight_right.png","yellow",4,false,true,false) minetest.register_alias("streets:rw_straight_right","streets:mark_yellow_arrow_straight_right") -streets.register_label("Yellow Arrow (left+straight+right)","yellow_arrow_left_straight_right","streets_rw_arrow_alldirs.png","yellow",5) +streets.register_label("Yellow Arrow (left+straight+right)","yellow_arrow_left_straight_right","streets_rw_arrow_alldirs.png","yellow",5,false,true,false) minetest.register_alias("streets:rw_alldirs","streets:mark_yellow_arrow_left_straight_right") -streets.register_label("Solid Yellow Side Line","solid_yellow_side_line","streets_rw_asphalt_side.png","yellow",3) +streets.register_label("Solid Yellow Side Line","solid_yellow_side_line","streets_rw_asphalt_side.png","yellow",3,false,true,false) minetest.register_alias("streets:rw_sideline","streets:mark_solid_yellow_side_line") -streets.register_label("Solid Yellow Side Line (rotated)","solid_yellow_side_line_rotated","streets_rw_asphalt_side.png^[transformR180","yellow",3,true) +--streets.register_label("Solid Yellow Side Line (rotated)","solid_yellow_side_line_rotated","streets_rw_asphalt_side.png^[transformR180","yellow",3,true,true,false) -streets.register_label("Yellow Diagonal Lines","yellow_diagonal","streets_yellow_diagonal_lines.png","yellow",5) +streets.register_label("Yellow Diagonal Lines","yellow_diagonal","streets_yellow_diagonal_lines.png","yellow",5,false,true,true) --Infrastructure markings -streets.register_label("Solid Yellow Center Line (wide)","solid_yellow_center_line_wide","infrastructure_single_yellow_line.png","yellow",4) +streets.register_label("Solid Yellow Center Line (wide)","solid_yellow_center_line_wide","infrastructure_single_yellow_line.png","yellow",4,false,true,true) minetest.register_alias("infrastructure:asphalt_center_solid_line","streets:mark_solid_yellow_center_line_wide_on_asphalt") -streets.register_label("Solid Yellow Center Line (wide,offset)","solid_yellow_center_line_wide_offset","infrastructure_solid_yellow_line_one_side.png","yellow",4) +streets.register_label("Solid Yellow Center Line (wide,offset)","solid_yellow_center_line_wide_offset","infrastructure_solid_yellow_line_one_side.png","yellow",4,false,true,false) minetest.register_alias("infrastructure:asphalt_center_solid_one_side","streets:mark_solid_yellow_center_line_wide_offset_on_asphalt") -streets.register_label("Double Yellow Center Line (wide)","double_yellow_center_line_wide","infrastructure_double_yellow_line.png","yellow",6) +streets.register_label("Double Yellow Center Line (wide)","double_yellow_center_line_wide","infrastructure_double_yellow_line.png","yellow",6,false,true,true) minetest.register_alias("infrastructure:asphalt_center_solid_double","streets:mark_double_yellow_center_line_wide_on_asphalt") -streets.register_label("Solid Yellow Center Line (wide,corner)","solid_yellow_center_line_wide_corner","infrastructure_single_yellow_line_corner.png","yellow",4) +streets.register_label("Solid Yellow Center Line (wide,corner)","solid_yellow_center_line_wide_corner","infrastructure_single_yellow_line_corner.png","yellow",4,false,false,false) minetest.register_alias("infrastructure:asphalt_center_corner_single","streets:mark_solid_yellow_center_line_wide_corner_on_asphalt") -streets.register_label("Double Yellow Center Line (wide,corner)","double_yellow_center_line_wide_corner","infrastructure_solid_double_yellow_line_corner.png","yellow",6) +streets.register_label("Double Yellow Center Line (wide,corner)","double_yellow_center_line_wide_corner","infrastructure_solid_double_yellow_line_corner.png","yellow",6,false,false,false) minetest.register_alias("infrastructure:asphalt_center_corner_double","streets:mark_double_yellow_center_line_wide_corner_on_asphalt")