Compare commits

...

6 Commits

28 changed files with 471 additions and 1 deletions

View File

@ -0,0 +1,22 @@
Minetest Game mod: fireflies
============================
Adds fireflies to the world on mapgen, which can then be caught in a net and placed in
bottles to provide light.
Authors of source code
----------------------
Shara RedCat (MIT)
Authors of media (textures)
---------------------------
Shara RedCat (CC BY-SA 3.0):
fireflies_firefly.png
fireflies_firefly_animated.png
fireflies_bugnet.png
fireflies_bottle.png
fireflies_bottle_animated.png
fireflies_bugnet.png is modified from a texture by tenplus1 (CC0)
fireflies_bottle.png and fireflies_bottle_animated.png are
modified from a texture by Vanessa Ezekowitz (CC BY-SA 3.0)

View File

@ -0,0 +1,293 @@
-- firefly/init.lua
-- Load support for MT game translation.
local S = minetest.get_translator("fireflies")
local enabled = minetest.settings:get_bool("mcl_feature_fireflies",true)
local biomes = { "SwampLand","SwampLand_shore","SwampLand_ocean","MangroveSwamp","MangroveSwamp_shore","MangroveSwamp_ocean"}
local placeon = {"mcl_core:dirt_with_grass","group:leaves","group:grass_block","group:dirt","mcl_mud:mud"}
local adjacents = {
vector.new(1,0,0),
vector.new(-1,0,0),
vector.new(0,1,0),
vector.new(0,-1,0),
vector.new(0,0,1),
vector.new(0,0,-1),
}
minetest.register_node("mcl_fireflies:firefly", {
description = S("Firefly"),
drawtype = "plantlike",
tiles = {{
name = "fireflies_firefly_animated.png",
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 1.5
},
}},
inventory_image = "fireflies_firefly.png",
wield_image = "fireflies_firefly.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},
},
light_source = 6,
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 = "mcl_fireflies:firefly"})
minetest.get_node_timer(pos):start(1)
itemstack:take_item()
end
return itemstack
end,
on_timer = function(pos, elapsed)
if math.random(2) == 1 then
local npos = vector.add(pos,adjacents[math.random(#adjacents)])
if minetest.get_node(npos).name == "air" then
minetest.set_node(npos, {name = "mcl_fireflies:firefly"})
minetest.remove_node(pos)
pos = npos
end
end
if not enabled or minetest.get_node_light(pos) > 11 then
minetest.set_node(pos, {name = "mcl_fireflies:hidden_firefly"})
end
minetest.get_node_timer(pos):start(30)
end
})
minetest.register_node("mcl_fireflies:hidden_firefly", {
description = S("Hidden Firefly"),
drawtype = "airlike",
inventory_image = "fireflies_firefly.png^default_invisible_node_overlay.png",
wield_image = "fireflies_firefly.png^default_invisible_node_overlay.png",
paramtype = "light",
sunlight_propagates = true,
walkable = false,
pointable = false,
diggable = false,
buildable_to = true,
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 = "mcl_fireflies:hidden_firefly"})
minetest.get_node_timer(pos):start(1)
itemstack:take_item()
end
return itemstack
end,
on_timer = function(pos, elapsed)
if enabled and minetest.get_node_light(pos) <= 11 then
minetest.set_node(pos, {name = "mcl_fireflies:firefly"})
end
minetest.get_node_timer(pos):start(30)
end
})
-- bug net
minetest.register_tool("mcl_fireflies:bug_net", {
description = S("Bug Net"),
inventory_image = "fireflies_bugnet.png",
on_place = function(itemstack, player, pointed_thing)
local player_name = player and player:get_player_name() or ""
if not pointed_thing or pointed_thing.type ~= "node" or
minetest.is_protected(pointed_thing.under, player_name) then
return
end
local node_name = minetest.get_node(pointed_thing.under).name
local inv = player:get_inventory()
if minetest.get_item_group(node_name, "catchable") == 1 then
minetest.set_node(pointed_thing.under, {name = "air"})
local stack = ItemStack(node_name.." 1")
local leftover = inv:add_item("main", stack)
if leftover:get_count() > 0 then
minetest.add_item(pointed_thing.under, node_name.." 1")
end
end
if not minetest.is_creative_enabled(player_name) then
itemstack:add_wear(256)
return itemstack
end
end
})
minetest.register_craft( {
output = "mcl_fireflies:bug_net",
recipe = {
{"mcl_mobitems:string", "mcl_mobitems:string"},
{"mcl_mobitems:string", "mcl_mobitems:string"},
{"mcl_core:stick", ""}
}
})
-- firefly in a bottle
minetest.register_node("mcl_fireflies:firefly_bottle", {
description = S("Firefly in a Bottle"),
inventory_image = "fireflies_bottle.png",
wield_image = "fireflies_bottle.png",
tiles = {{
name = "fireflies_bottle_animated.png",
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 1.5
},
}},
drawtype = "plantlike",
paramtype = "light",
sunlight_propagates = true,
light_source = 9,
walkable = false,
groups = {vessel = 1, dig_immediate = 3, attached_node = 1},
selection_box = {
type = "fixed",
fixed = {-0.25, -0.5, -0.25, 0.25, 0.3, 0.25}
},
--sounds = default.node_sound_glass_defaults(),
on_rightclick = function(pos, node, player, itemstack, pointed_thing)
local lower_pos = {x = pos.x, y = pos.y + 1, z = pos.z}
if minetest.is_protected(pos, player:get_player_name()) or
minetest.get_node(lower_pos).name ~= "air" then
return
end
local upper_pos = {x = pos.x, y = pos.y + 2, z = pos.z}
local firefly_pos
if not minetest.is_protected(upper_pos, player:get_player_name()) and
minetest.get_node(upper_pos).name == "air" then
firefly_pos = upper_pos
elseif not minetest.is_protected(lower_pos, player:get_player_name()) then
firefly_pos = lower_pos
end
if firefly_pos then
minetest.set_node(pos, {name = "mcl_potions:glass_bottle"})
minetest.set_node(firefly_pos, {name = "mcl_fireflies:firefly"})
minetest.get_node_timer(firefly_pos):start(1)
end
end
})
minetest.register_craft( {
output = "mcl_fireflies:firefly_bottle",
recipe = {
{"mcl_fireflies:firefly"},
{"mcl_potions:glass_bottle"}
}
})
-- register fireflies as decorations
if minetest.get_mapgen_setting("mg_name") == "v6" then
minetest.register_decoration({
name = "mcl_fireflies:firefly_low",
deco_type = "simple",
place_on = "mcl_core:dirt_with_grass",
place_offset_y = 2,
sidelen = 80,
fill_ratio = 0.0002,
y_max = 31000,
y_min = 1,
decoration = "mcl_fireflies:hidden_firefly",
})
minetest.register_decoration({
name = "mcl_fireflies:firefly_high",
deco_type = "simple",
place_on = "mcl_core:dirt_with_grass",
place_offset_y = 3,
sidelen = 80,
fill_ratio = 0.0002,
y_max = 31000,
y_min = 1,
decoration = "mcl_fireflies:hidden_firefly",
})
else
minetest.register_decoration({
name = "mcl_fireflies:firefly_low",
deco_type = "simple",
place_on = placeon,
place_offset_y = 1,
sidelen = 80,
fill_ratio = 0.0025,
biomes = biomes,
y_max = 31000,
y_min = -1,
decoration = "mcl_fireflies:hidden_firefly",
})
minetest.register_decoration({
name = "mcl_fireflies:firefly_high",
deco_type = "simple",
place_on = placeon,
place_offset_y = 3,
sidelen = 80,
fill_ratio = 0.0025,
biomes = { "SwampLand","SwampLand_shore","SwampLand_ocean","MangroveSwamp","MangroveSwamp_shore","MangroveSwamp_ocean"},
y_max = 31000,
y_min = -1,
decoration = "mcl_fireflies:hidden_firefly",
})
end
-- get decoration IDs
local firefly_low = minetest.get_decoration_id("mcl_fireflies:firefly_low")
local firefly_high = minetest.get_decoration_id("mcl_fireflies:firefly_high")
minetest.set_gen_notify({decoration = true}, {firefly_low, firefly_high})
-- 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#"..firefly_low] or {}) do
local firefly_low_pos = {x = pos.x, y = pos.y + 2, z = pos.z}
table.insert(poslist, firefly_low_pos)
end
for _, pos in ipairs(gennotify["decoration#"..firefly_high] or {}) do
local firefly_high_pos = {x = pos.x, y = pos.y + 4, z = pos.z}
table.insert(poslist, firefly_high_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/

View File

@ -0,0 +1,5 @@
# textdomain: fireflies
Firefly=Glühwürmchen
Hidden Firefly=Verborgenes Glühwürmchen
Bug Net=Insektennetz
Firefly in a Bottle=Glühwürmchen in einer Flasche

View File

@ -0,0 +1,5 @@
# textdomain: fireflies
Firefly=Lampiro
Hidden Firefly=Kaŝita Lampiro
Bug Net=Insekta Reto
Firefly in a Bottle=Lampiro en Botelo

View File

@ -0,0 +1,5 @@
# textdomain: fireflies
Firefly=Luciérnaga
Hidden Firefly=Luciérnaga oculta
Bug Net=Red de insectos
Firefly in a Bottle=Luciérnaga en botella

View File

@ -0,0 +1,5 @@
# textdomain: fireflies
Firefly=Luciole
Hidden Firefly=Luciole cachée
Bug Net=Filet à papillon
Firefly in a Bottle=Luciole en bouteille

View File

@ -0,0 +1,5 @@
# textdomain: fireflies
Firefly=Kunang-Kunang
Hidden Firefly=Kunang-Kunang Tersembunyi
Bug Net=Jaring Serangga
Firefly in a Bottle=Kunang-Kunang dalam Botol

View File

@ -0,0 +1,5 @@
# textdomain: fireflies
Firefly=Lucciola
Hidden Firefly=Lucciola nascosta
Bug Net=Retino
Firefly in a Bottle=Lucciola imbottigliata

View File

@ -0,0 +1,5 @@
# textdomain: fireflies
Firefly=ホタル
Hidden Firefly=隠されたホタル
Bug Net=虫取り網
Firefly in a Bottle=ホタルの入った瓶

View File

@ -0,0 +1,5 @@
# textdomain: fireflies
Firefly=lo gusycinki
Hidden Firefly=lo se mipri gusycinki
Bug Net=lo cinki julne
Firefly in a Bottle=lo gusycinki poi nenri lo botpi

View File

@ -0,0 +1,5 @@
# textdomain: fireflies
Firefly=Kelip-Kelip
Hidden Firefly=Kelip-Kelip Tersembunyi
Bug Net=Jaring Pepijat
Firefly in a Bottle=Kelip-Kelip dalam Botol

View File

@ -0,0 +1,5 @@
# textdomain: fireflies
Firefly=Świetlik
Hidden Firefly=Ukryty świetlik
Bug Net=Siatka na owady
Firefly in a Bottle=Świetlik w butelce

View File

@ -0,0 +1,5 @@
# textdomain: fireflies
Firefly=Vaga-lume
Hidden Firefly=Vaga-lume escondido
Bug Net=Rede de Insetos
Firefly in a Bottle=Vaga-lume em uma garrafa

View File

@ -0,0 +1,5 @@
# textdomain: fireflies
Firefly=Светлячок
Hidden Firefly=Притаившийся Светлячок
Bug Net=Сачок Для Ловли Насекомых
Firefly in a Bottle=Светлячок в Бутылке

View File

@ -0,0 +1,5 @@
# textdomain: fireflies
Firefly=Svetluška
Hidden Firefly=Skrytá svetluška
Bug Net=Sieťka na hmyz
Firefly in a Bottle=Svetluška vo fľaši

View File

@ -0,0 +1,5 @@
# textdomain: fireflies
Firefly=Eldfluga
Hidden Firefly=Gömd eldfluga
Bug Net=Insektshåv
Firefly in a Bottle=Eldfluga i en flaska

View File

@ -0,0 +1,5 @@
# textdomain: fireflies
Firefly=Світлячок
Hidden Firefly=Світлячок, що причаївся
Bug Net=Сачок Для Ловлі Комах
Firefly in a Bottle=Світлячок у Пляшці

View File

@ -0,0 +1,5 @@
# textdomain: fireflies
Firefly=萤火虫
Hidden Firefly=隐藏的萤火虫
Bug Net=虫网
Firefly in a Bottle=放在瓶子里的萤火虫

View File

@ -0,0 +1,5 @@
# textdomain: fireflies
Firefly=螢火蟲
Hidden Firefly=隱藏的螢火蟲
Bug Net=蟲網
Firefly in a Bottle=放在瓶子裡的螢火蟲

View File

@ -0,0 +1,5 @@
# textdomain: fireflies
Firefly=
Hidden Firefly=
Bug Net=
Firefly in a Bottle=

View File

@ -0,0 +1,3 @@
name = mcl_fireflies
description = Fireflies for MineClone2
depends = mcl_biomes

Binary file not shown.

After

Width:  |  Height:  |  Size: 172 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 203 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 192 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 113 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 121 B

View File

@ -39,6 +39,10 @@ mcl_doTileDrops (Blocks have drops) bool true
# If enabled, TNT explosions destroy blocks.
mcl_tnt_griefing (TNT destroys blocks) bool true
[ Feature flags ]
# Wether fireflies are enabled
mcl_feature_fireflies (Enable Fireflies) bool true
[Players]
# If enabled, players respawn at the bed they last lay on instead of normal
# spawn.
@ -168,4 +172,4 @@ enable_real_maps (Enable Real Maps) bool true
[Debugging]
# If enabled, this will show the itemstring of an item in the description.
mcl_item_id_debug (Item ID Debug) bool false
mcl_item_id_debug (Item ID Debug) bool false