Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
Luanti LED Tree
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tuxilio
Luanti LED Tree
Compare revisions
d3296e938f7c4071768ec79e060e5a4b72d17a55 to main
Compare revisions
Changes are shown as if the
source
revision was being merged into the
target
revision.
Learn more about comparing revisions.
Source
tuxilio/ledtree
Select target project
No results found
main
Select Git revision
Branches
magic-fixes
main
Swap
Target
codecraft/ledtree
Select target project
tuxilio/ledtree
codecraft/ledtree
2 results
d3296e938f7c4071768ec79e060e5a4b72d17a55
Select Git revision
Branches
magic-fixes
main
Show changes
Only incoming changes from source
Include changes to target since source was created
Compare
Commits on Source (3)
Add first version with LEDs placing automatically
· 0bcd2826
Tuxilio
authored
3 months ago
0bcd2826
wip: rework placement logic
· 605ad852
Tuxilio
authored
3 months ago
605ad852
rework placment logic
· 29022013
codecraft
authored
3 months ago
and
Tuxilio
committed
3 months ago
29022013
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tree.lua
+65
-11
65 additions, 11 deletions
tree.lua
with
65 additions
and
11 deletions
tree.lua
View file @
29022013
local
size
=
50
-- NUR DURCH 4 TEILBARE ZAHLEN > 20 VERWENDEN!!!
local
leds
=
{
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
height_increment
=
3
local
function
place_tree
(
pos
)
local
function
breite
(
n
)
local
set
=
{}
return
n
/
4
local
iled
=
0
end
for
iy
=
0
,
size
-
1
do
for
ix
=
iy
,
size
-
1
-
iy
do
for
iz
=
iy
,
size
-
1
-
iy
do
for
h
=
0
,
height_increment
-
1
do
table.insert
(
set
,
{
x
=
pos
.
x
+
ix
,
y
=
pos
.
y
+
iy
*
height_increment
+
h
,
z
=
pos
.
z
+
iz
})
iled
=
iled
+
1
local
function
is_led
(
center
,
breite
,
pos
)
if
math.abs
(
center
.
x
-
pos
.
x
)
>=
(
breite
-
1
)
/
2
and
math.abs
(
center
.
z
-
pos
.
z
)
>=
(
breite
-
1
)
/
2
then
return
false
end
if
math.abs
(
center
.
x
-
pos
.
x
)
==
(
breite
-
1
)
/
2
then
return
math.abs
(
center
.
z
-
pos
.
z
)
%
2
==
0
end
if
math.abs
(
center
.
z
-
pos
.
z
)
==
(
breite
-
1
)
/
2
then
return
math.abs
(
center
.
x
-
pos
.
x
)
%
2
==
0
end
end
local
function
place_layer
(
center
,
breite
)
breite
=
breite
*
2
+
1
local
needles
=
{}
local
leds
=
{}
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
y
==
0
and
is_led
(
center
,
breite
,
pos
)
then
table.insert
(
leds
,
pos
)
end
end
end
end
end
end
end
end
minetest
.
bulk_set_node
(
set
,
{
name
=
"ledtree:pine_needles"
})
core
.
bulk_set_node
(
needles
,
{
name
=
"ledtree:pine_needles"
})
return
leds
end
local
function
place_leds
(
led_index
,
leds
)
for
i
=
1
,
#
leds
do
core
.
set_node
(
leds
[
i
],
{
name
=
"ledtree:led"
..
led_index
..
"_red"
})
led_index
=
led_index
+
1
end
return
led_index
end
local
function
place_tree
(
pos
)
local
led_index
=
0
for
index
=
1
,
#
leds
do
local
l
=
leds
[
index
]
local
layer_center
=
vector
.
new
(
pos
.
x
,
pos
.
y
+
index
*
height_increment
-
height_increment
/
2
,
pos
.
z
)
local
leds
=
place_layer
(
layer_center
,
breite
(
l
))
led_index
=
place_leds
(
led_index
,
leds
)
end
end
end
core
.
register_node
(
"ledtree:ledtree"
,
{
core
.
register_node
(
"ledtree:ledtree"
,
{
...
...
This diff is collapsed.
Click to expand it.