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
Commits
605ad852
Project 'AlekSIS/onboarding/AlekSIS-App-Kolego' was moved to 'AlekSIS/official/AlekSIS-App-Kolego'. Please update any links and bookmarks that may still have the old path.
Verified
Commit
605ad852
authored
3 months ago
by
Tuxilio
Browse files
Options
Downloads
Patches
Plain Diff
wip: rework placement logic
parent
0bcd2826
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tree.lua
+50
-55
50 additions, 55 deletions
tree.lua
with
50 additions
and
55 deletions
tree.lua
+
50
−
55
View file @
605ad852
local
leds
=
{
3
0
,
2
0
,
1
0
,
5
,
2
,
3
2
,
2
8
,
1
6
,
8
,
4
,
}
local
height_increment
=
3
local
size
=
(
#
leds
+
1
)
*
2
local
function
place_tree
(
pos
)
local
set
=
{}
local
iled
=
0
local
blocks_per_layer
=
{}
for
iy
=
0
,
size
-
1
do
blocks_per_layer
[
iy
]
=
0
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
blocks_per_layer
[
iy
]
=
blocks_per_layer
[
iy
]
+
1
local
function
breite
(
n
)
return
n
/
4
end
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.ceil
(
breite
/
2
)
for
y
=
-
height_increment
/
2
,
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
table.insert
(
leds
,
pos
)
end
end
end
blocks_per_layer
[
iy
]
=
blocks_per_layer
[
iy
]
/
height_increment
blocks_per_layer
[
iy
]
=
math.sqrt
(
blocks_per_layer
[
iy
])
*
4
-
4
end
minetest
.
bulk_set_node
(
set
,
{
name
=
"ledtree:pine_needles"
})
local
loop_run
=
0
local
id
=
0
for
iy
=
0
,
size
-
1
do
loop_run
=
loop_run
+
1
if
loop_run
<=
#
leds
then
local
led_count
=
leds
[
iy
+
1
]
local
led_per_side
=
math.ceil
(
led_count
/
4
)
local
layer_size
=
size
-
2
*
iy
local
led_index
=
1
for
ix
=
iy
,
iy
+
layer_size
-
1
do
for
iz
=
iy
,
iy
+
layer_size
-
1
do
if
led_index
<=
led_count
then
local
led_pos
=
{}
if
(
ix
==
iy
or
ix
==
iy
+
layer_size
-
1
or
iz
==
iy
or
iz
==
iy
+
layer_size
-
1
)
then
if
not
((
ix
==
iy
and
iz
==
iy
)
or
(
ix
==
iy
and
iz
==
iy
+
layer_size
-
1
)
or
(
ix
==
iy
+
layer_size
-
1
and
iz
==
iy
)
or
(
ix
==
iy
+
layer_size
-
1
and
iz
==
iy
+
layer_size
-
1
))
then
led_pos
.
x
=
pos
.
x
+
ix
led_pos
.
z
=
pos
.
z
+
iz
led_pos
.
y
=
pos
.
y
+
iy
*
height_increment
+
math.floor
(
height_increment
/
2
)
core
.
bulk_set_node
(
needles
,
{
name
=
"ledtree:pine_needles"
})
return
leds
end
core
.
set_node
({
x
=
led_pos
.
x
,
y
=
led_pos
.
y
,
z
=
led_pos
.
z
},
{
name
=
"ledtree:led"
..
id
..
"_red"
})
id
=
id
+
1
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
led_index
=
led_index
+
1
end
end
end
end
end
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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment