fire flowers & give_initial_stuff
|
@ -0,0 +1,36 @@
|
|||
Minetest Game mod: fire
|
||||
=======================
|
||||
|
||||
License of source code:
|
||||
-----------------------
|
||||
Copyright (C) 2012 Perttu Ahola (celeron55) <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
|
||||
License of media (textures and sounds)
|
||||
--------------------------------------
|
||||
Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
|
||||
http://creativecommons.org/licenses/by-sa/3.0/
|
||||
|
||||
Authors of media files
|
||||
-----------------------
|
||||
Everything not listed in here:
|
||||
Copyright (C) 2012 Perttu Ahola (celeron55) <celeron55@gmail.com>
|
||||
|
||||
fire_small.ogg sampled from:
|
||||
http://www.freesound.org/people/dobroide/sounds/4211/
|
||||
|
||||
fire_large.ogg sampled from:
|
||||
http://www.freesound.org/people/Dynamicell/sounds/17548/
|
||||
|
||||
fire_basic_flame_animated.png:
|
||||
Muadtralk
|
||||
|
||||
fire_flint_steel.png
|
||||
Gambit (WTFPL)
|
||||
|
|
@ -0,0 +1,312 @@
|
|||
-- minetest/fire/init.lua
|
||||
|
||||
-- Global namespace for functions
|
||||
|
||||
fire = {}
|
||||
|
||||
|
||||
-- Register flame nodes
|
||||
|
||||
minetest.register_node("fire:basic_flame", {
|
||||
drawtype = "firelike",
|
||||
tiles = {
|
||||
{
|
||||
name = "fire_basic_flame_animated.png",
|
||||
animation = {
|
||||
type = "vertical_frames",
|
||||
aspect_w = 16,
|
||||
aspect_h = 16,
|
||||
length = 1
|
||||
},
|
||||
},
|
||||
},
|
||||
inventory_image = "fire_basic_flame.png",
|
||||
paramtype = "light",
|
||||
light_source = 14,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
sunlight_propagates = true,
|
||||
damage_per_second = 4,
|
||||
groups = {igniter = 2, dig_immediate = 3, not_in_creative_inventory = 1},
|
||||
drop = "",
|
||||
|
||||
on_construct = function(pos)
|
||||
minetest.after(0, fire.on_flame_add_at, pos)
|
||||
end,
|
||||
|
||||
on_destruct = function(pos)
|
||||
minetest.after(0, fire.on_flame_remove_at, pos)
|
||||
end,
|
||||
|
||||
on_blast = function()
|
||||
end, -- unaffected by explosions
|
||||
})
|
||||
|
||||
minetest.register_node("fire:permanent_flame", {
|
||||
description = "Permanent Flame",
|
||||
drawtype = "firelike",
|
||||
tiles = {
|
||||
{
|
||||
name = "fire_basic_flame_animated.png",
|
||||
animation = {
|
||||
type = "vertical_frames",
|
||||
aspect_w = 16,
|
||||
aspect_h = 16,
|
||||
length = 1
|
||||
},
|
||||
},
|
||||
},
|
||||
inventory_image = "fire_basic_flame.png",
|
||||
paramtype = "light",
|
||||
light_source = 14,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
sunlight_propagates = true,
|
||||
damage_per_second = 4,
|
||||
groups = {igniter = 2, dig_immediate = 3},
|
||||
drop = "",
|
||||
|
||||
on_blast = function()
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_tool("fire:flint_and_steel", {
|
||||
description = "Flint and Steel",
|
||||
inventory_image = "fire_flint_steel.png",
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
local player_name = user:get_player_name()
|
||||
local pt = pointed_thing
|
||||
|
||||
if pt.type == "node" and minetest.get_node(pt.above).name == "air" then
|
||||
itemstack:add_wear(1000)
|
||||
local node_under = minetest.get_node(pt.under).name
|
||||
|
||||
if minetest.get_item_group(node_under, "flammable") >= 1 then
|
||||
if not minetest.is_protected(pt.above, player_name) then
|
||||
minetest.set_node(pt.above, {name = "fire:basic_flame"})
|
||||
else
|
||||
minetest.chat_send_player(player_name, "This area is protected")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
return itemstack
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "fire:flint_and_steel",
|
||||
recipe = {
|
||||
{"default:flint", "default:steel_ingot"}
|
||||
}
|
||||
})
|
||||
|
||||
-- Get sound area of position
|
||||
|
||||
fire.D = 6 -- size of sound areas
|
||||
|
||||
function fire.get_area_p0p1(pos)
|
||||
local p0 = {
|
||||
x = math.floor(pos.x / fire.D) * fire.D,
|
||||
y = math.floor(pos.y / fire.D) * fire.D,
|
||||
z = math.floor(pos.z / fire.D) * fire.D,
|
||||
}
|
||||
local p1 = {
|
||||
x = p0.x + fire.D - 1,
|
||||
y = p0.y + fire.D - 1,
|
||||
z = p0.z + fire.D - 1
|
||||
}
|
||||
return p0, p1
|
||||
end
|
||||
|
||||
|
||||
-- Fire sounds table
|
||||
-- key: position hash of low corner of area
|
||||
-- value: {handle=sound handle, name=sound name}
|
||||
fire.sounds = {}
|
||||
|
||||
|
||||
-- Update fire sounds in sound area of position
|
||||
|
||||
function fire.update_sounds_around(pos)
|
||||
local p0, p1 = fire.get_area_p0p1(pos)
|
||||
local cp = {x = (p0.x + p1.x) / 2, y = (p0.y + p1.y) / 2, z = (p0.z + p1.z) / 2}
|
||||
local flames_p = minetest.find_nodes_in_area(p0, p1, {"fire:basic_flame"})
|
||||
--print("number of flames at "..minetest.pos_to_string(p0).."/"
|
||||
-- ..minetest.pos_to_string(p1)..": "..#flames_p)
|
||||
local should_have_sound = (#flames_p > 0)
|
||||
local wanted_sound = nil
|
||||
if #flames_p >= 9 then
|
||||
wanted_sound = {name = "fire_large", gain = 0.7}
|
||||
elseif #flames_p > 0 then
|
||||
wanted_sound = {name = "fire_small", gain = 0.9}
|
||||
end
|
||||
local p0_hash = minetest.hash_node_position(p0)
|
||||
local sound = fire.sounds[p0_hash]
|
||||
if not sound then
|
||||
if should_have_sound then
|
||||
fire.sounds[p0_hash] = {
|
||||
handle = minetest.sound_play(wanted_sound,
|
||||
{pos = cp, max_hear_distance = 16, loop = true}),
|
||||
name = wanted_sound.name,
|
||||
}
|
||||
end
|
||||
else
|
||||
if not wanted_sound then
|
||||
minetest.sound_stop(sound.handle)
|
||||
fire.sounds[p0_hash] = nil
|
||||
elseif sound.name ~= wanted_sound.name then
|
||||
minetest.sound_stop(sound.handle)
|
||||
fire.sounds[p0_hash] = {
|
||||
handle = minetest.sound_play(wanted_sound,
|
||||
{pos = cp, max_hear_distance = 16, loop = true}),
|
||||
name = wanted_sound.name,
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- Update fire sounds on flame node construct or destruct
|
||||
|
||||
function fire.on_flame_add_at(pos)
|
||||
fire.update_sounds_around(pos)
|
||||
end
|
||||
|
||||
|
||||
function fire.on_flame_remove_at(pos)
|
||||
fire.update_sounds_around(pos)
|
||||
end
|
||||
|
||||
|
||||
-- Return positions for flames around a burning node
|
||||
|
||||
function fire.find_pos_for_flame_around(pos)
|
||||
return minetest.find_node_near(pos, 1, {"air"})
|
||||
end
|
||||
|
||||
|
||||
-- Detect nearby extinguishing nodes
|
||||
|
||||
function fire.flame_should_extinguish(pos)
|
||||
return minetest.find_node_near(pos, 1, {"group:puts_out_fire"})
|
||||
end
|
||||
|
||||
|
||||
-- Extinguish all flames quickly with water, snow, ice
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"fire:basic_flame", "fire:permanent_flame"},
|
||||
neighbors = {"group:puts_out_fire"},
|
||||
interval = 3,
|
||||
chance = 1,
|
||||
catch_up = false,
|
||||
action = function(p0, node, _, _)
|
||||
minetest.remove_node(p0)
|
||||
minetest.sound_play("fire_extinguish_flame",
|
||||
{pos = p0, max_hear_distance = 16, gain = 0.25})
|
||||
end,
|
||||
})
|
||||
|
||||
|
||||
-- Enable the following ABMs according to 'disable fire' setting
|
||||
|
||||
if minetest.setting_getbool("disable_fire") then
|
||||
|
||||
-- Remove basic flames only
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"fire:basic_flame"},
|
||||
interval = 7,
|
||||
chance = 1,
|
||||
catch_up = false,
|
||||
action = function(p0, node, _, _)
|
||||
minetest.remove_node(p0)
|
||||
end,
|
||||
})
|
||||
|
||||
else
|
||||
|
||||
-- Ignite neighboring nodes, add basic flames
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"group:flammable"},
|
||||
neighbors = {"group:igniter"},
|
||||
interval = 7,
|
||||
chance = 12,
|
||||
catch_up = false,
|
||||
action = function(p0, node, _, _)
|
||||
-- If there is water or stuff like that around node, don't ignite
|
||||
if fire.flame_should_extinguish(p0) then
|
||||
return
|
||||
end
|
||||
local p = fire.find_pos_for_flame_around(p0)
|
||||
if p then
|
||||
minetest.set_node(p, {name = "fire:basic_flame"})
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
-- Remove basic flames and flammable nodes
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"fire:basic_flame"},
|
||||
interval = 5,
|
||||
chance = 6,
|
||||
catch_up = false,
|
||||
action = function(p0, node, _, _)
|
||||
-- If there are no flammable nodes around flame, remove flame
|
||||
local p = minetest.find_node_near(p0, 1, {"group:flammable"})
|
||||
if not p then
|
||||
minetest.remove_node(p0)
|
||||
return
|
||||
end
|
||||
if math.random(1, 3) == 1 then
|
||||
-- remove flammable nodes around flame
|
||||
local node = minetest.get_node(p)
|
||||
local def = minetest.registered_nodes[node.name]
|
||||
if def.on_burn then
|
||||
def.on_burn(p)
|
||||
else
|
||||
minetest.remove_node(p)
|
||||
nodeupdate(p)
|
||||
end
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
end
|
||||
|
||||
|
||||
-- Rarely ignite things from far
|
||||
|
||||
--[[ Currently disabled to reduce the chance of uncontrollable spreading
|
||||
fires that disrupt servers. Also for less lua processing load.
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"group:igniter"},
|
||||
neighbors = {"air"},
|
||||
interval = 5,
|
||||
chance = 10,
|
||||
action = function(p0, node, _, _)
|
||||
local reg = minetest.registered_nodes[node.name]
|
||||
if not reg or not reg.groups.igniter or reg.groups.igniter < 2 then
|
||||
return
|
||||
end
|
||||
local d = reg.groups.igniter
|
||||
local p = minetest.find_node_near(p0, d, {"group:flammable"})
|
||||
if p then
|
||||
-- If there is water or stuff like that around flame, don't ignite
|
||||
if fire.flame_should_extinguish(p) then
|
||||
return
|
||||
end
|
||||
local p2 = fire.find_pos_for_flame_around(p)
|
||||
if p2 then
|
||||
minetest.set_node(p2, {name = "fire:basic_flame"})
|
||||
end
|
||||
end
|
||||
end,
|
||||
})
|
||||
--]]
|
After Width: | Height: | Size: 646 B |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 3.0 KiB |
|
@ -0,0 +1,23 @@
|
|||
Minetest Game mod: flowers
|
||||
==========================
|
||||
|
||||
License of source code:
|
||||
-----------------------
|
||||
Copyright (C) 2012-2013 Ironzorg, VanessaE
|
||||
|
||||
This program is free software. It comes without any warranty, to
|
||||
the extent permitted by applicable law. You can redistribute it
|
||||
and/or modify it under the terms of the Do What The Fuck You Want
|
||||
To Public License, Version 2, as published by Sam Hocevar. See
|
||||
http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
|
||||
License of media (textures and sounds)
|
||||
--------------------------------------
|
||||
WTFPL
|
||||
|
||||
Gambit (WTFPL):
|
||||
flowers_mushroom_*.png
|
||||
flowers_waterlily.png
|
||||
|
||||
DanDuncombe (WTFPL):
|
||||
flowers_spores_*.png
|
|
@ -0,0 +1 @@
|
|||
default
|
|
@ -0,0 +1,257 @@
|
|||
-- Minetest 0.4 mod: default
|
||||
-- See README.txt for licensing and other information.
|
||||
|
||||
|
||||
-- Namespace for functions
|
||||
|
||||
flowers = {}
|
||||
|
||||
|
||||
-- Map Generation
|
||||
|
||||
dofile(minetest.get_modpath("flowers") .. "/mapgen.lua")
|
||||
|
||||
|
||||
--
|
||||
-- Flowers
|
||||
--
|
||||
|
||||
-- Aliases for original flowers mod
|
||||
|
||||
minetest.register_alias("flowers:flower_rose", "flowers:rose")
|
||||
minetest.register_alias("flowers:flower_tulip", "flowers:tulip")
|
||||
minetest.register_alias("flowers:flower_dandelion_yellow", "flowers:dandelion_yellow")
|
||||
minetest.register_alias("flowers:flower_geranium", "flowers:geranium")
|
||||
minetest.register_alias("flowers:flower_viola", "flowers:viola")
|
||||
minetest.register_alias("flowers:flower_dandelion_white", "flowers:dandelion_white")
|
||||
|
||||
|
||||
-- Flower registration
|
||||
|
||||
local function add_simple_flower(name, desc, box, f_groups)
|
||||
-- Common flowers' groups
|
||||
f_groups.snappy = 3
|
||||
f_groups.flower = 1
|
||||
f_groups.flora = 1
|
||||
f_groups.attached_node = 1
|
||||
|
||||
minetest.register_node("flowers:" .. name, {
|
||||
description = desc,
|
||||
drawtype = "plantlike",
|
||||
waving = 1,
|
||||
tiles = {"flowers_" .. name .. ".png"},
|
||||
inventory_image = "flowers_" .. name .. ".png",
|
||||
wield_image = "flowers_" .. name .. ".png",
|
||||
sunlight_propagates = true,
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
stack_max = 99,
|
||||
groups = f_groups,
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = box
|
||||
}
|
||||
})
|
||||
end
|
||||
|
||||
flowers.datas = {
|
||||
{"rose", "Rose", {-0.15, -0.5, -0.15, 0.15, 0.3, 0.15}, {color_red = 1}},
|
||||
{"tulip", "Orange Tulip", {-0.15, -0.5, -0.15, 0.15, 0.2, 0.15}, {color_orange = 1}},
|
||||
{"dandelion_yellow", "Yellow Dandelion", {-0.15, -0.5, -0.15, 0.15, 0.2, 0.15}, {color_yellow = 1}},
|
||||
{"geranium", "Blue Geranium", {-0.15, -0.5, -0.15, 0.15, 0.2, 0.15}, {color_blue = 1}},
|
||||
{"viola", "Viola", {-0.5, -0.5, -0.5, 0.5, -0.2, 0.5}, {color_violet = 1}},
|
||||
{"dandelion_white", "White dandelion", {-0.5, -0.5, -0.5, 0.5, -0.2, 0.5}, {color_white = 1}}
|
||||
}
|
||||
|
||||
for _,item in pairs(flowers.datas) do
|
||||
add_simple_flower(unpack(item))
|
||||
end
|
||||
|
||||
|
||||
-- Flower spread
|
||||
-- Public function to enable override by mods
|
||||
|
||||
function flowers.flower_spread(pos, node)
|
||||
pos.y = pos.y - 1
|
||||
local under = minetest.get_node(pos)
|
||||
pos.y = pos.y + 1
|
||||
if under.name == "default:desert_sand" then
|
||||
minetest.set_node(pos, {name = "default:dry_shrub"})
|
||||
return
|
||||
elseif under.name ~= "default:dirt_with_grass" and
|
||||
under.name ~= "default:dirt_with_dry_grass" then
|
||||
return
|
||||
end
|
||||
|
||||
local light = minetest.get_node_light(pos)
|
||||
if not light or light < 13 then
|
||||
return
|
||||
end
|
||||
|
||||
local pos0 = vector.subtract(pos, 4)
|
||||
local pos1 = vector.add(pos, 4)
|
||||
if #minetest.find_nodes_in_area(pos0, pos1, "group:flora") > 3 then
|
||||
return
|
||||
end
|
||||
|
||||
local seedling = minetest.find_nodes_in_area_under_air(pos0, pos1,
|
||||
{"default:dirt_with_grass", "default:dirt_with_dry_grass"})
|
||||
if #seedling > 0 then
|
||||
seedling = seedling[math.random(#seedling)]
|
||||
seedling.y = seedling.y + 1
|
||||
light = minetest.get_node_light(seedling)
|
||||
if not light or light < 13 then
|
||||
return
|
||||
end
|
||||
minetest.set_node(seedling, {name = node.name})
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"group:flora"},
|
||||
neighbors = {"default:dirt_with_grass", "default:dirt_with_dry_grass",
|
||||
"default:desert_sand"},
|
||||
interval = 13,
|
||||
chance = 96,
|
||||
action = function(...)
|
||||
flowers.flower_spread(...)
|
||||
end,
|
||||
})
|
||||
|
||||
|
||||
--
|
||||
-- Mushrooms
|
||||
--
|
||||
|
||||
minetest.register_node("flowers:mushroom_red", {
|
||||
description = "Red Mushroom",
|
||||
tiles = {"flowers_mushroom_red.png"},
|
||||
inventory_image = "flowers_mushroom_red.png",
|
||||
wield_image = "flowers_mushroom_red.png",
|
||||
drawtype = "plantlike",
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
groups = {snappy = 3, attached_node = 1},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
on_use = minetest.item_eat(-5),
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.3, -0.5, -0.3, 0.3, 0, 0.3}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_node("flowers:mushroom_brown", {
|
||||
description = "Brown Mushroom",
|
||||
tiles = {"flowers_mushroom_brown.png"},
|
||||
inventory_image = "flowers_mushroom_brown.png",
|
||||
wield_image = "flowers_mushroom_brown.png",
|
||||
drawtype = "plantlike",
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
groups = {snappy = 3, attached_node = 1},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
on_use = minetest.item_eat(1),
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.3, -0.5, -0.3, 0.3, 0, 0.3}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
-- Mushroom spread and death
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"flowers:mushroom_brown", "flowers:mushroom_red"},
|
||||
interval = 11,
|
||||
chance = 50,
|
||||
action = function(pos, node)
|
||||
if minetest.get_node_light(pos, nil) == 15 then
|
||||
minetest.remove_node(pos)
|
||||
return
|
||||
end
|
||||
local random = {
|
||||
x = pos.x + math.random(-2, 2),
|
||||
y = pos.y + math.random(-1, 1),
|
||||
z = pos.z + math.random(-2, 2)
|
||||
}
|
||||
local random_node = minetest.get_node_or_nil(random)
|
||||
if not random_node or random_node.name ~= "air" then
|
||||
return
|
||||
end
|
||||
local node_under = minetest.get_node_or_nil({x = random.x,
|
||||
y = random.y - 1, z = random.z})
|
||||
if not node_under then
|
||||
return
|
||||
end
|
||||
|
||||
if (minetest.get_item_group(node_under.name, "soil") ~= 0 or
|
||||
minetest.get_item_group(node_under.name, "tree") ~= 0) and
|
||||
minetest.get_node_light(pos, 0.5) <= 3 and
|
||||
minetest.get_node_light(random, 0.5) <= 3 then
|
||||
minetest.set_node(random, {name = node.name})
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
|
||||
-- These old mushroom related nodes can be simplified now
|
||||
|
||||
minetest.register_alias("flowers:mushroom_spores_brown", "flowers:mushroom_brown")
|
||||
minetest.register_alias("flowers:mushroom_spores_red", "flowers:mushroom_red")
|
||||
minetest.register_alias("flowers:mushroom_fertile_brown", "flowers:mushroom_brown")
|
||||
minetest.register_alias("flowers:mushroom_fertile_red", "flowers:mushroom_red")
|
||||
|
||||
|
||||
--
|
||||
-- Waterlily
|
||||
--
|
||||
|
||||
minetest.register_node("flowers:waterlily", {
|
||||
description = "Waterlily",
|
||||
drawtype = "nodebox",
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
tiles = {"flowers_waterlily.png"},
|
||||
inventory_image = "flowers_waterlily.png",
|
||||
wield_image = "flowers_waterlily.png",
|
||||
liquids_pointable = true,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
sunlight_propagates = true,
|
||||
groups = {snappy = 3, flower = 1},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
node_placement_prediction = "",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.5, -0.5, -0.5, 0.5, -0.46875, 0.5}
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.5, -0.5, -0.5, 0.5, -0.4375, 0.5}
|
||||
},
|
||||
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
local pos = pointed_thing.above
|
||||
local node = minetest.get_node(pointed_thing.under).name
|
||||
local def = minetest.registered_nodes[node]
|
||||
local player_name = placer:get_player_name()
|
||||
|
||||
if def and def.liquidtype == "source" and minetest.get_item_group(node, "water") > 0 then
|
||||
if not minetest.is_protected(pos, player_name) then
|
||||
minetest.set_node(pos, {name = "flowers:waterlily", param2 = math.random(0, 3)})
|
||||
else
|
||||
minetest.chat_send_player(player_name, "This area is protected")
|
||||
end
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
itemstack:take_item()
|
||||
return itemstack
|
||||
end
|
||||
end
|
||||
end
|
||||
})
|
|
@ -0,0 +1,173 @@
|
|||
--
|
||||
-- Mgv6
|
||||
--
|
||||
|
||||
local function register_mgv6_flower(name)
|
||||
minetest.register_decoration({
|
||||
deco_type = "simple",
|
||||
place_on = {"default:dirt_with_grass"},
|
||||
sidelen = 16,
|
||||
noise_params = {
|
||||
offset = 0,
|
||||
scale = 0.006,
|
||||
spread = {x = 100, y = 100, z = 100},
|
||||
seed = 436,
|
||||
octaves = 3,
|
||||
persist = 0.6
|
||||
},
|
||||
y_min = 1,
|
||||
y_max = 30,
|
||||
decoration = "flowers:"..name,
|
||||
})
|
||||
end
|
||||
|
||||
local function register_mgv6_mushroom(name)
|
||||
minetest.register_decoration({
|
||||
deco_type = "simple",
|
||||
place_on = {"default:dirt_with_grass"},
|
||||
sidelen = 16,
|
||||
noise_params = {
|
||||
offset = 0,
|
||||
scale = 0.04,
|
||||
spread = {x = 100, y = 100, z = 100},
|
||||
seed = 7133,
|
||||
octaves = 3,
|
||||
persist = 0.6
|
||||
},
|
||||
y_min = 1,
|
||||
y_max = 30,
|
||||
decoration = "flowers:"..name,
|
||||
spawn_by = "default:tree",
|
||||
num_spawn_by = 1,
|
||||
})
|
||||
end
|
||||
|
||||
local function register_mgv6_waterlily()
|
||||
minetest.register_decoration({
|
||||
deco_type = "schematic",
|
||||
place_on = {"default:dirt"},
|
||||
sidelen = 16,
|
||||
noise_params = {
|
||||
offset = -0.12,
|
||||
scale = 0.3,
|
||||
spread = {x = 100, y = 100, z = 100},
|
||||
seed = 33,
|
||||
octaves = 3,
|
||||
persist = 0.7
|
||||
},
|
||||
y_min = 0,
|
||||
y_max = 0,
|
||||
schematic = minetest.get_modpath("flowers").."/schematics/waterlily.mts",
|
||||
rotation = "random",
|
||||
})
|
||||
end
|
||||
|
||||
function flowers.register_mgv6_decorations()
|
||||
register_mgv6_flower("rose")
|
||||
register_mgv6_flower("tulip")
|
||||
register_mgv6_flower("dandelion_yellow")
|
||||
register_mgv6_flower("geranium")
|
||||
register_mgv6_flower("viola")
|
||||
register_mgv6_flower("dandelion_white")
|
||||
|
||||
register_mgv6_mushroom("mushroom_brown")
|
||||
register_mgv6_mushroom("mushroom_red")
|
||||
|
||||
register_mgv6_waterlily()
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- All other biome API mapgens
|
||||
--
|
||||
|
||||
local function register_flower(seed, name)
|
||||
minetest.register_decoration({
|
||||
deco_type = "simple",
|
||||
place_on = {"default:dirt_with_grass"},
|
||||
sidelen = 16,
|
||||
noise_params = {
|
||||
offset = -0.015,
|
||||
scale = 0.025,
|
||||
spread = {x = 200, y = 200, z = 200},
|
||||
seed = seed,
|
||||
octaves = 3,
|
||||
persist = 0.6
|
||||
},
|
||||
biomes = {"stone_grassland", "sandstone_grassland",
|
||||
"deciduous_forest", "coniferous_forest"},
|
||||
y_min = 1,
|
||||
y_max = 31000,
|
||||
decoration = "flowers:"..name,
|
||||
})
|
||||
end
|
||||
|
||||
local function register_mushroom(name)
|
||||
minetest.register_decoration({
|
||||
deco_type = "simple",
|
||||
place_on = {"default:dirt_with_grass"},
|
||||
sidelen = 16,
|
||||
noise_params = {
|
||||
offset = 0,
|
||||
scale = 0.006,
|
||||
spread = {x = 200, y = 200, z = 200},
|
||||
seed = 2,
|
||||
octaves = 3,
|
||||
persist = 0.66
|
||||
},
|
||||
biomes = {"deciduous_forest", "coniferous_forest"},
|
||||
y_min = 1,
|
||||
y_max = 31000,
|
||||
decoration = "flowers:"..name,
|
||||
})
|
||||
end
|
||||
|
||||
local function register_waterlily()
|
||||
minetest.register_decoration({
|
||||
deco_type = "schematic",
|
||||
place_on = {"default:dirt"},
|
||||
sidelen = 16,
|
||||
noise_params = {
|
||||
offset = -0.12,
|
||||
scale = 0.3,
|
||||
spread = {x = 200, y = 200, z = 200},
|
||||
seed = 33,
|
||||
octaves = 3,
|
||||
persist = 0.7
|
||||
},
|
||||
biomes = {"rainforest_swamp", "savanna_swamp", "deciduous_forest_swamp"},
|
||||
y_min = 0,
|
||||
y_max = 0,
|
||||
schematic = minetest.get_modpath("flowers").."/schematics/waterlily.mts",
|
||||
rotation = "random",
|
||||
})
|
||||
end
|
||||
|
||||
function flowers.register_decorations()
|
||||
register_flower(436, "rose")
|
||||
register_flower(19822, "tulip")
|
||||
register_flower(1220999, "dandelion_yellow")
|
||||
register_flower(36662, "geranium")
|
||||
register_flower(1133, "viola")
|
||||
register_flower(73133, "dandelion_white")
|
||||
|
||||
register_mushroom("mushroom_brown")
|
||||
register_mushroom("mushroom_red")
|
||||
|
||||
register_waterlily()
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Detect mapgen to select functions
|
||||
--
|
||||
|
||||
-- Mods using singlenode mapgen can call these functions to enable
|
||||
-- the use of minetest.generate_ores or minetest.generate_decorations
|
||||
|
||||
local mg_params = minetest.get_mapgen_params()
|
||||
if mg_params.mgname == "v6" then
|
||||
flowers.register_mgv6_decorations()
|
||||
elseif mg_params.mgname ~= "singlenode" then
|
||||
flowers.register_decorations()
|
||||
end
|
After Width: | Height: | Size: 142 B |
After Width: | Height: | Size: 133 B |
After Width: | Height: | Size: 163 B |
After Width: | Height: | Size: 155 B |
After Width: | Height: | Size: 167 B |
After Width: | Height: | Size: 136 B |
After Width: | Height: | Size: 143 B |
After Width: | Height: | Size: 153 B |
After Width: | Height: | Size: 3.3 KiB |
|
@ -0,0 +1,2 @@
|
|||
default
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
local stuff_string = minetest.setting_get("initial_stuff") or
|
||||
"default:pick_steel,default:axe_steel,default:shovel_steel," ..
|
||||
"default:torch 99,default:cobble 99"
|
||||
|
||||
give_initial_stuff = {
|
||||
items = {}
|
||||
}
|
||||
|
||||
function give_initial_stuff.give(player)
|
||||
minetest.log("action",
|
||||
"Giving initial stuff to player " .. player:get_player_name())
|
||||
local inv = player:get_inventory()
|
||||
for _, stack in ipairs(give_initial_stuff.items) do
|
||||
inv:add_item("main", stack)
|
||||
end
|
||||
end
|
||||
|
||||
function give_initial_stuff.add(stack)
|
||||
give_initial_stuff.items[#give_initial_stuff.items + 1] = ItemStack(stack)
|
||||
end
|
||||
|
||||
function give_initial_stuff.clear()
|
||||
give_initial_stuff.items = {}
|
||||
end
|
||||
|
||||
function give_initial_stuff.add_from_csv(str)
|
||||
local items = str:split(",")
|
||||
for _, itemname in ipairs(items) do
|
||||
give_initial_stuff.add(itemname)
|
||||
end
|
||||
end
|
||||
|
||||
function give_initial_stuff.set_list(list)
|
||||
give_initial_stuff.items = list
|
||||
end
|
||||
|
||||
function give_initial_stuff.get_list()
|
||||
return give_initial_stuff.items
|
||||
end
|
||||
|
||||
give_initial_stuff.add_from_csv(stuff_string)
|
||||
if minetest.setting_getbool("give_initial_stuff") then
|
||||
minetest.register_on_newplayer(give_initial_stuff.give)
|
||||
end
|