diff --git a/tree.lua b/tree.lua index 77850487b68a0c766c4240d595e6795cb0ccbd25..1a33372e0075d0a1f619515fb43749552f24b388 100644 --- a/tree.lua +++ b/tree.lua @@ -1,11 +1,21 @@ +-- NUR DURCH 4 TEILBARE ZAHLEN > 20 VERWENDEN!!! local leds = { - 32, - 28, - 16, - 8, - 4, + 64, + 56, + 48, + 36, + 20, } +for i = 1, #leds do + if leds[i] % 4 ~= 0 then + error("[ledtree] led count per layer must be divisible by 4. Error location: 'leds' table, item "..i..": "..leds[i]) + end + if leds[i] < 20 then + error("[ledtree] led count per layer must be greater than or qual to 20. Error location: 'leds' table, item "..i..": "..leds[i]) + end +end + local height_increment = 3 local function breite(n) @@ -28,13 +38,13 @@ local function place_layer(center, breite) breite = breite * 2 + 1 local needles = {} local leds = {} - local max_offset = math.ceil(breite / 2) - for y = -height_increment / 2, height_increment / 2 do + local max_offset = math.floor(breite / 2) + for y = math.ceil(-height_increment / 2), math.floor(height_increment / 2) do for x = -max_offset, max_offset do for z = -max_offset, max_offset do local pos = vector.new({x = center.x + x, y = center.y + y, z = center.z + z}) table.insert(needles, pos) - if is_led(center, breite, pos) then + if y == 0 and is_led(center, breite, pos) then table.insert(leds, pos) end end