Add butterflies mod

This commit is contained in:
Ezhh 2018-06-25 21:28:39 +01:00 committed by GitHub
parent 5692c15b4d
commit 0ea6065a09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 207 additions and 0 deletions

View File

@ -0,0 +1,14 @@
Minetest Game mod: Butterflies
==============================
Adds butterflies to the world on mapgen, which can be caught in a net if the
fireflies mod is also enabled.
Authors of source code
----------------------
Shara RedCat (MIT)
Authors of media (textures)
---------------------------
Shara RedCat (CC BY-SA 3.0):
butterflies_butterfly_*.png
butterflies_butterfly_*_animated.png

View File

@ -0,0 +1,2 @@
default
flowers

133
mods/butterflies/init.lua Normal file
View File

@ -0,0 +1,133 @@
-- register butterflies
local butter_list = {
{"white", "White"},
{"red", "Red"},
{"violet", "Violet"}
}
for i in ipairs (butter_list) do
local name = butter_list[i][1]
local desc = butter_list[i][2]
minetest.register_node("butterflies:butterfly_"..name, {
description = desc.." Butterfly",
drawtype = "plantlike",
tiles = {{
name = "butterflies_butterfly_"..name.."_animated.png",
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 3
},
}},
inventory_image = "butterflies_butterfly_"..name..".png",
wield_image = "butterflies_butterfly_"..name..".png",
waving = 1,
paramtype = "light",
sunlight_propagates = true,
buildable_to = true,
walkable = false,
groups = {catchable = 1},
selection_box = {
type = "fixed",
fixed = {-0.1, -0.1, -0.1, 0.1, 0.1, 0.1},
},
floodable = true,
on_place = function(itemstack, placer, pointed_thing)
local player_name = placer:get_player_name()
local pos = pointed_thing.above
if not minetest.is_protected(pos, player_name) and
not minetest.is_protected(pointed_thing.under, player_name) and
minetest.get_node(pos).name == "air" then
minetest.set_node(pos, {name = "butterflies:butterfly_"..name})
minetest.get_node_timer(pos):start(1)
itemstack:take_item()
end
return itemstack
end,
on_timer = function(pos, elapsed)
if minetest.get_node_light(pos) < 11 then
minetest.set_node(pos, {name = "butterflies:hidden_butterfly_"..name})
end
minetest.get_node_timer(pos):start(30)
end
})
minetest.register_node("butterflies:hidden_butterfly_"..name, {
description = "Hidden "..desc.." Butterfly",
drawtype = "airlike",
inventory_image = "insects_butterfly_"..name..".png",
wield_image = "insects_butterfly_"..name..".png",
paramtype = "light",
sunlight_propagates = true,
walkable = false,
pointable = false,
diggable = false,
drop = "",
groups = {not_in_creative_inventory = 1},
floodable = true,
on_place = function(itemstack, placer, pointed_thing)
local player_name = placer:get_player_name()
local pos = pointed_thing.above
if not minetest.is_protected(pos, player_name) and
not minetest.is_protected(pointed_thing.under, player_name) and
minetest.get_node(pos).name == "air" then
minetest.set_node(pos, {name = "butterflies:hidden_butterfly_"..name})
minetest.get_node_timer(pos):start(1)
itemstack:take_item()
end
return itemstack
end,
on_timer = function(pos, elapsed)
if minetest.get_node_light(pos) >= 11 then
minetest.set_node(pos, {name = "butterflies:butterfly_"..name})
end
minetest.get_node_timer(pos):start(30)
end
})
end
-- register decoration
minetest.register_decoration({
name = "butterflies:butterfly",
deco_type = "simple",
place_on = {"default:dirt_with_grass"},
place_offset_y = 2,
sidelen = 80,
fill_ratio = 0.005,
biomes = {"grassland", "deciduous_forest", "floatland_grassland"},
y_max = 31000,
y_min = 1,
decoration = {
"butterflies:butterfly_white",
"butterflies:butterfly_red",
"butterflies:butterfly_violet"
},
spawn_by = "group:flower",
num_spawn_by = 1
})
-- get decoration ID
local butterflies = minetest.get_decoration_id("butterflies:butterfly")
minetest.set_gen_notify({decoration = true}, {butterflies})
-- start nodetimers
minetest.register_on_generated(function(minp, maxp, blockseed)
local gennotify = minetest.get_mapgen_object("gennotify")
local poslist = {}
for _, pos in ipairs(gennotify["decoration#"..butterflies] or {}) do
local deco_pos = {x = pos.x, y = pos.y + 3, z = pos.z}
table.insert(poslist, deco_pos)
end
if #poslist ~= 0 then
for i = 1, #poslist do
local pos = poslist[i]
minetest.get_node_timer(pos):start(1)
end
end
end)

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 110 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 125 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 110 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 125 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 110 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 125 B