From 0ea6065a09f1fee014c7f2a9a36605d57986a209 Mon Sep 17 00:00:00 2001 From: Ezhh Date: Mon, 25 Jun 2018 21:28:39 +0100 Subject: [PATCH] Add butterflies mod --- mods/butterflies/README.txt | 14 ++ mods/butterflies/depends.txt | 2 + mods/butterflies/init.lua | 133 ++++++++++++++++++ mods/butterflies/license.txt | 58 ++++++++ .../textures/butterflies_butterfly_red.png | Bin 0 -> 110 bytes .../butterflies_butterfly_red_animated.png | Bin 0 -> 125 bytes .../textures/butterflies_butterfly_violet.png | Bin 0 -> 110 bytes .../butterflies_butterfly_violet_animated.png | Bin 0 -> 125 bytes .../textures/butterflies_butterfly_white.png | Bin 0 -> 110 bytes .../butterflies_butterfly_white_animated.png | Bin 0 -> 125 bytes 10 files changed, 207 insertions(+) create mode 100644 mods/butterflies/README.txt create mode 100644 mods/butterflies/depends.txt create mode 100644 mods/butterflies/init.lua create mode 100644 mods/butterflies/license.txt create mode 100644 mods/butterflies/textures/butterflies_butterfly_red.png create mode 100644 mods/butterflies/textures/butterflies_butterfly_red_animated.png create mode 100644 mods/butterflies/textures/butterflies_butterfly_violet.png create mode 100644 mods/butterflies/textures/butterflies_butterfly_violet_animated.png create mode 100644 mods/butterflies/textures/butterflies_butterfly_white.png create mode 100644 mods/butterflies/textures/butterflies_butterfly_white_animated.png diff --git a/mods/butterflies/README.txt b/mods/butterflies/README.txt new file mode 100644 index 00000000..a7f52a07 --- /dev/null +++ b/mods/butterflies/README.txt @@ -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 \ No newline at end of file diff --git a/mods/butterflies/depends.txt b/mods/butterflies/depends.txt new file mode 100644 index 00000000..df07aca3 --- /dev/null +++ b/mods/butterflies/depends.txt @@ -0,0 +1,2 @@ +default +flowers \ No newline at end of file diff --git a/mods/butterflies/init.lua b/mods/butterflies/init.lua new file mode 100644 index 00000000..008211ee --- /dev/null +++ b/mods/butterflies/init.lua @@ -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) diff --git a/mods/butterflies/license.txt b/mods/butterflies/license.txt new file mode 100644 index 00000000..eebdad63 --- /dev/null +++ b/mods/butterflies/license.txt @@ -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/ \ No newline at end of file diff --git a/mods/butterflies/textures/butterflies_butterfly_red.png b/mods/butterflies/textures/butterflies_butterfly_red.png new file mode 100644 index 0000000000000000000000000000000000000000..8edfc3659c113f648b8efa5771c2731110e254c3 GIT binary patch literal 110 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!93?!50ihlx9oB=)|u0Z;FaPSgNt$)$s%0Lcd zNswPKgTu2MX+Vy!r;B3<$Ms|dHUldL&Sh*#QgTe~DWM4f DxxpD+ literal 0 HcmV?d00001 diff --git a/mods/butterflies/textures/butterflies_butterfly_red_animated.png b/mods/butterflies/textures/butterflies_butterfly_red_animated.png new file mode 100644 index 0000000000000000000000000000000000000000..4a2097bd0447df99bbf0c6388fdf5e8124b86fdd GIT binary patch literal 125 zcmeAS@N?(olHy`uVBq!ia0vp^0zllr#0(_se=}|bQk(%kA+A9BdT{U(POX2@;mSY` zV@Z%-FoVOh8)-m}lBbJfh{pM31qKO67GdV8jm#Yx3clw9$~BMFHlGM>Ryx2Ce1n;{ TOe@C&sG7mk)z4*}Q$iB}%%LCs literal 0 HcmV?d00001 diff --git a/mods/butterflies/textures/butterflies_butterfly_violet.png b/mods/butterflies/textures/butterflies_butterfly_violet.png new file mode 100644 index 0000000000000000000000000000000000000000..8b8c29ddf0edf7a2267a5ffb622b8bfe409962a7 GIT binary patch literal 110 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!93?!50ihlx9oB=)|u0Xm?XIC7gTe~DWM4f DkqH>G literal 0 HcmV?d00001 diff --git a/mods/butterflies/textures/butterflies_butterfly_violet_animated.png b/mods/butterflies/textures/butterflies_butterfly_violet_animated.png new file mode 100644 index 0000000000000000000000000000000000000000..3f9d72e9fce79e261a27e5126b6dbfef4d548d42 GIT binary patch literal 125 zcmeAS@N?(olHy`uVBq!ia0vp^0zllr#0(_se=}|bQk(%kA+A8WO=nje!<029YLY+> zV@Z%-FoVOh8)-m}lBbJfh{pM31qKO67GdV8jm#Yx3clw9$~BMFHlGM>Ryx2Ce1n;{ TOe@C&sG7mk)z4*}Q$iB}ne!i0 literal 0 HcmV?d00001 diff --git a/mods/butterflies/textures/butterflies_butterfly_white.png b/mods/butterflies/textures/butterflies_butterfly_white.png new file mode 100644 index 0000000000000000000000000000000000000000..db4eaec81fd2e2c958f22a6623f316a331f95bfc GIT binary patch literal 110 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!93?!50ihlx9oB=)|u0Z<#|NnRH+zH(qeG~V%8lDfAy0;L%|UHx3vIVCg! E0GjX|`~Uy| literal 0 HcmV?d00001 diff --git a/mods/butterflies/textures/butterflies_butterfly_white_animated.png b/mods/butterflies/textures/butterflies_butterfly_white_animated.png new file mode 100644 index 0000000000000000000000000000000000000000..e7cada39a9bc439eb7501472c4ccc843cef1b096 GIT binary patch literal 125 zcmeAS@N?(olHy`uVBq!ia0vp^0zllr#0(_se=}|bQk(%kA+A9B|NsAw?_U0_cXbPp z!&nmJ7tG-B>_!@pqvYx07@~1LS%E>qkwut!Y9n(;hJx?;fO5?vwaq6&o0SeQ1m9rh UEz`>J0IFv2boFyt=akR{00r125C8xG literal 0 HcmV?d00001