Skip to content

Commit 0ea6065

Browse files
authored
Add butterflies mod
1 parent 5692c15 commit 0ea6065

10 files changed

+207
-0
lines changed

mods/butterflies/README.txt

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Minetest Game mod: Butterflies
2+
==============================
3+
Adds butterflies to the world on mapgen, which can be caught in a net if the
4+
fireflies mod is also enabled.
5+
6+
Authors of source code
7+
----------------------
8+
Shara RedCat (MIT)
9+
10+
Authors of media (textures)
11+
---------------------------
12+
Shara RedCat (CC BY-SA 3.0):
13+
butterflies_butterfly_*.png
14+
butterflies_butterfly_*_animated.png

mods/butterflies/depends.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
default
2+
flowers

mods/butterflies/init.lua

+133
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
-- register butterflies
2+
local butter_list = {
3+
{"white", "White"},
4+
{"red", "Red"},
5+
{"violet", "Violet"}
6+
}
7+
8+
for i in ipairs (butter_list) do
9+
local name = butter_list[i][1]
10+
local desc = butter_list[i][2]
11+
12+
minetest.register_node("butterflies:butterfly_"..name, {
13+
description = desc.." Butterfly",
14+
drawtype = "plantlike",
15+
tiles = {{
16+
name = "butterflies_butterfly_"..name.."_animated.png",
17+
animation = {
18+
type = "vertical_frames",
19+
aspect_w = 16,
20+
aspect_h = 16,
21+
length = 3
22+
},
23+
}},
24+
inventory_image = "butterflies_butterfly_"..name..".png",
25+
wield_image = "butterflies_butterfly_"..name..".png",
26+
waving = 1,
27+
paramtype = "light",
28+
sunlight_propagates = true,
29+
buildable_to = true,
30+
walkable = false,
31+
groups = {catchable = 1},
32+
selection_box = {
33+
type = "fixed",
34+
fixed = {-0.1, -0.1, -0.1, 0.1, 0.1, 0.1},
35+
},
36+
floodable = true,
37+
on_place = function(itemstack, placer, pointed_thing)
38+
local player_name = placer:get_player_name()
39+
local pos = pointed_thing.above
40+
41+
if not minetest.is_protected(pos, player_name) and
42+
not minetest.is_protected(pointed_thing.under, player_name) and
43+
minetest.get_node(pos).name == "air" then
44+
minetest.set_node(pos, {name = "butterflies:butterfly_"..name})
45+
minetest.get_node_timer(pos):start(1)
46+
itemstack:take_item()
47+
end
48+
return itemstack
49+
end,
50+
on_timer = function(pos, elapsed)
51+
if minetest.get_node_light(pos) < 11 then
52+
minetest.set_node(pos, {name = "butterflies:hidden_butterfly_"..name})
53+
end
54+
minetest.get_node_timer(pos):start(30)
55+
end
56+
})
57+
58+
minetest.register_node("butterflies:hidden_butterfly_"..name, {
59+
description = "Hidden "..desc.." Butterfly",
60+
drawtype = "airlike",
61+
inventory_image = "insects_butterfly_"..name..".png",
62+
wield_image = "insects_butterfly_"..name..".png",
63+
paramtype = "light",
64+
sunlight_propagates = true,
65+
walkable = false,
66+
pointable = false,
67+
diggable = false,
68+
drop = "",
69+
groups = {not_in_creative_inventory = 1},
70+
floodable = true,
71+
on_place = function(itemstack, placer, pointed_thing)
72+
local player_name = placer:get_player_name()
73+
local pos = pointed_thing.above
74+
75+
if not minetest.is_protected(pos, player_name) and
76+
not minetest.is_protected(pointed_thing.under, player_name) and
77+
minetest.get_node(pos).name == "air" then
78+
minetest.set_node(pos, {name = "butterflies:hidden_butterfly_"..name})
79+
minetest.get_node_timer(pos):start(1)
80+
itemstack:take_item()
81+
end
82+
return itemstack
83+
end,
84+
on_timer = function(pos, elapsed)
85+
if minetest.get_node_light(pos) >= 11 then
86+
minetest.set_node(pos, {name = "butterflies:butterfly_"..name})
87+
end
88+
minetest.get_node_timer(pos):start(30)
89+
end
90+
})
91+
end
92+
93+
-- register decoration
94+
minetest.register_decoration({
95+
name = "butterflies:butterfly",
96+
deco_type = "simple",
97+
place_on = {"default:dirt_with_grass"},
98+
place_offset_y = 2,
99+
sidelen = 80,
100+
fill_ratio = 0.005,
101+
biomes = {"grassland", "deciduous_forest", "floatland_grassland"},
102+
y_max = 31000,
103+
y_min = 1,
104+
decoration = {
105+
"butterflies:butterfly_white",
106+
"butterflies:butterfly_red",
107+
"butterflies:butterfly_violet"
108+
},
109+
spawn_by = "group:flower",
110+
num_spawn_by = 1
111+
})
112+
113+
-- get decoration ID
114+
local butterflies = minetest.get_decoration_id("butterflies:butterfly")
115+
minetest.set_gen_notify({decoration = true}, {butterflies})
116+
117+
-- start nodetimers
118+
minetest.register_on_generated(function(minp, maxp, blockseed)
119+
local gennotify = minetest.get_mapgen_object("gennotify")
120+
local poslist = {}
121+
122+
for _, pos in ipairs(gennotify["decoration#"..butterflies] or {}) do
123+
local deco_pos = {x = pos.x, y = pos.y + 3, z = pos.z}
124+
table.insert(poslist, deco_pos)
125+
end
126+
127+
if #poslist ~= 0 then
128+
for i = 1, #poslist do
129+
local pos = poslist[i]
130+
minetest.get_node_timer(pos):start(1)
131+
end
132+
end
133+
end)

mods/butterflies/license.txt

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
License of source code
2+
----------------------
3+
4+
The MIT License (MIT)
5+
Copyright (c) 2018 Shara RedCat
6+
7+
Permission is hereby granted, free of charge, to any person obtaining a copy of this
8+
software and associated documentation files (the "Software"), to deal in the Software
9+
without restriction, including without limitation the rights to use, copy, modify, merge,
10+
publish, distribute, sublicense, and/or sell copies of the Software, and to permit
11+
persons to whom the Software is furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in all copies or
14+
substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
17+
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
18+
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
19+
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20+
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21+
DEALINGS IN THE SOFTWARE.
22+
23+
For more details:
24+
https://opensource.org/licenses/MIT
25+
26+
Licenses of media (textures)
27+
----------------------------
28+
29+
Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
30+
Copyright (C) 2018 Shara RedCat
31+
32+
You are free to:
33+
Share — copy and redistribute the material in any medium or format.
34+
Adapt — remix, transform, and build upon the material for any purpose, even commercially.
35+
The licensor cannot revoke these freedoms as long as you follow the license terms.
36+
37+
Under the following terms:
38+
39+
Attribution — You must give appropriate credit, provide a link to the license, and
40+
indicate if changes were made. You may do so in any reasonable manner, but not in any way
41+
that suggests the licensor endorses you or your use.
42+
43+
ShareAlike — If you remix, transform, or build upon the material, you must distribute
44+
your contributions under the same license as the original.
45+
46+
No additional restrictions — You may not apply legal terms or technological measures that
47+
legally restrict others from doing anything the license permits.
48+
49+
Notices:
50+
51+
You do not have to comply with the license for elements of the material in the public
52+
domain or where your use is permitted by an applicable exception or limitation.
53+
No warranties are given. The license may not give you all of the permissions necessary
54+
for your intended use. For example, other rights such as publicity, privacy, or moral
55+
rights may limit how you use the material.
56+
57+
For more details:
58+
http://creativecommons.org/licenses/by-sa/3.0/
Loading
Loading
Loading
Loading
Loading
Loading

0 commit comments

Comments
 (0)