mirror of
				https://github.com/mt-mods/coloredwood.git
				synced 2025-10-31 13:25:24 +01:00 
			
		
		
		
	Compare commits
	
		
			3 Commits
		
	
	
		
			colored_it
			...
			7f09ef4c3d
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | 7f09ef4c3d | ||
|  | b1a094b770 | ||
|  | 2eeb9f95da | 
							
								
								
									
										174
									
								
								init.lua
									
									
									
									
									
								
							
							
						
						
									
										174
									
								
								init.lua
									
									
									
									
									
								
							| @@ -117,26 +117,23 @@ table.insert(coloredwood.hues_plus_greys, "grey") | ||||
| local function is_stairsplus(name, colorized) | ||||
|  | ||||
| 	-- the format of a coloredwood stairsplus node is: | ||||
| 	-- "coloredwood:$CLASS_wood_$COLOR_$SHAPE" | ||||
| 	-- where $CLASS is "slab", "stair", etc., $SHAPE is "three quarter", "alt", etc., | ||||
| 	-- and $COLOR is one of the 13 color sets (counting "grey") | ||||
| 	-- moreblocks:class_wood_color_shape | ||||
| 	-- where class is "slab", "stair", etc. and shape is "three quarter", "alt", etc. | ||||
|  | ||||
| 	local a = string.find(name, ":") | ||||
| 	local b = string.find(name, "_") | ||||
|  | ||||
| 	local class = string.sub(name, a+1, b-1) -- from colon to underscore is the class | ||||
| 	local shape = "" | ||||
| 	local rest | ||||
| 	local colorshape | ||||
|  | ||||
| 	if class == "stair" | ||||
| 	  or class == "slab" | ||||
| 	  or class == "panel" | ||||
| 	  or class == "micro" | ||||
| 	  or class == "slope" then | ||||
| 		or class == "slab" | ||||
| 		or class == "panel" | ||||
| 		or class == "micro" | ||||
| 	or class == "slope" then | ||||
|  | ||||
| 		if colorized then | ||||
| 			colorshape = string.sub(name, b+6) | ||||
| 			local colorshape = string.sub(name, b+6) | ||||
| 			local c = string.find(colorshape, "_") or 0  -- first word after "_wood_" is color | ||||
| 			shape = string.sub(colorshape, c) -- everything after the color is the shape | ||||
| 			if colorshape == shape then shape = "" end -- if there was no shape | ||||
| @@ -155,19 +152,31 @@ minetest.register_node("coloredwood:wood_block", { | ||||
| 	paramtype = "light", | ||||
| 	paramtype2 = "color", | ||||
| 	palette = "unifieddyes_palette_extended.png", | ||||
| 	place_param2 = 240, | ||||
| 	walkable = true, | ||||
| 	sunlight_propagates = false, | ||||
| 	groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=2, not_in_creative_inventory=1, ud_param2_colorable = 1}, | ||||
| 	groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=2, not_in_creative_inventory=1, ud_param2_colorable = 1, wood = 1}, | ||||
| 	sounds = default.node_sound_wood_defaults(), | ||||
| 	after_place_node = unifieddyes.recolor_on_place, | ||||
| 	after_dig_node = unifieddyes.after_dig_node, | ||||
| 	drop = "default:wood" | ||||
| }) | ||||
|  | ||||
| for _, color in ipairs(coloredwood.hues_plus_greys) do | ||||
| -- moreblocks/stairsplus support | ||||
|  | ||||
| 	-- moreblocks/stairsplus support | ||||
| if coloredwood.enable_stairsplus then | ||||
|  | ||||
| 	if coloredwood.enable_stairsplus then | ||||
| 	local on_place_custom = function(itemstack, placer, pointed_thing) | ||||
| 		local pos = minetest.get_pointed_thing_position(pointed_thing, true) | ||||
| 		minetest.rotate_node(itemstack, placer, pointed_thing) | ||||
| 		unifieddyes.recolor_on_place(pos, placer, itemstack, pointed_thing) | ||||
| 		return itemstack | ||||
| 	end | ||||
|  | ||||
| 	--	stairsplus:register_all(modname, subname, recipeitem, {fields}) | ||||
|  | ||||
| 	for _, color in ipairs(coloredwood.hues_plus_greys) do | ||||
|  | ||||
| 		--	stairsplus:register_all(modname, subname, recipeitem, {fields}) | ||||
|  | ||||
| 		stairsplus:register_all( | ||||
| 			"coloredwood", | ||||
| @@ -179,101 +188,85 @@ for _, color in ipairs(coloredwood.hues_plus_greys) do | ||||
| 				paramtype = "light", | ||||
| 				paramtype2 = "colorfacedir", | ||||
| 				palette = "unifieddyes_palette_"..color.."s.png", | ||||
| 				after_place_node = function(pos, placer, itemstack, pointed_thing) | ||||
| 					minetest.rotate_node(itemstack, placer, pointed_thing) | ||||
| 				end, | ||||
| 				groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=2, not_in_creative_inventory=1, ud_param2_colorable = 1}, | ||||
| 			} | ||||
| 		) | ||||
| 				on_place = on_place_custom, | ||||
| 				groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=2, not_in_creative_inventory=1, ud_param2_colorable = 1, wood = 1}, | ||||
| 				after_dig_node = unifieddyes.after_dig_node | ||||
| 		}) | ||||
| 	end | ||||
| end | ||||
|  | ||||
| local coloredwood_cuts = {} | ||||
|  | ||||
| -- force settings for stairsplus default wood stair/slab/etc nodes | ||||
| -- and fix other stuff for colored versions of stairsplus nodes | ||||
|  | ||||
| if coloredwood.enable_stairsplus then | ||||
| 	-- force replacement node type for stairsplus default wood stair/slab/etc nodes | ||||
|  | ||||
| 	for _, i in pairs(minetest.registered_nodes) do | ||||
|  | ||||
| 		if (string.find(i.name, "moreblocks:stair_wood") | ||||
| 		  or string.find(i.name, "moreblocks:slab_wood") | ||||
| 		  or string.find(i.name, "moreblocks:panel_wood") | ||||
| 		  or string.find(i.name, "moreblocks:micro_wood") | ||||
| 		  or string.find(i.name, "moreblocks:slope_wood")) | ||||
| 		  and not string.find(i.name, "wood_tile") then | ||||
| 		if string.find(i.name, "moreblocks:stair_wood") | ||||
| 			or string.find(i.name, "moreblocks:slab_wood") | ||||
| 			or string.find(i.name, "moreblocks:panel_wood") | ||||
| 			or string.find(i.name, "moreblocks:micro_wood") | ||||
| 			or string.find(i.name, "moreblocks:slope_wood") | ||||
| 		then | ||||
|  | ||||
| 			table.insert(coloredwood_cuts, i.name) | ||||
| 			local a,b = string.find(i.name, "wood_tile") | ||||
| 			if not a then | ||||
|  | ||||
| 				local s1, s2 = is_stairsplus(i.name, false) | ||||
|  | ||||
| 				minetest.override_item(i.name, { | ||||
| 					ud_replacement_node = "coloredwood:"..s1.."_wood_grey"..s2, | ||||
| 					paramtype2 = "colorfacedir", | ||||
| 					on_place = on_place_custom, | ||||
| 					groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2, wood = 1, not_in_creative_inventory=1, ud_param2_colorable = 1, wood = 1}, | ||||
| 					drop = "moreblocks:"..s1.."_wood"..s2 | ||||
| 				}) | ||||
| 			end | ||||
| 		end | ||||
| 	end | ||||
|  | ||||
| 	-- fix drops and other stuff for colored versions of stairsplus nodes | ||||
|  | ||||
| 	for _, i in pairs(minetest.registered_nodes) do | ||||
|  | ||||
| 		if string.find(i.name, "coloredwood:stair_") | ||||
| 			or string.find(i.name, "coloredwood:slab_") | ||||
| 			or string.find(i.name, "coloredwood:panel_") | ||||
| 			or string.find(i.name, "coloredwood:micro_") | ||||
| 			or string.find(i.name, "coloredwood:slope_") | ||||
| 		then | ||||
|  | ||||
| 			local s1, s2 = is_stairsplus(string.gsub(i.name, "coloredwood:", "moreblocks:"), true) | ||||
|  | ||||
| 			minetest.override_item(i.name, { | ||||
| 				groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2, wood = 1, not_in_creative_inventory=1, ud_param2_colorable = 1}, | ||||
| 				on_place = on_place_custom, | ||||
| 				drop = "moreblocks:"..s1.."_wood"..s2 | ||||
| 			}) | ||||
| 		end | ||||
| 	end | ||||
| end | ||||
|  | ||||
| -- "coloredwood:slope_wood_outer_half_raised" | ||||
|  | ||||
| for _, mname in ipairs(coloredwood_cuts) do | ||||
|  | ||||
| 	local class, shape = is_stairsplus(mname, nil) | ||||
|  | ||||
| 	unifieddyes.register_color_craft({ | ||||
| 		output_prefix = "coloredwood:"..class.."_wood_", | ||||
| 		output_suffix = shape, | ||||
| 		palette = true, | ||||
| 		type = "shapeless", | ||||
| 		neutral_node = mname, | ||||
| 		recipe = { | ||||
| 			"NEUTRAL_NODE", | ||||
| 			"MAIN_DYE" | ||||
| 		} | ||||
| 	}) | ||||
| end | ||||
|  | ||||
| minetest.override_item("default:wood", { | ||||
| 	palette = "unifieddyes_palette_extended.png", | ||||
| 	ud_replacement_node = "coloredwood:wood_block", | ||||
| 	after_place_node = unifieddyes.recolor_on_place, | ||||
| 	groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2, wood = 1, ud_param2_colorable = 1}, | ||||
| }) | ||||
|  | ||||
| default.register_fence("coloredwood:fence", { | ||||
| 	description = "Colored wooden fence", | ||||
| 	texture = "coloredwood_fence_base.png", | ||||
| 	paramtype2 = "color", | ||||
| 	palette = "unifieddyes_palette_extended.png", | ||||
| 	groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2, ud_param2_colorable = 1}, | ||||
| 	sounds = default.node_sound_wood_defaults(), | ||||
| 	material = "default:wood" | ||||
| }) | ||||
| local fence_data = table.copy(minetest.registered_items["default:fence_wood"]) | ||||
| fence_data.name = "coloredwood:fence" | ||||
| fence_data.description = "Colored wooden fence" | ||||
| fence_data.tiles = {"coloredwood_fence_base.png"} | ||||
| fence_data.paramtype2 = "color" | ||||
| fence_data.palette = "unifieddyes_palette_extended.png" | ||||
| fence_data.groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2, ud_param2_colorable = 1, fence = 1, not_in_creative_inventory = 1} | ||||
| fence_data.after_place_node = unifieddyes.recolor_on_place | ||||
| fence_data.after_dig_node = unifieddyes.after_dig_node | ||||
| fence_data.drop = "default:fence_wood" | ||||
|  | ||||
| minetest.register_item("coloredwood:fence", fence_data) | ||||
|  | ||||
| minetest.override_item("default:fence_wood", { | ||||
| 	palette = "unifieddyes_palette_extended.png", | ||||
| 	groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2, ud_param2_colorable = 1} | ||||
| }) | ||||
|  | ||||
| -- Crafts | ||||
|  | ||||
| unifieddyes.register_color_craft({ | ||||
| 	output = "coloredwood:wood_block", | ||||
| 	palette = "extended", | ||||
| 	type = "shapeless", | ||||
| 	neutral_node = "default:wood", | ||||
| 	recipe = { | ||||
| 		"NEUTRAL_NODE", | ||||
| 		"MAIN_DYE" | ||||
| 	} | ||||
| }) | ||||
|  | ||||
| unifieddyes.register_color_craft({ | ||||
| 	output = "coloredwood:fence", | ||||
| 	palette = "extended", | ||||
| 	type = "shapeless", | ||||
| 	neutral_node = "default:fence_wood", | ||||
| 	recipe = { | ||||
| 		"NEUTRAL_NODE", | ||||
| 		"MAIN_DYE" | ||||
| 	} | ||||
| 	ud_replacement_node = "coloredwood:fence", | ||||
| 	after_place_node = unifieddyes.recolor_on_place, | ||||
| 	groups = {fence = 1, choppy = 2, oddly_breakable_by_hand = 2, flammable = 2, ud_param2_colorable = 1} | ||||
| }) | ||||
|  | ||||
| -- ============================ | ||||
| @@ -299,7 +292,6 @@ end | ||||
|  | ||||
| table.insert(coloredwood.old_13_color_nodes, "coloredwood:wood_grey") | ||||
|  | ||||
|  | ||||
| -- add all of the stairsplus nodes, if moreblocks is installed. | ||||
| if coloredwood.enable_stairsplus then | ||||
| 	for _, shape in ipairs(circular_saw.names) do | ||||
| @@ -354,7 +346,6 @@ minetest.register_lbm({ | ||||
| 	nodenames = coloredwood.old_static_nodes, | ||||
| 	action = function(pos, node) | ||||
| 		local meta = minetest.get_meta(pos) | ||||
|  | ||||
| 		local name = node.name | ||||
| 		local hue, sat, val = unifieddyes.get_hsv(name) | ||||
| 		local color = val..hue..sat | ||||
| @@ -373,7 +364,6 @@ minetest.register_lbm({ | ||||
| 			minetest.set_node(pos, { name = newname, param2 = cfdir }) | ||||
| 			local meta = minetest.get_meta(pos) | ||||
| 			meta:set_string("dye", "unifieddyes:"..color) | ||||
|  | ||||
| 		elseif string.find(name, ":fence") then | ||||
| 			local paletteidx, hue = unifieddyes.getpaletteidx("unifieddyes:"..color, "extended") | ||||
| 			minetest.set_node(pos, { name = "coloredwood:fence", param2 = paletteidx }) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user