Cleaned up code

master
DonBatman 2015-05-18 07:17:15 -07:00
parent ae10b6519c
commit ea0a76473f
4 changed files with 101 additions and 213 deletions

View File

@ -1,13 +1,29 @@
local material = {}
local block = {}
local make_ok = {}
local anzahl = {}
local make_ok = false
local anzahl = 0
local material2 = {}
local stone = {}
local make_ok2 = {}
local anzahl2 = {}
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", "", ""},
}
minetest.register_node('mylandscaping:machine', {
description = 'concrete forms',
@ -36,15 +52,14 @@ minetest.register_node('mylandscaping:machine', {
can_dig = function(pos,player)
local meta = minetest.env:get_meta(pos);
local inv = meta:get_inventory()
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
if player:get_player_name() == meta:get_string("owner") and
inv:is_empty("input") and
inv:is_empty("input") and
inv:is_empty("output") then
return true
else
return false
end
return true
end,
@ -104,24 +119,6 @@ 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]
@ -138,56 +135,56 @@ or fields["column4"]
then
if fields["wall1"] then
make_ok = "0"
anzahl = "2"
make_ok = false
anzahl = 2
block = "mylandscaping:rwall_left_"
if inv:is_empty("input") then
return
end
end
if fields["wall2"] then
make_ok = "0"
anzahl = "2"
make_ok = false
anzahl = 2
block = "mylandscaping:rwall_middle_"
if inv:is_empty("input") then
return
end
end
if fields["wall3"] then
make_ok = "0"
anzahl = "2"
make_ok = false
anzahl = 2
block = "mylandscaping:rwall_right_"
if inv:is_empty("input") then
return
end
end
if fields["wall4"] then
make_ok = "0"
anzahl = "2"
make_ok = false
anzahl = 2
block = "mylandscaping:rwall_corner_"
if inv:is_empty("input") then
return
end
end
if fields["column2"] then
make_ok = "0"
anzahl = "1"
make_ok = false
anzahl = 1
block = "mylandscaping:rwall_column_m_t_"
if inv:is_empty("input") then
return
end
end
if fields["column3"] then
make_ok = "0"
anzahl = "1"
make_ok = false
anzahl = 1
block = "mylandscaping:rwall_column_ic_t_"
if inv:is_empty("input") then
return
end
end
if fields["column4"] then
make_ok = "0"
anzahl = "1"
make_ok = false
anzahl = 1
block = "mylandscaping:rwall_column_oc_t_"
if inv:is_empty("input") then
return
@ -201,15 +198,15 @@ then
if instack:get_name()== "mylandscaping:concrete_bag" and
dyestack:get_name()== dyecol then
material = col
make_ok = "1"
make_ok = true
end
if instack:get_name()== "myconcrete:concrete" and
if instack:get_name()== "myconcrete:concrete" and
dyestack:get_name()== dyecol then
material = col
make_ok = "1"
make_ok = true
end
----------------------------------------------------------------------
if make_ok == "1" then
if make_ok == true then
local give = {}
for i = 0, anzahl-1 do
give[i+1]=inv:add_item("output",block..col)
@ -233,56 +230,56 @@ or fields["patio7"]
then
if fields["patio1"] then
make_ok2 = "0"
anzahl2 = "2"
make_ok = false
anzahl = 2
stone = "mylandscaping:stone_square"
if inv:is_empty("input") then
return
end
end
if fields["patio2"] then
make_ok2 = "0"
anzahl2 = "2"
make_ok = false
anzahl = 2
stone = "mylandscaping:stone_square_sm"
if inv:is_empty("input") then
return
end
end
if fields["patio7"] then
make_ok2 = "0"
anzahl2 = "2"
make_ok = false
anzahl = 2
stone = "mylandscaping:stone_square_xsm"
if inv:is_empty("input") then
return
end
end
if fields["patio3"] then
make_ok2 = "0"
anzahl2 = "2"
make_ok = false
anzahl = 2
stone = "mylandscaping:stone_pavers"
if inv:is_empty("input") then
return
end
end
if fields["patio4"] then
make_ok2 = "0"
anzahl2 = "2"
make_ok = false
anzahl = 2
stone = "mylandscaping:stone_ashlar"
if inv:is_empty("input") then
return
end
end
if fields["patio5"] then
make_ok2 = "0"
anzahl2 = "2"
make_ok = false
anzahl = 2
stone = "mylandscaping:stone_flagstone"
if inv:is_empty("input") then
return
end
end
if fields["patio6"] then
make_ok2 = "0"
anzahl2 = "2"
make_ok = false
anzahl = 2
stone = "mylandscaping:stone_pinwheel"
if inv:is_empty("input") then
return
@ -292,22 +289,20 @@ then
local outstack = inv:get_stack("output", 1)
local dyestack = inv:get_stack("dye", 1)
----------------------------------------------------------------------
if instack:get_name()== "mylandscaping:concrete_bag" and
dyestack:get_name()== dyecol then
make_ok2 = "1"
make_ok = true
end
if instack:get_name()== "myconcrete:concrete" and
dyestack:get_name()== dyecol then
make_ok2 = "1"
make_ok = true
end
----------------------------------------------------------------------
if make_ok2 == "1" then
if make_ok == true then
local give = {}
for i = 0, anzahl2-1 do
for i = 0, anzahl-1 do
give[i+1]=inv:add_item("output",stone..col)
end
dyestack:take_item()

107
mixer.lua
View File

@ -1,15 +1,6 @@
minetest.register_alias("myconcrete:concrete", "mylandscaping:concrete")
local make_gravel = {}
local output_gravel = {}
local make_concrete = {}
local output_concrete = {}
local make_cement = {}
local output_cement = {}
local amount = {}
local amount2 = {}
local amount3 = {}
minetest.register_node('mylandscaping:mixer', {
description = 'concrete mixer',
@ -36,18 +27,15 @@ minetest.register_node('mylandscaping:mixer', {
can_dig = function(pos,player)
local meta = minetest.env:get_meta(pos);
local inv = meta:get_inventory()
if player:get_player_name() ~= meta:get_string("owner") then
return false
elseif not inv:is_empty("cobble") then
return false
elseif not inv:is_empty("gravel") then
return false
elseif not inv:is_empty("concrete") then
return false
elseif not inv:is_empty("sand") then
return false
if player:get_player_name() == meta:get_string("owner") and
inv:is_empty("cobble") and
inv:is_empty("gravel") and
inv:is_empty("concrete") and
inv:is_empty("sand") then
return true
else
return false
end
return true
end,
after_place_node = function(pos, placer, itemstack)
@ -88,82 +76,7 @@ on_construct = function(pos)
inv:set_size("concrete", 1)
inv:set_size("sand", 1)
end,
--[[
on_receive_fields = function(pos, formname, fields, sender)
local meta = minetest.env:get_meta(pos)
local inv = meta:get_inventory()
if fields["crush"]
then
if fields["crush"] then
grave = "0"
amount = "1"
if inv:is_empty("cobble") then
return
end
end
local cobblestack = inv:get_stack("cobble", 1)
local gravelstack = inv:get_stack("gravel", 1)
----------------------------------------------------------------------
if cobblestack:get_name()== "default:cobble" then
output_gravel = "default:gravel"
make_gravel = "1"
end
----------------------------------------------------------------------
if make_gravel == "1" then
local give = {}
for i = 0, amount-1 do
give[i+1]=inv:add_item("gravel",output_gravel)
end
cobblestack:take_item()
inv:set_stack("cobble",1,cobblestack)
end
end
--------------------------------------------------------------------------------------
if fields["mix"]
then
if fields["mix"] then
make_concrete = "0"
amount2 = "2"
if inv:is_empty("gravel") or
inv:is_empty("sand") then
return
end
end
local gravelstack = inv:get_stack("gravel", 1)
local sandstack = inv:get_stack("sand", 1)
local concretestack = inv:get_stack("concrete", 1)
----------------------------------------------------------------------
if gravelstack:get_name()== "default:gravel" and
sandstack:get_name()== "default:sand" then
make_concrete = "1"
output_concrete = "mylandscaping:concrete_bag"
end
if gravelstack:get_name()== "default:gravel" and
sandstack:get_name()== "default:desert_sand" then
make_concrete = "1"
output_concrete = "mylandscaping:concrete_bag"
end
----------------------------------------------------------------------
if make_concrete == "1" then
local give = {}
for i = 0, amount2-1 do
give[i+1]=inv:add_item("concrete",output_concrete)
end
gravelstack:take_item()
inv:set_stack("gravel",1,gravelstack)
sandstack:take_item()
inv:set_stack("cement",1,sandstack)
end
end
end
--]]
on_timer = function(pos)
local timer = minetest.get_node_timer(pos)
local meta = minetest.get_meta(pos)
@ -171,7 +84,6 @@ on_timer = function(pos)
local cobble = inv:get_stack("cobble", 1)
local gravel = inv:get_stack("gravel", 1)
local sand = inv:get_stack("sand", 1)
local concrete = inv:get_stack("concrete", 1)
----------------------------------------------------------------------
if cobble:get_name() == "default:cobble" then
inv:add_item("gravel","default:gravel")
@ -179,7 +91,8 @@ on_timer = function(pos)
inv:set_stack("cobble",1,cobble)
end
if gravel:get_name() == "default:gravel" and
sand:get_name() == "default:sand" then
sand:get_name() == "default:sand" or
sand:get_name() == "default:desert_sand" then
inv:add_item("concrete","mylandscaping:concrete_bag")
gravel:take_item()
inv:set_stack("gravel",1,gravel)

View File

@ -264,7 +264,7 @@ minetest.register_node("mylandscaping:stone_"..style..col,{
"mylandscaping_"..img1..".png"..alpha,
},
paramtype = "light",
groups = {cracky = 2},
groups = {cracky = 2, not_in_creative_inventory=1},
node_box = cbox,
selection_box = stone_cbox,
collision_box = stone_cbox,

View File

@ -1,58 +1,44 @@
visible = 1 -- set this to 0 to take blocks out of creative inventory.
local colbox_type1 = { --top blocks
type = "fixed",
fixed = {
{-.49, -.5, 0.05, .5, .6, .52}
}
fixed = {{-.49, -.5, 0.05, .5, .6, .52}}
}
local colbox_type2 = { --columns
type = "fixed",
fixed = {
{-.2, -.5, -.2, .5, .5, .5}
}
fixed = {{-.2, -.5, -.2, .5, .5, .5}}
}
local colbox_type3 = { --bottom blocks
type = "fixed",
fixed = {
{-.5, -.5, -.16, .5, .5, .25}
}
fixed = {{-.5, -.5, -.16, .5, .5, .25}}
}
local colbox_type4 = { --corner
type = "fixed",
fixed = {
{-.5, -.5, 0, .5, .5, .5},
{0, -.5, -.5, .5, .5, .5}
}
fixed = {{-.5, -.5, 0, .5, .5, .5},
{0, -.5, -.5, .5, .5, .5}}
}
local colbox_type5 = { --corner
type = "fixed",
fixed = {
{-.5, -.5, -.5, .5, .5, .5},
}
fixed = {{-.5, -.5, -.5, .5, .5, .5},}
}
local colbox_type6 = { --corner
type = "fixed",
fixed = {
{-.5, -.5, -.3, .5, .5, .5},
}
fixed = {{-.5, -.5, -.3, .5, .5, .5},}
}
local block_type1 = { -- desc2, typ, obj, colbox, drops, grup
{"Retaining Wall Left", "left", "block1_l_t", colbox_type1, "left", {cracky=2,not_in_creative_inventory=0}},
{"Retaining Wall Middle", "middle", "block1_m_t", colbox_type1, "middle", {cracky=2,not_in_creative_inventory=0}},
{"Retaining Wall Right", "right", "block1_r_t", colbox_type1, "right", {cracky=2,not_in_creative_inventory=0}},
{"Retaining Wall Corner", "corner", "block1_c_t", colbox_type4, "corner", {cracky=2,not_in_creative_inventory=0}},
{"Retaining Wall Left Bot", "bleft", "block1_l_b", colbox_type3, "left", {not_in_creative_inventory=visible}},
{"Retaining Wall Middle Bot", "bmiddle", "block1_m_b", colbox_type3, "middle", {not_in_creative_inventory=visible}},
{"Retaining Wall Right Bot", "bright", "block1_r_b", colbox_type3, "right", {not_in_creative_inventory=visible}},
{"Retaining Wall Corner Bot", "bcorner", "block1_c_b", colbox_type4, "corner", {not_in_creative_inventory=visible}},
{"Column Inside Corner", "column_ic_t", "column_ic_t", colbox_type5, "column_ic_t", {cracky=2,not_in_creative_inventory=0}},
{"Column Outside Corner", "column_oc_t", "column_oc_t", colbox_type2, "column_oc_t", {cracky=2,not_in_creative_inventory=0}},
{"Column Middle", "column_m_t", "column_m_t", colbox_type6, "column_m_t", {cracky=2,not_in_creative_inventory=0}},
{"Column Inside Corner Bot", "bcolumn_ic_t", "column_ic_b", colbox_type5, "column_ic_b", {not_in_creative_inventory=visible}},
{"Column Outside Corner Bot","bcolumn_oc_t", "column_oc_b", colbox_type2, "column_oc_b", {not_in_creative_inventory=visible}},
{"Column Middle Bot", "bcolumn_m_t", "column_m_b", colbox_type6, "column_m_b", {not_in_creative_inventory=visible}},
{"Retaining Wall Left", "left", "block1_l_t", colbox_type1, "left", {cracky=2,not_in_creative_inventory=1}},
{"Retaining Wall Middle", "middle", "block1_m_t", colbox_type1, "middle", {cracky=2,not_in_creative_inventory=1}},
{"Retaining Wall Right", "right", "block1_r_t", colbox_type1, "right", {cracky=2,not_in_creative_inventory=1}},
{"Retaining Wall Corner", "corner", "block1_c_t", colbox_type4, "corner", {cracky=2,not_in_creative_inventory=1}},
{"Retaining Wall Left Bot", "bleft", "block1_l_b", colbox_type3, "left", {not_in_creative_inventory=1}},
{"Retaining Wall Middle Bot", "bmiddle", "block1_m_b", colbox_type3, "middle", {not_in_creative_inventory=1}},
{"Retaining Wall Right Bot", "bright", "block1_r_b", colbox_type3, "right", {not_in_creative_inventory=1}},
{"Retaining Wall Corner Bot", "bcorner", "block1_c_b", colbox_type4, "corner", {not_in_creative_inventory=1}},
{"Column Inside Corner", "column_ic_t", "column_ic_t", colbox_type5, "column_ic_t", {cracky=2,not_in_creative_inventory=1}},
{"Column Outside Corner", "column_oc_t", "column_oc_t", colbox_type2, "column_oc_t", {cracky=2,not_in_creative_inventory=1}},
{"Column Middle", "column_m_t", "column_m_t", colbox_type6, "column_m_t", {cracky=2,not_in_creative_inventory=1}},
{"Column Inside Corner Bot", "bcolumn_ic_t", "column_ic_b", colbox_type5, "column_ic_b", {not_in_creative_inventory=1}},
{"Column Outside Corner Bot", "bcolumn_oc_t", "column_oc_b", colbox_type2, "column_oc_b", {not_in_creative_inventory=1}},
{"Column Middle Bot", "bcolumn_m_t", "column_m_b", colbox_type6, "column_m_b", {not_in_creative_inventory=1}},
}
for i in ipairs (block_type1) do
local desc2 = block_type1[i][1]
@ -64,10 +50,10 @@ for i in ipairs (block_type1) do
local block_mat = { -- desc1, mat, img, img2, img3
{"Cement", "cement", "mylandscaping_block_top.png","","mylandscaping_block_face.png"},
{"Tan Cement", "cement_tan", "mylandscaping_block_top.png","^[colorize:#b8882a:75", "mylandscaping_block_face.png"},
{"Autumn Cement", "cement_autumn", "mylandscaping_block_top.png","^[colorize:#ffaf00:75", "mylandscaping_block_face.png"},
{"Red Cement", "cement_red", "mylandscaping_block_top.png","^[colorize:#cf0f00:75","mylandscaping_block_face.png"},
{"Cement", "cement", "mylandscaping_block_top.png","","mylandscaping_block_face.png"},
{"Tan Cement", "cement_tan", "mylandscaping_block_top.png","^[colorize:#b8882a:75", "mylandscaping_block_face.png"},
{"Autumn Cement", "cement_autumn", "mylandscaping_block_top.png","^[colorize:#ffaf00:75", "mylandscaping_block_face.png"},
{"Red Cement", "cement_red", "mylandscaping_block_top.png","^[colorize:#cf0f00:75","mylandscaping_block_face.png"},
}
for i in ipairs (block_mat) do
local desc1 = block_mat[i][1]
@ -75,6 +61,7 @@ for i in ipairs (block_mat) do
local img = block_mat[i][3]
local img2 = block_mat[i][4]
local img3 = block_mat[i][5]
local color_tab = {
{"black", "Black", "^[colorize:black:150"},
{"blue", "Blue", "^[colorize:#0404B4:100"},
@ -98,12 +85,8 @@ local col = color_tab[i][1]
local coldesc = color_tab[i][2]
local alpha = color_tab[i][3]
minetest.register_node('mylandscaping:rwall_'..typ.."_"..col, {
description = desc2,
description = desc2.." "..coldesc,
drawtype = 'mesh',
mesh = 'mylandscaping_'..obj..'.obj',
tiles = {{name=img..alpha}, {name=img3..alpha}},
@ -115,7 +98,6 @@ minetest.register_node('mylandscaping:rwall_'..typ.."_"..col, {
collision_box = colbox,
sounds = default.node_sound_stone_defaults(),
after_place_node = function(pos, placer, itemstack, pointed_thing)
local nodeu = minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z})
local nodea = minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z})
@ -132,7 +114,6 @@ end,
after_destruct = function(pos, oldnode)
local node = minetest.get_node(pos).name
local nodeu = minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z})
local nodeu2 = minetest.get_node({x=pos.x,y=pos.y-2,z=pos.z})
local nodea = minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z})
if nodeu.name == "mylandscaping:rwall_b"..typ.."_"..col and
@ -140,7 +121,6 @@ after_destruct = function(pos, oldnode)
minetest.set_node({x=pos.x,y=pos.y-1,z=pos.z},{name="mylandscaping:rwall_"..typ.."_"..col,param2=nodeu.param2})
end
end,
})