optimization

This commit is contained in:
kilbith 2015-06-14 19:55:59 +02:00
parent 4a62a8252c
commit 5fb8d0292a

View File

@ -19,12 +19,13 @@ local def = { -- node name, yield, nodebox shape
local function xconstruct(pos) local function xconstruct(pos)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local nodebtn = "" local nodebtn = {}
for i=1, #def do for i=1, #def do
nodebtn = nodebtn.. nodebtn[#nodebtn+1] = "item_image_button["..(i-1)..",0.5;1,1;xdecor:"..def[i][1].."_cloud;"..def[i][1]..";]"
"item_image_button["..(i-1)..",0.5;1,1;xdecor:"..def[i][1].."_cloud;"..def[i][1]..";]"
end end
nodebtn = table.concat(nodebtn)
meta:set_string("formspec", "size[8,7;]"..fancy_gui.. meta:set_string("formspec", "size[8,7;]"..fancy_gui..
"label[0,0;Cut your material into...]".. "label[0,0;Cut your material into...]"..
nodebtn.. nodebtn..
@ -56,12 +57,14 @@ local function xfields(pos, formname, fields, sender)
local give = {} local give = {}
local anz = 0 local anz = 0
for _, m in ipairs(material) do for m=1, #material do
for _, n in ipairs(def) do for n=1, #def do
if (inputstack:get_name() == "default:"..m) and (outputstack:get_count() < 99) then local v = material[m]
if fields[n[1]] then local w = def[n]
anz = n[2] if (inputstack:get_name() == "default:"..v) and (outputstack:get_count() < 99) then
shape = "xdecor:"..n[1].."_"..m if fields[w[1]] then
anz = w[2]
shape = "xdecor:"..w[1].."_"..v
for i=0, anz-1 do for i=0, anz-1 do
give[i+1] = inv:add_item("output", shape) give[i+1] = inv:add_item("output", shape)
end end
@ -116,16 +119,18 @@ local function tnaming(material)
else return "default_"..material..".png" end else return "default_"..material..".png" end
end end
for _, m in ipairs(material) do for m=1, #material do
local light = lightlvl(m) local v = material[m]
local sound = stype(m) local light = lightlvl(v)
local tile = tnaming(m) local sound = stype(v)
local tile = tnaming(v)
for _, n in ipairs(def) do for n=1, #def do
xdecor.register(n[1].."_"..m, { local w = def[n]
description = n[1], light_source = light, sounds = sound, xdecor.register(w[1].."_"..v, {
description = w[1], light_source = light, sounds = sound,
tiles = {tile}, groups = {snappy=3, not_in_creative_inventory=1}, tiles = {tile}, groups = {snappy=3, not_in_creative_inventory=1},
on_place = minetest.rotate_node, node_box = {type = "fixed", fixed = n[3]} }) on_place = minetest.rotate_node, node_box = {type = "fixed", fixed = w[3]} })
end end
end end