Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Moonflower, Glowing Mese / Dye #169

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 15 additions & 0 deletions mods/default/crafting.lua
Expand Up @@ -304,6 +304,21 @@ minetest.register_craft({
recipe = {"default:steel_ingot", "default:copper_ingot"},
})

minetest.register_craft({
type = "shapeless",
output = "dye:glowing_dye",
recipe = {"default:mese_crystal_fragment", "moonflower:moonflower_closed"},
})

minetest.register_craft({
output = 'default:glowing_mese',
recipe = {
{'', 'dye:glowing_dye', ''},
{'dye:glowing_dye', 'default:mese', 'dye:glowing_dye'},
{'', 'dye:glowing_dye', ''},
}
})

minetest.register_craft({
output = 'default:coalblock',
recipe = {
Expand Down
8 changes: 8 additions & 0 deletions mods/default/nodes.lua
Expand Up @@ -29,6 +29,14 @@ minetest.register_node("default:stone_with_coal", {
sounds = default.node_sound_stone_defaults(),
})

minetest.register_node("default:glowing_mese", {
description = "Glowing Mese",
tiles = {"default_glowing_mese.png"},
groups = {cracky=1,level=2},
light_source = 14,
sounds = default.node_sound_stone_defaults(),
})

minetest.register_node("default:stone_with_iron", {
description = "Iron Ore",
tiles = {"default_stone.png^default_mineral_iron.png"},
Expand Down
Binary file added mods/default/textures/default_glowing_mese.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions mods/dye/init.lua
Expand Up @@ -61,6 +61,12 @@ dye.excolors = {"white", "lightgrey", "grey", "darkgrey", "black", "red", "orang
-- Local stuff
local dyelocal = {}

-- Glowing Moonflower Dye:
minetest.register_craftitem("dye:glowing_dye", {
description = "Glowing Moonflower Dye",
inventory_image = "dye_moonflower_glow.png",
})

-- This collection of colors is partly a historic thing, partly something else.
dyelocal.dyes = {
{"white", "White dye", {dye=1, basecolor_white=1, excolor_white=1, unicolor_white=1}},
Expand Down
Binary file added mods/dye/textures/dye_moonflower_glow.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions mods/moonflower/depends.txt
@@ -0,0 +1 @@
default
88 changes: 88 additions & 0 deletions mods/moonflower/init.lua
@@ -0,0 +1,88 @@
-- Moon Flower mod by MirceaKitsune

local SPAWN_ATTEMPTS = 5 -- How many times to attempt spawning per chunk
local SPAWN_PROBABILITY = 0.1 -- Probability of each spawn attempt
local OPEN_TIME_START = 0.2 -- Day time at which moon flowers open up
local OPEN_TIME_END = 0.8 -- Day time at which moon flowers close up
local OPEN_CHECK = 10 -- Interval at which to check if lighting changed

minetest.register_node("moonflower:moonflower_closed", {
description = "Moon flower",
drawtype = "plantlike",
tiles = { "moonflower_closed.png" },
inventory_image = "moonflower_closed.png",
wield_image = "moonflower_closed.png",
sunlight_propagates = true,
paramtype = "light",
walkable = false,
groups = { snappy = 3, flammable=2, flower=1 },
drop = 'moonflower:moonflower_closed',
sounds = default.node_sound_leaves_defaults(),
selection_box = {
type = "fixed",
fixed = { -0.15, -0.5, -0.15, 0.15, 0.2, 0.15 },
},
})

minetest.register_node("moonflower:moonflower_open", {
description = "Moon flower",
drawtype = "plantlike",
tiles = { "moonflower_open.png" },
inventory_image = "moonflower_open.png",
wield_image = "moonflower_open.png",
paramtype = "light",
sunlight_propagates = true,
paramtype = "light",
walkable = false,
light_source = LIGHT_MAX / 2,
groups = { not_in_creative_inventory = 1, snappy = 3, flammable=2, flower=1 },
drop = 'moonflower:moonflower_closed',
sounds = default.node_sound_leaves_defaults(),
selection_box = {
type = "fixed",
fixed = { -0.15, -0.5, -0.15, 0.15, 0.2, 0.15 },
},
})

set_moonflower = function (pos)
-- choose the appropriate form of the moon flower
if (minetest.env:get_node_light(pos, 0.5) == 15)
and ((minetest.env:get_timeofday() < OPEN_TIME_START) or (minetest.env:get_timeofday() > OPEN_TIME_END)) then
minetest.env:add_node(pos, { name = "moonflower:moonflower_open" })
else
minetest.env:add_node(pos, { name = "moonflower:moonflower_closed" })
end
end

minetest.register_abm({
nodenames = { "moonflower:moonflower_closed", "moonflower:moonflower_open" },
interval = OPEN_CHECK,
chance = 1,

action = function(pos, node, active_object_count, active_object_count_wider)
set_moonflower(pos)
end
})

minetest.register_on_generated(function(minp, maxp, seed)
for attempts = 0, SPAWN_ATTEMPTS do
-- choose a random location on the X and Z axes
local coords_x = math.random(minp.x, maxp.x)
local coords_z = math.random(minp.z, maxp.z)

-- now scan upward until we find a suitable spot on the Y axis, if none is found this attempt is failed
for coords_y = minp.y, maxp.y do
local pos_here = { x = coords_x, y = coords_y, z = coords_z }
local node_here = minetest.env:get_node(pos_here)
local pos_top = { x = coords_x, y = coords_y + 1, z = coords_z }
local node_top = minetest.env:get_node(pos_top)

if (node_here.name == "default:dirt_with_grass") and (node_top.name == "air") then
if (math.random() <= SPAWN_PROBABILITY) then
set_moonflower(pos_top)
end
break
end
end
end
end)
Binary file added mods/moonflower/textures/moonflower_closed.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added mods/moonflower/textures/moonflower_open.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.