mylandscaping/machine.lua

324 lines
8.1 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()
2015-05-05 09:09:48 -07:00
if player:get_player_name() ~= meta:get_string("owner") then
return false
elseif not inv:is_empty("input") then
return false
elseif not inv:is_empty("output") then
return false
end
return true
2015-05-05 09:09:48 -07:00
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", "size[10,10;]"..
2015-04-27 10:31:29 -07:00
"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[5.5,1.5;1,1;mylandscaping:stone_squarecement;patio1; ]"..
"item_image_button[6.5,1.5;1,1;mylandscaping:stone_square_smcement;patio2; ]"..
"item_image_button[7.5,1.5;1,1;mylandscaping:stone_square_xsmcement;patio7; ]"..
"item_image_button[8.5,1.5;1,1;mylandscaping:stone_paverscement;patio3; ]"..
"item_image_button[6,2.5;1,1;mylandscaping:stone_ashlarcement;patio4; ]"..
"item_image_button[7,2.5;1,1;mylandscaping:stone_flagstonecement;patio5; ]"..
"item_image_button[8,2.5;1,1;mylandscaping:stone_pinwheelcement;patio6; ]"..
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()
local color_tab = {
{"black", "Black", "dye:black"},
{"blue", "Blue", "dye:blue"},
{"brown", "Brown", "dye:brown"},
{"cyan", "Cyan", "dye:cyan"},
{"dark_green", "Dark Green", "dye:dark_green"},
{"dark_grey", "Dark Grey", "dye:dark_grey"},
{"green", "Green", "dye:green"},
{"grey", "Grey", "dye:grey"},
{"magenta", "Magenta", "dye:magenta"},
{"orange", "Orange", "dye:orange"},
{"pink", "Pink", "dye:pink"},
{"red", "Red", "dye:red"},
{"violet", "Violet", "dye:violet"},
{"white", "White", "dye:white"},
{"yellow", "Yellow", "dye:yellow"},
{"cement", "", ""},
}
for i in ipairs (color_tab) do
local col = color_tab[i][1]
local coldesc = color_tab[i][2]
local dyecol = color_tab[i][3]
2015-04-27 10:31:29 -07:00
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" and
dyestack:get_name()== dyecol then
material = col
2015-04-28 07:48:19 -07:00
make_ok = "1"
end
if instack:get_name()== "myconcrete:concrete" and
dyestack:get_name()== dyecol then
material = col
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..col)
2015-04-27 10:31:29 -07:00
end
2015-04-28 07:48:19 -07:00
instack:take_item()
inv:set_stack("input",1,instack)
if dyestack:get_name() == "dye:"..col then
2015-04-28 07:48:19 -07:00
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"]
or fields["patio4"]
or fields["patio5"]
or fields["patio6"]
or fields["patio7"]
2015-04-27 10:31:29 -07:00
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["patio7"] then
make_ok2 = "0"
anzahl2 = "2"
stone = "mylandscaping:stone_square_xsm"
if inv:is_empty("input") then
return
end
end
2015-04-27 10:31:29 -07:00
if fields["patio3"] then
make_ok2 = "0"
anzahl2 = "2"
stone = "mylandscaping:stone_pavers"
if inv:is_empty("input") then
return
end
end
if fields["patio4"] then
make_ok2 = "0"
anzahl2 = "2"
stone = "mylandscaping:stone_ashlar"
if inv:is_empty("input") then
return
end
end
if fields["patio5"] then
make_ok2 = "0"
anzahl2 = "2"
stone = "mylandscaping:stone_flagstone"
if inv:is_empty("input") then
return
end
end
if fields["patio6"] then
make_ok2 = "0"
anzahl2 = "2"
stone = "mylandscaping:stone_pinwheel"
if inv:is_empty("input") then
return
end
2015-04-27 10:31:29 -07:00
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)
local dyestack = inv:get_stack("dye", 1)
2015-04-27 10:31:29 -07:00
----------------------------------------------------------------------
if instack:get_name()== "mylandscaping:concrete_bag" and
dyestack:get_name()== dyecol then
make_ok2 = "1"
end
if instack:get_name()== "myconcrete:concrete" and
dyestack:get_name()== dyecol 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..col)
2015-04-27 10:31:29 -07:00
end
dyestack:take_item()
inv:set_stack("dye",1,dyestack)
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
end
2015-04-26 14:38:21 -07:00
})
2015-04-27 10:31:29 -07:00