aboutsummaryrefslogtreecommitdiff
path: root/advtrains/textures/advtrains_dtrack_placer.png
diff options
context:
space:
mode:
Diffstat (limited to 'advtrains/textures/advtrains_dtrack_placer.png')
0 files changed, 0 insertions, 0 deletions
id='n99' href='#n99'>99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448
dofile(minetest.get_modpath("moreblocks").."/_config.txt")

-- Nodes will be called <modname>:{stair,slab,panel,micro}_<subname>

if minetest.get_modpath("unified_inventory") or not minetest.setting_getbool("creative_mode") then
	stairsplus_expect_infinite_stacks = false
else
	stairsplus_expect_infinite_stacks = true
end

-- these vales are in order: facedir in degrees = 90, 0, 270, 180, 90

local dirs1 = { 21, 20, 23, 22, 21 }
local dirs2 = { 15, 8, 17, 6, 15 }
local dirs3 = { 14, 11, 16, 5, 14 }

stairsplus_players_onwall = {}

minetest.register_chatcommand("st", {
	params = "",
	description = "Toggle stairsplus between placing wall/vertical stairs/panels and normal.",
	func = function(name, param)
		stairsplus_players_onwall[name] = not stairsplus_players_onwall[name]

		if stairsplus_players_onwall[name] then
			 minetest.chat_send_player(name, "Stairsplus:  Placing wall stairs/vertical panels.")
		else
			 minetest.chat_send_player(name, "Stairsplus:  Placing floor/ceiling stairs/panels.")
		end
	end
})

stairsplus_can_it_stack = function(itemstack, placer, pointed_thing)
	return false
--[[
	if pointed_thing.type ~= "node" then
		return itemstack
	end

	-- If it's being placed on an another similar one, replace it with
	-- a full block
	local slabpos = nil
	local slabnode = nil
	local p1 = pointed_thing.above
	p1 = {x = p1.x, y = p1.y - 1, z = p1.z}
	local n1 = minetest.env:get_node(p1)
	if n1.name == modname .. ":slab_" .. subname then
		slabpos = p1
		slabnode = n1
	end
	if slabpos then
		-- Remove the slab at slabpos
		minetest.env:remove_node(slabpos)
		-- Make a fake stack of a single item and try to place it
		local fakestack = ItemStack(recipeitem)
		pointed_thing.above = slabpos
		fakestack = minetest.item_place(fakestack, placer, pointed_thing)
		-- If the item was taken from the fake stack, decrement original
		if not fakestack or fakestack:is_empty() then
			itemstack:take_item(1)
		-- Else put old node back
		else
			minetest.env:set_node(slabpos, slabnode)
		end
		return itemstack
	end

	if n1.name == modname .. ":slab_" .. subname .. "_quarter" then
		slabpos = p1
		slabnode = n1
	end
	if slabpos then
		-- Remove the slab at slabpos
		minetest.env:remove_node(slabpos)
		-- Make a fake stack of a single item and try to place it
		local fakestack = ItemStack(modname .. ":slab_" .. subname .. "_three_quarter")
		pointed_thing.above = slabpos
		fakestack = minetest.item_place(fakestack, placer, pointed_thing)
		-- If the item was taken from the fake stack, decrement original
		if not fakestack or fakestack:is_empty() then
			itemstack:take_item(1)
		-- Else put old node back
		else
			minetest.env:set_node(slabpos, slabnode)
		end
		return itemstack
	end

	-- Otherwise place regularly
	return minetest.item_place(itemstack, placer, pointed_thing)

]]--

end

local function get_nodedef_field(nodename, fieldname)
	if not minetest.registered_nodes[nodename] then
		return nil
	end
	return minetest.registered_nodes[nodename][fieldname]
end

function stairsplus_rotate_and_place(itemstack, placer, pointed_thing, onwall)

	local node = minetest.env:get_node(pointed_thing.under)

	if not minetest.registered_nodes[node.name] or not minetest.registered_nodes[node.name].on_rightclick then

		local above = pointed_thing.above
		local under = pointed_thing.under
		local top = {x=under.x, y=under.y+1, z=under.z}

		local pitch = placer:get_look_pitch()
		local node = minetest.env:get_node(above)
		local fdir = minetest.dir_to_facedir(placer:get_look_dir())
		local wield_name = itemstack:get_name()

		local slab = string.find(wield_name, "slab")
		local panel = string.find(wield_name, "panel")
		local micro = string.find(wield_name, "micro")
		local iswall = (above.x ~= under.x) or (above.z ~= under.z)
		local isceiling = (above.x == under.x) and (above.z == under.z) and (pitch > 0)

		if get_nodedef_field(minetest.env:get_node(under).name, "buildable_to") then
			if slab then fdir = 0 end
			minetest.env:add_node(under, {name = wield_name, param2 = fdir }) -- place right side up
		elseif not get_nodedef_field(minetest.env:get_node(above).name, "buildable_to") then
			return
		elseif onwall or (iswall and (slab or panel)) then 
			if slab then
				minetest.env:add_node(above, {name = wield_name, param2 = dirs2[fdir+2] }) -- place with wall slab rotation
			else
				minetest.env:add_node(above, {name = wield_name, param2 = dirs3[fdir+2] }) -- place with wall panel/micro rotation
			end
		elseif isceiling then
			local nfdir = dirs1[fdir+2]
			if slab then nfdir = 22 end
			minetest.env:add_node(above, {name = wield_name, param2 = nfdir }) -- place upside down variant
		else
			if slab then fdir = 0 end
			minetest.env:add_node(above, {name = wield_name, param2 = fdir }) -- place right side up
		end

		if not stairsplus_expect_infinite_stacks then
			itemstack:take_item()
			return itemstack
		end
	else
		minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, placer)
	end
end

function register_stair_slab_panel_micro(modname, subname, recipeitem, groups, images, description, drop, light)
        if show_stairsplus_creative_inv then
                groups.not_in_creative_inventory = 0
        else
                groups.not_in_creative_inventory = 1
        end
        register_stair(modname, subname, recipeitem, groups, images, description, drop, light)
        register_slab( modname, subname, recipeitem, groups, images, description, drop, light)
        register_panel(modname, subname, recipeitem, groups, images, description, drop, light)
        register_micro(modname, subname, recipeitem, groups, images, description, drop, light)
        register_6dfacedir_conversion(modname, subname)
end

-- Default stairs/slabs/panels/microblocks

register_stair_slab_panel_micro("moreblocks", "wood", "default:wood",
	{snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=3},
	{"default_wood.png"},
	"Wooden",
	"wood",
	0)

register_stair_slab_panel_micro("moreblocks", "stone", "default:stone",
	{cracky=3},
	{"default_stone.png"},
	"Stone",
	"cobble",
	0)

register_stair_slab_panel_micro("moreblocks", "cobble", "default:cobble",
	{cracky=3},
	{"default_cobble.png"},
	"Cobblestone",
	"cobble",
	0)
	
register_stair_slab_panel_micro("moreblocks", "mossycobble", "default:mossycobble",
	{cracky=3},
	{"default_mossycobble.png"},
	"Mossy Cobblestone",
	"mossycobble",
	0)

register_stair_slab_panel_micro("moreblocks", "brick", "default:brick",
	{cracky=3},
	{"default_brick.png"},
	"Brick",
	"brick",
	0)

register_stair_slab_panel_micro("moreblocks", "sandstone", "default:sandstone",
	{crumbly=2,cracky=2},
	{"default_sandstone.png"},
	"Sandstone",
	"sandstone",
	0)
	
register_stair_slab_panel_micro("moreblocks", "steelblock", "default:steelblock",
	{cracky=1,level=2},
	{"default_steel_block.png"},
	"Steel Block",
	"steelblock",
	0)
	
register_stair_slab_panel_micro("moreblocks", "goldblock", "default:goldblock",
	{cracky=1},
	{"default_gold_block.png"},
	"Gold Block",
	"goldblock",
	0)
	
register_stair_slab_panel_micro("moreblocks", "copperblock", "default:copperblock",
	{cracky=1,level=2},
	{"default_copper_block.png"},
	"Copper Block",
	"copperblock",
	0)
	
register_stair_slab_panel_micro("moreblocks", "bronzeblock", "default:bronzeblock",
	{cracky=1,level=2},
	{"default_bronze_block.png"},
	"Bronze Block",
	"bronzeblock",
	0)
	
register_stair_slab_panel_micro("moreblocks", "diamondblock", "default:diamondblock",
	{cracky=1,level=3},
	{"default_diamond_block.png"},
	"Diamond Block",
	"diamondblock",
	0)
	
register_stair_slab_panel_micro("moreblocks", "desert_stone", "default:desert_stone",
	{cracky=3},
	{"default_desert_stone.png"},
	"Desert Stone",
	"desert_stone",
	0)
	
register_stair_slab_panel_micro("moreblocks", "glass", "default:glass",
	{snappy=2,cracky=3,oddly_breakable_by_hand=3},
	{"moreblocks_glass_stairsplus.png"},
	"Glass",
	"glass",
	0)
	
register_stair_slab_panel_micro("moreblocks", "tree", "default:tree",
	{tree=1,snappy=1,choppy=2,oddly_breakable_by_hand=1,flammable=2},
	{"default_tree_top.png", "default_tree_top.png", "default_tree.png"},
	"Tree",
	"tree",
	0)
	
register_stair_slab_panel_micro("moreblocks", "jungletree", "default:jungletree",