Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
farming
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Illuna-Minetest
farming
Commits
01e2f374
Commit
01e2f374
authored
8 years ago
by
TenPlus1
Browse files
Options
Downloads
Patches
Plain Diff
using on_generate to place cocoa pods instead of abm
parent
38b41118
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cocoa.lua
+38
-30
38 additions, 30 deletions
cocoa.lua
with
38 additions
and
30 deletions
cocoa.lua
+
38
−
30
View file @
01e2f374
...
...
@@ -137,38 +137,46 @@ crop_def.drop = {
}
minetest
.
register_node
(
"farming:cocoa_3"
,
table
.
copy
(
crop_def
))
-- add random cocoa pods to jungle tree trunks
minetest
.
register_abm
({
nodenames
=
{
"default:jungletree"
},
neighbors
=
{
"default:jungleleaves"
,
"moretrees:jungletree_leaves_green"
},
interval
=
8
,
chance
=
80
,
catch_up
=
false
,
action
=
function
(
pos
,
node
)
local
dir
=
math.random
(
1
,
50
)
if
dir
==
1
then
pos
.
x
=
pos
.
x
+
1
elseif
dir
==
2
then
pos
.
x
=
pos
.
x
-
1
elseif
dir
==
3
then
pos
.
z
=
pos
.
z
+
1
elseif
dir
==
4
then
pos
.
z
=
pos
.
z
-
1
else
return
-- add random cocoa pods to jungle tree's
minetest
.
register_on_generated
(
function
(
minp
,
maxp
)
if
maxp
.
y
<
0
then
return
end
local
pos
,
dir
local
cocoa
=
minetest
.
find_nodes_in_area
(
minp
,
maxp
,
"default:jungletree"
)
for
n
=
1
,
#
cocoa
do
pos
=
cocoa
[
n
]
if
minetest
.
find_node_near
(
pos
,
1
,
{
"default:jungleleaves"
,
"moretrees:jungletree_leaves_green"
})
then
if
nodename
==
"air"
dir
=
math.random
(
1
,
80
)
if
dir
==
1
then
pos
.
x
=
pos
.
x
+
1
elseif
dir
==
2
then
pos
.
x
=
pos
.
x
-
1
elseif
dir
==
3
then
pos
.
z
=
pos
.
z
+
1
elseif
dir
==
4
then
pos
.
z
=
pos
.
z
-
1
end
if
dir
<
5
and
minetest
.
get_node
(
pos
).
name
==
"air"
and
minetest
.
get_node_light
(
pos
)
>
12
then
--print ("Cocoa Pod added at " .. minetest.pos_to_string(pos))
minetest
.
swap_node
(
pos
,
{
name
=
"farming:cocoa_"
..
tostring
(
math.random
(
1
,
3
))
})
end
minetest
.
set_node
(
pos
,
{
name
=
"farming:cocoa_"
..
tostring
(
math.random
(
1
,
3
))
end
en
d
end
,
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