shorten code with loops

This commit is contained in:
webdesigner97 2014-05-27 18:48:04 +02:00
parent d205a81d68
commit b514e6b921

View File

@ -112,22 +112,14 @@ minetest.register_node(":streets:signworkshop",{
local def = minetest.registered_nodes[selection].streets.signworkshop local def = minetest.registered_nodes[selection].streets.signworkshop
local need = inv:get_list("streets:signworkshop_recipe") local need = inv:get_list("streets:signworkshop_recipe")
local has = inv:get_list("streets:signworkshop_input") local has = inv:get_list("streets:signworkshop_input")
need[1] = need[1]:to_table() for k, v in pairs(need) do
need[2] = need[2]:to_table() need[k] = need[k]:to_table()
need[3] = need[3]:to_table() if need[k] == nil then need[k] = { name = "" } end
need[4] = need[4]:to_table() end
has[1] = has[1]:to_table() for k, v in pairs(has) do
has[2] = has[2]:to_table() has[k] = has[k]:to_table()
has[3] = has[3]:to_table() if has[k] == nil then has[k] = { name = "" } end
has[4] = has[4]:to_table() end
if need[1] == nil then need[1] = { name = "" } end
if need[2] == nil then need[2] = { name = "" } end
if need[3] == nil then need[3] = { name = "" } end
if need[4] == nil then need[4] = { name = "" } end
if has[1] == nil then has[1] = { name = "" } end
if has[2] == nil then has[2] = { name = "" } end
if has[3] == nil then has[3] = { name = "" } end
if has[4] == nil then has[4] = { name = "" } end
if need[1].name == has[1].name and need[2].name == has[2].name and need[3].name == has[3].name and need[4].name == has[4].name then if need[1].name == has[1].name and need[2].name == has[2].name and need[3].name == has[3].name and need[4].name == has[4].name then
meta:set_string("infotext",streets.S("Sign workshop working")) meta:set_string("infotext",streets.S("Sign workshop working"))
meta:set_string("idle","n") meta:set_string("idle","n")