Complete rewrite

This commit is contained in:
DonBatman 2015-03-15 15:30:20 -07:00
parent 8306472018
commit 4190937365
18 changed files with 378 additions and 3 deletions

4
README.md Normal file
View File

@ -0,0 +1,4 @@
mybricks
========
mybricks adds an overlay to default nodes. Turns them into bricks, squares, small squares or tiles.

61
bricks.lua Normal file
View File

@ -0,0 +1,61 @@
function mybricks.register_all(mat, desc, image, groups, craft)
minetest.register_node("mybricks:brick_"..mat, {
description = desc.." Brick",
drawtype = "normal",
tiles = {
image.."^mybricks_pattern2.png",
image.."^mybricks_pattern2.png",
image.."^mybricks_pattern1.png",
image.."^mybricks_pattern1.png",
image.."^mybricks_pattern3.png",
image.."^mybricks_pattern3.png",
},
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
is_ground_content = true,
groups = {cracky = 2,not_in_creative_inventory=1},
sounds = default.node_sound_stone_defaults(),
})
minetest.register_node("mybricks:brick_square_"..mat, {
description = desc.." Square Brick",
drawtype = "normal",
tiles = {image.."^mybricks_pattern6.png"},
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
is_ground_content = true,
groups = {cracky = 2,not_in_creative_inventory=1},
sounds = default.node_sound_stone_defaults(),
})
minetest.register_node("mybricks:brick_square_sm_"..mat, {
description = desc.." Square Brick Small",
drawtype = "normal",
tiles = {image.."^mybricks_pattern5.png"},
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
is_ground_content = true,
groups = {cracky = 2,not_in_creative_inventory=1},
sounds = default.node_sound_stone_defaults(),
})
minetest.register_node("mybricks:brick_tile_"..mat, {
description = desc.." Tile Brick",
drawtype = "normal",
tiles = {image.."^mybricks_pattern2.png"},
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
is_ground_content = true,
groups = {cracky = 2,not_in_creative_inventory=1},
sounds = default.node_sound_stone_defaults(),
})
end

View File

@ -1 +1 @@
default
default

View File

@ -1,4 +1,12 @@
mybricks = {}
dofile(minetest.get_modpath("mybricks").."/bricks.lua")
dofile(minetest.get_modpath("mybricks").."/machine.lua")
dofile(minetest.get_modpath("mybricks").."/register.lua")
dofile(minetest.get_modpath("mymulch").."/mulch.lua")
print("mymulch mod loaded!")

221
machine.lua Normal file
View File

@ -0,0 +1,221 @@
local material = {}
local shape = {}
local make_ok = {}
local anzahl = {}
minetest.register_node("mybricks:machine", {
description = "Brick Machine",
tiles = {"mybricks_machine.png"},
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
groups = {cracky=2},
node_box = {
type = "fixed",
fixed = {
{-0.5, -0.1875, -0.5, 0.5, 0.0625, 0.5},
{-0.5, -0.1875, -0.5, 0.5, 0.5, -0.3125},
{-0.5, -0.5, -0.5, -0.3125, -0.1875, -0.3125},
{0.3125, -0.5, -0.5, 0.5, -0.1875, -0.3125},
{0.3125, -0.5, 0.3125, 0.5, -0.1875, 0.5},
{-0.5, -0.5, 0.3125, -0.3125, -0.1875, 0.5},
{-0.5, -0.1875, -0.5, -0.3125, 0.5, 0.5},
{-0.5, -0.1875, 0.3125, 0.5, 0.5, 0.5},
{0.3125, -0.1875, -0.5, 0.5, 0.5, 0.5},
}
},
after_place_node = function(pos, placer)
local meta = minetest.env:get_meta(pos);
meta:set_string("owner", (placer:get_player_name() or ""));
meta:set_string("infotext", "Brick Machine is empty (owned by " .. (placer:get_player_name() or "") .. ")");
end,
can_dig = function(pos,player)
local meta = minetest.env:get_meta(pos);
local inv = meta:get_inventory()
if not inv:is_empty("ingot") then
return false
elseif not inv:is_empty("res") then
return false
end
return true
end,
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
meta:set_string("formspec", "invsize[10,11;]"..
"background[-0.15,-0.25;10.40,11.75;mybricks_background.png]"..
"list[current_name;ingot;7,2;1,1;]"..
"list[current_name;res;7,4;1,1;]"..
"label[7,1.5;Input:]"..
"label[7,3.5;Output:]"..
"label[0,0;Choose Brick Stye:]"..
"label[1.5,1.5;Brick]"..
"image_button[1.5,2;1,1;mybricks_mach1.png;brick; ]"..
"label[4,1.5;Squares]"..
"image_button[4,2;1,1;mybricks_mach2.png;square; ]"..
"label[1.5,3.5;Small Squares]"..
"image_button[1.5,4;1,1;mybricks_mach3.png;square_sm; ]"..
"label[4,3.5;Tiles]"..
"image_button[4,4;1,1;mybricks_mach4.png;tile; ]"..
"list[current_player;main;1,7;8,4;]")
meta:set_string("infotext", "Brick Machine")
local inv = meta:get_inventory()
inv:set_size("ingot", 1)
inv:set_size("res", 1)
end,
on_receive_fields = function(pos, formname, fields, sender)
local meta = minetest.env:get_meta(pos)
local inv = meta:get_inventory()
if fields["brick"]
or fields["square"]
or fields["square_sm"]
or fields["tile"]
then
if fields["brick"] then
make_ok = "0"
anzahl = "1"
shape = "mybricks:brick_"
if inv:is_empty("ingot") then
return
end
end
if fields["square"] then
make_ok = "0"
anzahl = "1"
shape = "mybricks:brick_square_"
if inv:is_empty("ingot") then
return
end
end
if fields["square_sm"] then
make_ok = "0"
anzahl = "1"
shape = "mybricks:brick_square_sm_"
if inv:is_empty("ingot") then
return
end
end
if fields["tile"] then
make_ok = "0"
anzahl = "1"
shape = "mybricks:brick_tile_"
if inv:is_empty("ingot") then
return
end
end
local ingotstack = inv:get_stack("ingot", 1)
local resstack = inv:get_stack("res", 1)
----------------------------------------------------------------------------------
--register nodes
----------------------------------------------------------------------------------
if ingotstack:get_name()=="default:sandstone" then
material = "default_sandstone"
make_ok = "1"
end
if ingotstack:get_name()=="default:desert_sand" then
material = "default_desert_sand"
make_ok = "1"
end
if ingotstack:get_name()=="default:clay" then
material = "default_clay"
make_ok = "1"
end
if ingotstack:get_name()=="wool:white" then
material = "millwork_white"
make_ok = "1"
end
if ingotstack:get_name()=="default:desert_stone" then
material = "default_desert_stone"
make_ok = "1"
end
if ingotstack:get_name()=="default:cobble" then
material = "default_cobble"
make_ok = "1"
end
if ingotstack:get_name()=="default:stone" then
material = "default_stone"
make_ok = "1"
end
if ingotstack:get_name()=="default:cactus" then
material = "default_cactus"
make_ok = "1"
end
if ingotstack:get_name()=="wool:white" then
material = "millwork_white"
make_ok = "1"
end
if ingotstack:get_name()=="default:sand" then
material = "default_sand"
make_ok = "1"
end
if ingotstack:get_name()=="default:wood" then
material = "default_wood"
make_ok = "1"
end
if ingotstack:get_name()=="default:pinewood" then
material = "default_pinewood"
make_ok = "1"
end
if ingotstack:get_name()=="default:dirt" then
material = "default_dirt"
make_ok = "1"
end
----------------------------------------------------------------------
if make_ok == "1" then
local give = {}
for i = 0, anzahl-1 do
give[i+1]=inv:add_item("res",shape..material)
end
ingotstack:take_item()
inv:set_stack("ingot",1,ingotstack)
end
end
end
})
--Craft
minetest.register_craft({
output = 'mybricks:machine',
recipe = {
{'default:brick', 'default:brick', 'default:brick'},
{'default:brick', 'default:steel_ingot', 'default:brick'},
{'default:brick', "default:brick", 'default:brick'},
},
})

81
register.lua Normal file
View File

@ -0,0 +1,81 @@
mybricks.register_all(--material, description, image, groups, craft item
"default_sandstone",
"Sandstone",
"default_sandstone.png",
"{cracky = 1, oddly_breakable_by_hand = 1, not_in_creative_inventory=1}",
"default:sandstone"
)
mybricks.register_all(--material, description, image, groups, craft item
"default_desert_sand",
"Desert Sand",
"default_desert_sand.png",
"{cracky = 1, oddly_breakable_by_hand = 1,not_in_creative_inventory=1}",
"default:desert_sand"
)
mybricks.register_all(--material, description, image, groups, craft item
"default_clay",
"Clay",
"default_clay.png",
"{cracky = 1, oddly_breakable_by_hand = 1,not_in_creative_inventory=1}",
"default:clay"
)
mybricks.register_all(--material, description, image, groups, craft item
"default_cobble",
"Cobble",
"default_cobble.png",
"{cracky = 1, oddly_breakable_by_hand = 1,not_in_creative_inventory=1}",
"default:cobble"
)
mybricks.register_all(--material, description, image, groups, craft item
"default_stone",
"Stone",
"default_stone.png",
"{cracky = 1, oddly_breakable_by_hand = 1,not_in_creative_inventory=1}",
"default:stone"
)
mybricks.register_all(--material, description, image, groups, craft item
"default_cactus",
"Cactus",
"default_cactus_side.png",
"{cracky = 1, oddly_breakable_by_hand = 1,not_in_creative_inventory=1}",
"default:cactus"
)
mybricks.register_all(--material, description, image, groups, craft item
"default_sand",
"Sand",
"default_sand.png",
"{cracky = 1, oddly_breakable_by_hand = 1,not_in_creative_inventory=1}",
"default:sand"
)
mybricks.register_all(--material, description, image, groups, craft item
"default_desert_stone",
"Desert Stone",
"default_desert_stone.png",
"{cracky = 1, oddly_breakable_by_hand = 1,not_in_creative_inventory=1}",
"default:desert_stone"
)
mybricks.register_all(--material, description, image, groups, craft item
"default_wood",
"Wood",
"default_wood.png",
"{cracky = 1, oddly_breakable_by_hand = 1,not_in_creative_inventory=1}",
"default:wood"
)
mybricks.register_all(--material, description, image, groups, craft item
"default_pinewood",
"Pine Wood",
"default_pinewood.png",
"{cracky = 1, oddly_breakable_by_hand = 1,not_in_creative_inventory=1}",
"default:pinewood"
)
mybricks.register_all(--material, description, image, groups, craft item
"default_dirt",
"Dirt",
"default_dirt.png",
"{cracky = 1, oddly_breakable_by_hand = 1,not_in_creative_inventory=1}",
"default:dirt"
)

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

BIN
textures/mybricks_mach1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

BIN
textures/mybricks_mach2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

BIN
textures/mybricks_mach3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
textures/mybricks_mach4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 307 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 294 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 216 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 309 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 325 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 388 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 343 B