Skip to content
Snippets Groups Projects
Verified Commit 29022013 authored by codecraft's avatar codecraft :crocodile: Committed by Tuxilio
Browse files

rework placment logic

parent 605ad852
No related branches found
No related tags found
No related merge requests found
-- 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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment