mylandscaping/machine.lua

252 lines
6.4 KiB
Lua
Raw Normal View History

2015-04-27 10:31:29 -07:00
local material = {}
local block = {}
local make_ok = {}
local anzahl = {}
local material2 = {}
local stone = {}
local make_ok2 = {}
local anzahl2 = {}
2015-04-26 14:38:21 -07:00
minetest.register_node('mylandscaping:machine', {
description = 'concrete forms',
2015-04-26 14:38:21 -07:00
drawtype = 'mesh',
mesh = 'mylandscaping_cement_mixer.obj',
2015-04-26 14:38:21 -07:00
tiles = {
{name='mylandscaping_tex3.png'},{name='mylandscaping_tex1.png'},{name='default_gravel.png'},{name='mylandscaping_tex2.png'}},
groups = {oddly_breakable_by_hand=2},
paramtype = 'light',
paramtype2 = 'facedir',
selection_box = {
type = 'fixed',
fixed = {
2015-05-03 18:09:16 -07:00
{-0.5, -0.5, -0.5, 1.1, 0.5, 0.5},
2015-04-26 14:38:21 -07:00
{1.1, -0.5, -0.1, 1.5, -0.3, 0.5}
}
},
collision_box = {
type = 'fixed',
fixed = {
{-0.5, -0.5, -0.5, 1.1, 0.5, 0.5},
{1.1, -0.5, -0.1, 1.5, -0.3, 0.5}
}
},
can_dig = function(pos,player)
local meta = minetest.env:get_meta(pos);
local inv = meta:get_inventory()
if not inv:is_empty("input") then
return false
elseif not inv:is_empty("output") then
return false
end
return true
end,
after_place_node = function(pos, placer, itemstack)
local meta = minetest.env:get_meta(pos)
meta:set_string("owner",placer:get_player_name())
meta:set_string("infotext","Concrete Mixer (owned by "..placer:get_player_name()..")")
end,
2015-04-27 10:31:29 -07:00
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
meta:set_string("formspec", "invsize[10,10;]"..
"background[-0.15,-0.25;10.40,10.75;mylandscaping_background.png]"..
"label[1.5,0.5;Retaining Wall]"..
--Styles of blocks
2015-05-01 06:15:34 -07:00
"label[1,1;Wall Blocks]"..
"item_image_button[1,1.5;1,1;mylandscaping:rwall_left_cement;wall1; ]"..
"item_image_button[2,1.5;1,1;mylandscaping:rwall_middle_cement;wall2; ]"..
"item_image_button[3,1.5;1,1;mylandscaping:rwall_right_cement;wall3; ]"..
"item_image_button[4,1.5;1,1;mylandscaping:rwall_corner_cement;wall4; ]"..
2015-05-01 06:15:34 -07:00
--Styles of columns
"label[1,2.5;Columns]"..
"item_image_button[1,3;1,1;mylandscaping:rwall_column_m_t_cement;column2; ]"..
"item_image_button[2,3;1,1;mylandscaping:rwall_column_ic_t_cement;column3; ]"..
"item_image_button[3,3;1,1;mylandscaping:rwall_column_oc_t_cement;column4; ]"..
2015-04-27 10:31:29 -07:00
"label[6.5,0.5;Patio Stones]"..
--Styles of blocks
"item_image_button[6,1.5;1,1;mylandscaping:stone_square;patio1; ]"..
"item_image_button[7,1.5;1,1;mylandscaping:stone_square_sm;patio2; ]"..
"item_image_button[8,1.5;1,1;mylandscaping:stone_pavers;patio3; ]"..
2015-04-27 10:31:29 -07:00
--Input
"label[3,4; Input]"..
"list[current_name;input;3,4.5;1,1;]"..
2015-04-28 07:48:19 -07:00
"label[4,4; Dye]"..
"list[current_name;dye;4,4.5;1,1;]"..
2015-04-27 10:31:29 -07:00
--Output
"label[6,4;Output]"..
"list[current_name;output;6,4.5;1,1;]"..
--Players Inven
"list[current_player;main;1,6;8,4;]")
meta:set_string("infotext", "Concrete Mixer")
local inv = meta:get_inventory()
inv:set_size("input", 1)
inv:set_size("output", 1)
2015-04-28 07:48:19 -07:00
inv:set_size("dye", 1)
2015-04-27 10:31:29 -07:00
end,
on_receive_fields = function(pos, formname, fields, sender)
local meta = minetest.env:get_meta(pos)
local inv = meta:get_inventory()
if fields["wall1"]
or fields["wall2"]
or fields["wall3"]
or fields["wall4"]
or fields["column"]
2015-04-28 13:02:17 -07:00
or fields["column2"]
2015-05-01 06:15:34 -07:00
or fields["column3"]
2015-05-03 18:09:16 -07:00
or fields["column4"]
2015-04-27 10:31:29 -07:00
then
if fields["wall1"] then
make_ok = "0"
anzahl = "2"
block = "mylandscaping:rwall_left_"
2015-04-27 10:31:29 -07:00
if inv:is_empty("input") then
return
end
end
if fields["wall2"] then
make_ok = "0"
anzahl = "2"
block = "mylandscaping:rwall_middle_"
2015-04-27 10:31:29 -07:00
if inv:is_empty("input") then
return
end
end
if fields["wall3"] then
make_ok = "0"
anzahl = "2"
block = "mylandscaping:rwall_right_"
2015-04-27 10:31:29 -07:00
if inv:is_empty("input") then
return
end
end
if fields["wall4"] then
make_ok = "0"
anzahl = "2"
block = "mylandscaping:rwall_corner_"
2015-04-27 10:31:29 -07:00
if inv:is_empty("input") then
return
end
end
2015-05-03 18:09:16 -07:00
if fields["column2"] then
2015-04-27 10:31:29 -07:00
make_ok = "0"
2015-05-01 06:15:34 -07:00
anzahl = "1"
block = "mylandscaping:rwall_column_m_t_"
2015-04-27 10:31:29 -07:00
if inv:is_empty("input") then
return
end
end
2015-05-03 18:09:16 -07:00
if fields["column3"] then
2015-04-28 13:02:17 -07:00
make_ok = "0"
2015-05-01 06:15:34 -07:00
anzahl = "1"
block = "mylandscaping:rwall_column_ic_t_"
2015-04-28 13:02:17 -07:00
if inv:is_empty("input") then
return
end
end
2015-05-03 18:09:16 -07:00
if fields["column4"] then
2015-05-01 06:15:34 -07:00
make_ok = "0"
anzahl = "1"
block = "mylandscaping:rwall_column_oc_t_"
2015-05-01 06:15:34 -07:00
if inv:is_empty("input") then
return
end
end
2015-04-28 07:48:19 -07:00
local instack = inv:get_stack("input", 1)
2015-04-27 10:31:29 -07:00
local outstack = inv:get_stack("output", 1)
2015-04-28 07:48:19 -07:00
local dyestack = inv:get_stack("dye", 1)
2015-04-27 10:31:29 -07:00
----------------------------------------------------------------------
if instack:get_name()== "mylandscaping:concrete_bag" then
2015-04-27 10:31:29 -07:00
material = "cement"
make_ok = "1"
end
if instack:get_name()== "mylandscaping:concrete_bag" and
2015-04-28 07:48:19 -07:00
dyestack:get_name()== "dye:yellow" then
material = "cement_tan"
make_ok = "1"
end
if instack:get_name()== "mylandscaping:concrete_bag" and
2015-04-28 07:48:19 -07:00
dyestack:get_name()== "dye:orange" then
material = "cement_autumn"
make_ok = "1"
end
if instack:get_name()== "mylandscaping:concrete_bag" and
2015-04-28 07:48:19 -07:00
dyestack:get_name()== "dye:red" then
material = "cement_red"
2015-04-27 10:31:29 -07:00
make_ok = "1"
end
----------------------------------------------------------------------
if make_ok == "1" then
local give = {}
for i = 0, anzahl-1 do
give[i+1]=inv:add_item("output",block..material)
end
2015-04-28 07:48:19 -07:00
instack:take_item()
inv:set_stack("input",1,instack)
if dyestack:get_name() == "dye:yellow" or
dyestack:get_name() == "dye:orange" or
dyestack:get_name() == "dye:red" then
dyestack:take_item()
inv:set_stack("dye",1,dyestack)
end
2015-04-27 10:31:29 -07:00
end
end
--------------------------------------------------------------------------------------
if fields["patio1"]
or fields["patio2"]
or fields["patio3"]
then
if fields["patio1"] then
make_ok2 = "0"
anzahl2 = "2"
stone = "mylandscaping:stone_square"
if inv:is_empty("input") then
return
end
end
if fields["patio2"] then
make_ok2 = "0"
anzahl2 = "2"
stone = "mylandscaping:stone_square_sm"
if inv:is_empty("input") then
return
end
end
if fields["patio3"] then
make_ok2 = "0"
anzahl2 = "2"
stone = "mylandscaping:stone_pavers"
if inv:is_empty("input") then
return
end
end
2015-04-28 07:48:19 -07:00
local instack = inv:get_stack("input", 1)
2015-04-27 10:31:29 -07:00
local outstack = inv:get_stack("output", 1)
----------------------------------------------------------------------
if instack:get_name()== "mylandscaping:concrete_bag" then
2015-04-27 10:31:29 -07:00
make_ok2 = "1"
end
----------------------------------------------------------------------
if make_ok2 == "1" then
local give = {}
for i = 0, anzahl2-1 do
give[i+1]=inv:add_item("output",stone)
end
2015-04-28 07:48:19 -07:00
instack:take_item()
inv:set_stack("input",1,instack)
2015-04-27 10:31:29 -07:00
end
end
end
2015-04-26 14:38:21 -07:00
})
2015-04-27 10:31:29 -07:00