2017-05-18 21:32:19 +02:00
2015-09-29 20:19:14 +02:00
--
-- Partial blocks mod
-- By Kaadmy, for Pixture
--
2019-08-28 17:31:41 +02:00
local S = minetest.get_translator ( " partialblocks " )
2015-09-29 20:19:14 +02:00
partialblocks = { }
2019-08-31 17:27:09 +02:00
function partialblocks . register_material ( name , desc_slab , desc_stair , node , groups , is_fuel , tiles_slab , tiles_stair )
2017-05-12 04:29:55 +02:00
local nodedef = minetest.registered_nodes [ node ]
2015-09-29 20:19:14 +02:00
if nodedef == nil then
2017-05-12 04:29:55 +02:00
minetest.log ( " warning " , " Cannot find node for partialblock: " .. node )
2017-05-16 20:12:49 +02:00
2015-09-29 20:19:14 +02:00
return
end
-- Slab
2019-08-29 04:31:49 +02:00
local tiles
if tiles_slab then
tiles = tiles_slab
else
tiles = nodedef.tiles
end
2019-08-31 17:27:09 +02:00
if not groups then
2019-09-04 14:18:57 +02:00
groups = table.copy ( nodedef.groups )
else
groups = { }
2019-08-31 17:27:09 +02:00
end
2019-09-04 14:18:57 +02:00
groups.slab = 1
2017-05-16 20:12:49 +02:00
2017-05-12 04:29:55 +02:00
minetest.register_node (
2017-05-18 21:32:19 +02:00
" partialblocks:slab_ " .. name ,
2015-09-29 20:19:14 +02:00
{
2019-08-29 04:31:49 +02:00
tiles = tiles ,
2019-08-31 17:27:09 +02:00
groups = groups ,
2015-09-29 20:19:14 +02:00
sounds = nodedef.sounds ,
2019-08-28 17:31:41 +02:00
description = desc_slab ,
2015-09-29 20:19:14 +02:00
drawtype = " nodebox " ,
node_box = {
2017-05-18 21:32:19 +02:00
type = " fixed " ,
fixed = { - 0.5 , - 0.5 , - 0.5 , 0.5 , 0 , 0.5 } ,
2015-09-29 20:19:14 +02:00
} ,
paramtype = " light " ,
2019-08-29 14:52:32 +02:00
is_ground_content = nodedef.is_ground_content ,
2017-05-18 21:32:19 +02:00
2019-09-05 22:47:27 +02:00
on_place = function ( itemstack , placer , pointed_thing )
-- Slab on slab placement creates full block
if not ( pointed_thing.above . y > pointed_thing.under . y ) then
itemstack = minetest.item_place ( itemstack , placer , pointed_thing )
return itemstack
end
local pos = pointed_thing.under
local shift = false
if placer : is_player ( ) then
-- Place node normally when sneak is pressed
shift = placer : get_player_control ( ) . sneak
end
if ( not shift ) and minetest.get_node ( pos ) . name == itemstack : get_name ( )
2017-05-18 21:32:19 +02:00
and itemstack : get_count ( ) >= 1 then
minetest.set_node ( pos , { name = node } )
2019-09-02 14:19:50 +02:00
if not minetest.settings : get_bool ( " creative_mode " ) then
itemstack : take_item ( )
end
2017-05-18 21:32:19 +02:00
2019-09-05 22:47:27 +02:00
else
itemstack = minetest.item_place ( itemstack , placer , pointed_thing )
2017-05-18 21:32:19 +02:00
end
2019-09-05 22:47:27 +02:00
return itemstack
2017-05-18 21:32:19 +02:00
end ,
2017-05-16 20:12:49 +02:00
} )
crafting.register_craft ( -- Craft to
2015-09-29 20:19:14 +02:00
{
2017-05-18 21:32:19 +02:00
output = " partialblocks:slab_ " .. name ,
2017-05-16 20:12:49 +02:00
items = {
2017-05-18 21:32:19 +02:00
node ,
2015-09-29 20:19:14 +02:00
} ,
2017-05-16 20:12:49 +02:00
} )
2015-09-29 20:19:14 +02:00
2017-05-18 21:32:19 +02:00
if is_fuel then
2017-05-12 04:29:55 +02:00
minetest.register_craft ( -- Fuel
2015-10-04 02:07:04 +02:00
{
type = " fuel " ,
2017-05-18 21:32:19 +02:00
recipe = " partialblocks:slab_ " .. name ,
2015-10-04 02:07:04 +02:00
burntime = 7 ,
2017-05-16 20:12:49 +02:00
} )
2015-10-04 02:07:04 +02:00
end
2015-09-29 20:19:14 +02:00
-- Stair
2017-05-16 20:12:49 +02:00
2019-08-29 04:31:49 +02:00
local tiles
if tiles_stair then
tiles = tiles_stair
else
tiles = nodedef.tiles
end
2019-09-04 14:18:57 +02:00
groups.slab = nil
groups.stair = 1
2017-05-12 04:29:55 +02:00
minetest.register_node (
2017-05-18 21:32:19 +02:00
" partialblocks:stair_ " .. name ,
2015-09-29 20:19:14 +02:00
{
2019-08-29 04:31:49 +02:00
tiles = tiles ,
2019-08-31 17:27:09 +02:00
groups = groups ,
2015-09-29 20:19:14 +02:00
sounds = nodedef.sounds ,
2019-08-28 17:31:41 +02:00
description = desc_stair ,
2015-09-29 20:19:14 +02:00
drawtype = " nodebox " ,
node_box = {
type = " fixed " ,
fixed = {
{ - 0.5 , - 0.5 , - 0.5 , 0.5 , 0 , 0.5 } ,
{ - 0.5 , 0 , 0 , 0.5 , 0.5 , 0.5 } ,
} ,
} ,
paramtype = " light " ,
paramtype2 = " facedir " ,
2019-08-29 14:52:32 +02:00
is_ground_content = nodedef.is_ground_content ,
2017-05-16 20:12:49 +02:00
} )
crafting.register_craft ( -- Craft to
2015-09-29 20:19:14 +02:00
{
2017-05-18 21:32:19 +02:00
output = " partialblocks:stair_ " .. name ,
2017-05-16 20:12:49 +02:00
items = {
2017-05-18 21:32:19 +02:00
node ,
2015-09-29 20:19:14 +02:00
} ,
2017-05-16 20:12:49 +02:00
} )
2015-10-04 02:07:04 +02:00
2017-05-18 21:32:19 +02:00
if is_fuel then
2017-05-12 04:29:55 +02:00
minetest.register_craft ( -- Fuel
2015-10-04 02:07:04 +02:00
{
type = " fuel " ,
2017-05-18 21:32:19 +02:00
recipe = " partialblocks:stair_ " .. name ,
2015-10-04 02:07:04 +02:00
burntime = 7 ,
2017-05-16 20:12:49 +02:00
} )
2015-10-04 02:07:04 +02:00
end
2015-09-29 20:19:14 +02:00
end
2019-08-29 04:31:49 +02:00
local adv_slab_tex = function ( name , texname )
local t1 = minetest.registered_nodes [ name ] . tiles [ 1 ]
local t2 = " partialblocks_ " .. texname .. " _slab.png "
return { t1 , t1 , t2 }
end
local adv_stair_tex = function ( name , texname )
local t1 = minetest.registered_nodes [ name ] . tiles [ 1 ]
local t2 = " partialblocks_ " .. texname .. " _stair.png "
local t3 = " partialblocks_ " .. texname .. " _slab.png "
return { t3 , t1 , t2 .. " ^[transformFX " , t2 , t1 , t3 }
end
2017-05-16 20:12:49 +02:00
-- Stonelike materials
partialblocks.register_material (
2019-08-31 17:27:09 +02:00
" cobble " , S ( " Cobble Slab " ) , S ( " Cobble Stair " ) , " default:cobble " , { cracky = 3 } , false )
2017-05-16 20:12:49 +02:00
partialblocks.register_material (
2019-08-31 17:27:09 +02:00
" stone " , S ( " Stone Slab " ) , S ( " Stone Stair " ) , " default:stone " , { cracky = 2 } , false )
2017-05-16 20:12:49 +02:00
partialblocks.register_material (
2019-08-31 17:27:09 +02:00
" brick " , S ( " Brick Slab " ) , S ( " Brick Stair " ) , " default:brick " , { cracky = 2 } , false )
2017-05-16 20:12:49 +02:00
-- Woodlike
partialblocks.register_material (
2019-08-31 17:27:09 +02:00
" wood " , S ( " Wooden Slab " ) , S ( " Wooden Stair " ) , " default:planks " , { snappy = 3 , choppy = 3 , oddly_breakable_by_hand = 3 } , true )
2017-05-16 20:12:49 +02:00
partialblocks.register_material (
2019-08-31 17:27:09 +02:00
" oak " , S ( " Oak Slab " ) , S ( " Oak Stair " ) , " default:planks_oak " , { snappy = 3 , choppy = 3 , oddly_breakable_by_hand = 3 } , true )
2017-05-16 20:12:49 +02:00
partialblocks.register_material (
2019-08-31 17:27:09 +02:00
" birch " , S ( " Birch Slab " ) , S ( " Birch Stair " ) , " default:planks_birch " , { snappy = 3 , choppy = 3 , oddly_breakable_by_hand = 3 } , true )
2017-05-16 20:12:49 +02:00
-- Frames
partialblocks.register_material (
2019-08-31 17:27:09 +02:00
" frame " , S ( " Frame Slab " ) , S ( " Frame Stair " ) , " default:frame " , { choppy = 2 , oddly_breakable_by_hand = 1 } , true , adv_slab_tex ( " default:frame " , " frame " ) , adv_stair_tex ( " default:frame " , " frame " ) )
2017-05-16 20:12:49 +02:00
partialblocks.register_material (
2019-08-31 17:27:09 +02:00
" reinforced_frame " , S ( " Reinforced Frame Slab " ) , S ( " Reinforced Frame Stair " ) , " default:reinforced_frame " , { choppy = 1 } , true , adv_slab_tex ( " default:reinforced_frame " , " reinforced_frame " ) , adv_stair_tex ( " default:reinforced_frame " , " reinforced_frame " ) )
2017-05-16 20:12:49 +02:00
partialblocks.register_material (
2019-08-31 17:27:09 +02:00
" reinforced_cobble " , S ( " Reinforced Cobble Slab " ) , S ( " Reinforced Cobble Stair " ) , " default:reinforced_cobble " , { cracky = 1 } , false , adv_slab_tex ( " default:reinforced_cobble " , " reinforced_cobbles " ) , adv_stair_tex ( " default:reinforced_cobble " , " reinforced_cobbles " ) )
2017-05-16 20:12:49 +02:00
-- Misc. blocks
partialblocks.register_material (
2019-08-31 17:30:34 +02:00
" coal " , S ( " Coal Slab " ) , S ( " Coal Stair " ) , " default:block_coal " , { cracky = 3 } , false , adv_slab_tex ( " default:block_coal " , " block_coal " ) , adv_stair_tex ( " default:block_coal " , " block_coal " ) )
2017-05-16 20:12:49 +02:00
partialblocks.register_material (
2019-08-31 17:27:09 +02:00
" steel " , S ( " Steel Slab " ) , S ( " Steel Stair " ) , " default:block_steel " , { cracky = 2 } , false , adv_slab_tex ( " default:block_steel " , " block_steel " ) , adv_stair_tex ( " default:block_steel " , " block_steel " ) )
2019-08-29 04:31:49 +02:00
2019-08-29 04:38:21 +02:00
partialblocks.register_material (
2019-08-31 17:27:09 +02:00
" carbon_steel " , S ( " Carbon Steel Slab " ) , S ( " Carbon Steel Stair " ) , " default:block_carbon_steel " , { cracky = 1 } , false , adv_slab_tex ( " default:block_carbon_steel " , " block_carbon_steel " ) , adv_stair_tex ( " default:block_carbon_steel " , " block_carbon_steel " ) )
2019-08-29 04:38:21 +02:00
partialblocks.register_material (
2019-08-31 17:27:09 +02:00
" wrought_iron " , S ( " Wrought Iron Slab " ) , S ( " Wrought Iron Stair " ) , " default:block_wrought_iron " , { cracky = 2 } , false , adv_slab_tex ( " default:block_wrought_iron " , " block_wrought_iron " ) , adv_stair_tex ( " default:block_wrought_iron " , " block_wrought_iron " ) )
2019-08-29 04:38:21 +02:00
partialblocks.register_material (
2019-08-31 17:27:09 +02:00
" bronze " , S ( " Bronze Slab " ) , S ( " Bronze Stair " ) , " default:block_bronze " , { cracky = 1 } , false , adv_slab_tex ( " default:block_bronze " , " block_bronze " ) , adv_stair_tex ( " default:block_bronze " , " block_bronze " ) )
2019-08-29 04:38:21 +02:00
2019-08-29 04:31:49 +02:00
local cs_stair_tiles = {
" default_compressed_sandstone.png " ,
" default_compressed_sandstone_top.png " ,
" partialblocks_compressed_sandstone_stair.png^[transformFX " ,
" partialblocks_compressed_sandstone_stair.png " ,
" default_compressed_sandstone.png " ,
" default_compressed_sandstone.png " }
2017-05-16 20:12:49 +02:00
partialblocks.register_material (
2019-08-31 17:27:09 +02:00
" compressed_sandstone " , S ( " Compressed Sandstone Slab " ) , S ( " Compressed Sandstone Stair " ) , " default:compressed_sandstone " , { cracky = 2 } , false , nil , cs_stair_tiles )
2016-06-21 13:57:38 +02:00
default.log ( " mod:partialblocks " , " loaded " )