Update Trees and small fix

This commit is contained in:
Maksim 2019-05-08 22:18:59 +02:00
parent 416bfee23d
commit 1693f1792f
37 changed files with 832 additions and 448 deletions

View File

@ -212,15 +212,29 @@ core.register_entity(":__builtin:item", {
end end
end end
local nn = node and node.name or "" if minetest.get_item_group(node.name, "lava") > 0 then
if nn == "default:lava_flowing" or nn == "default:lava_source" then
minetest.sound_play("default_cool_lava", { minetest.sound_play("default_cool_lava", {
pos=self.object:getpos(), pos = self.object:get_pos(),
max_hear_distance = 6, max_hear_distance = 8,
gain = 0.5
}) })
self.object:remove() self.object:remove()
return return
minetest.add_particlespawner({
amount = 3,
time = 0.1,
minpos = {x = p.x - 0.1, y = p.y + 0.1, z = p.z - 0.1 },
maxpos = {x = p.x + 0.1, y = p.y + 0.2, z = p.z + 0.1 },
minvel = {x = 0, y = 2.5, z = 0},
maxvel = {x = 0, y = 2.5, z = 0},
minacc = {x = -0.15, y = -0.02, z = -0.15},
maxacc = {x = 0.15, y = -0.01, z = 0.15},
minexptime = 4,
maxexptime = 6,
minsize = 2,
maxsize = 4,
collisiondetection = true,
texture = "item_smoke.png"
})
end end
end, end,

View File

@ -554,4 +554,3 @@ minetest.register_on_player_hpchange(function(player, hp_change)
end end
return hp_change return hp_change
end) end)

View File

@ -1,5 +1,3 @@
ARMOR_MOD_NAME = minetest.get_current_modname() ARMOR_MOD_NAME = minetest.get_current_modname()
dofile(minetest.get_modpath(minetest.get_current_modname()).."/armor.lua") dofile(minetest.get_modpath(minetest.get_current_modname()).."/armor.lua")
@ -193,5 +191,3 @@ for k, v in pairs(craft_ingreds) do
}, },
}) })
end end

View File

@ -6,7 +6,3 @@ Authors of source code
---------------------- ----------------------
Originally by Perttu Ahola (celeron55) <celeron55@gmail.com> (MIT) Originally by Perttu Ahola (celeron55) <celeron55@gmail.com> (MIT)
Jean-Patrick G. (kilbith) <jeanpatrick.guerrero@gmail.com> (MIT) Jean-Patrick G. (kilbith) <jeanpatrick.guerrero@gmail.com> (MIT)
Author of media (textures)
--------------------------
Jean-Patrick G. (kilbith) <jeanpatrick.guerrero@gmail.com> (CC BY-SA 3.0)

View File

@ -21,7 +21,7 @@ if creative_mode_cache then
minetest.register_item(":", { minetest.register_item(":", {
type = "none", type = "none",
wield_image = "wieldhand.png", wield_image = "wieldhand.png",
wield_scale = {x = 0.7, y = 2, z = 0}, wield_scale = {x = 0.7, y = 2, z = 0},
range = 10, range = 10,
tool_capabilities = { tool_capabilities = {
full_punch_interval = 0.9, full_punch_interval = 0.9,
@ -60,4 +60,4 @@ function minetest.handle_node_drops(pos, drops, digger)
end end
end end
end end
end end

View File

@ -1,5 +1,3 @@
-- mods/default/functions.lua
-- --
-- Sounds -- Sounds
-- --
@ -18,7 +16,7 @@ end
function default.node_sound_stone_defaults(table) function default.node_sound_stone_defaults(table)
table = table or {} table = table or {}
table.footstep = table.footstep or table.footstep = table.footstep or
{name = "default_hard_footstep", gain = 0.5} {name = "default_hard_footstep", gain = 0.3}
table.dug = table.dug or table.dug = table.dug or
{name = "default_hard_footstep", gain = 1.0} {name = "default_hard_footstep", gain = 1.0}
default.node_sound_defaults(table) default.node_sound_defaults(table)
@ -28,9 +26,9 @@ end
function default.node_sound_dirt_defaults(table) function default.node_sound_dirt_defaults(table)
table = table or {} table = table or {}
table.footstep = table.footstep or table.footstep = table.footstep or
{name = "default_dirt_footstep", gain = 1.0} {name = "default_dirt_footstep", gain = 0.4}
table.dug = table.dug or table.dug = table.dug or
{name = "default_dirt_footstep", gain = 1.5} {name = "default_dirt_footstep", gain = 1.0}
table.place = table.place or table.place = table.place or
{name = "default_place_node", gain = 1.0} {name = "default_place_node", gain = 1.0}
default.node_sound_defaults(table) default.node_sound_defaults(table)
@ -40,7 +38,7 @@ end
function default.node_sound_sand_defaults(table) function default.node_sound_sand_defaults(table)
table = table or {} table = table or {}
table.footstep = table.footstep or table.footstep = table.footstep or
{name = "default_sand_footstep", gain = 0.2} {name = "default_sand_footstep", gain = 0.12}
table.dug = table.dug or table.dug = table.dug or
{name = "default_sand_footstep", gain = 0.4} {name = "default_sand_footstep", gain = 0.4}
table.place = table.place or table.place = table.place or
@ -52,7 +50,7 @@ end
function default.node_sound_wood_defaults(table) function default.node_sound_wood_defaults(table)
table = table or {} table = table or {}
table.footstep = table.footstep or table.footstep = table.footstep or
{name = "default_wood_footstep", gain = 0.5} {name = "default_wood_footstep", gain = 0.3}
table.dug = table.dug or table.dug = table.dug or
{name = "default_wood_footstep", gain = 1.0} {name = "default_wood_footstep", gain = 1.0}
default.node_sound_defaults(table) default.node_sound_defaults(table)
@ -62,11 +60,9 @@ end
function default.node_sound_leaves_defaults(table) function default.node_sound_leaves_defaults(table)
table = table or {} table = table or {}
table.footstep = table.footstep or table.footstep = table.footstep or
{name = "default_grass_footstep", gain = 0.35} {name = "default_grass_footstep", gain = 0.45}
table.dug = table.dug or table.dug = table.dug or
{name = "default_grass_footstep", gain = 0.7} {name = "default_grass_footstep", gain = 0.7}
table.dig = table.dig or
{name = "default_dig_crumbly", gain = 0.4}
table.place = table.place or table.place = table.place or
{name = "default_place_node", gain = 1.0} {name = "default_place_node", gain = 1.0}
default.node_sound_defaults(table) default.node_sound_defaults(table)
@ -76,6 +72,8 @@ end
function default.node_sound_glass_defaults(table) function default.node_sound_glass_defaults(table)
table = table or {} table = table or {}
table.footstep = table.footstep or table.footstep = table.footstep or
{name = "default_glass_footstep", gain = 0.3}
table.dig = table.dig or
{name = "default_glass_footstep", gain = 0.5} {name = "default_glass_footstep", gain = 0.5}
table.dug = table.dug or table.dug = table.dug or
{name = "default_break_glass", gain = 1.0} {name = "default_break_glass", gain = 1.0}
@ -83,6 +81,20 @@ function default.node_sound_glass_defaults(table)
return table return table
end end
function default.node_sound_metal_defaults(table)
table = table or {}
table.footstep = table.footstep or
{name = "default_metal_footstep", gain = 0.4}
table.dig = table.dig or
{name = "default_dig_metal", gain = 0.5}
table.dug = table.dug or
{name = "default_dug_metal", gain = 0.5}
table.place = table.place or
{name = "default_place_node_metal", gain = 0.5}
default.node_sound_defaults(table)
return table
end
function default.node_sound_water_defaults(table) function default.node_sound_water_defaults(table)
table = table or {} table = table or {}
table.footstep = table.footstep or table.footstep = table.footstep or
@ -91,50 +103,72 @@ function default.node_sound_water_defaults(table)
return table return table
end end
function default.node_sound_snow_defaults(table)
table = table or {}
table.footstep = table.footstep or
{name = "default_snow_footstep", gain = 0.2}
table.dig = table.dig or
{name = "default_snow_footstep", gain = 0.3}
table.dug = table.dug or
{name = "default_snow_footstep", gain = 0.3}
table.place = table.place or
{name = "default_place_node", gain = 1.0}
default.node_sound_defaults(table)
return table
end
-- --
-- Lavacooling -- Lavacooling
-- --
default.cool_lava_source = function(pos) default.cool_lava = function(pos, node)
minetest.set_node(pos, {name = "default:obsidian"}) if node.name == "default:lava_source" then
minetest.set_node(pos, {name = "default:obsidian"})
else -- Lava flowing
minetest.set_node(pos, {name = "default:stone"})
end
minetest.sound_play("default_cool_lava", minetest.sound_play("default_cool_lava",
{pos = pos, max_hear_distance = 16, gain = 0.25}) {pos = pos, max_hear_distance = 16, gain = 0.25})
end end
default.cool_lava_flowing = function(pos) if minetest.settings:get_bool("enable_lavacooling") ~= false then
minetest.set_node(pos, {name = "default:stone"}) minetest.register_abm({
minetest.sound_play("default_cool_lava", label = "Lava cooling",
{pos = pos, max_hear_distance = 16, gain = 0.25}) nodenames = {"default:lava_source", "default:lava_flowing"},
neighbors = {"group:cools_lava", "group:water"},
interval = 2,
chance = 2,
catch_up = false,
action = function(...)
default.cool_lava(...)
end,
})
end end
minetest.register_abm({
nodenames = {"default:lava_flowing"},
neighbors = {"group:water"},
interval = 1,
chance = 2,
catch_up = false,
action = function(...)
default.cool_lava_flowing(...)
end,
})
minetest.register_abm({ --
nodenames = {"default:lava_source"}, -- Optimized helper to put all items in an inventory into a drops list
neighbors = {"group:water"}, --
interval = 1,
chance = 2, function default.get_inventory_drops(pos, inventory, drops)
catch_up = false, local inv = minetest.get_meta(pos):get_inventory()
action = function(...) local n = #drops
default.cool_lava_source(...) for i = 1, inv:get_size(inventory) do
end, local stack = inv:get_stack(inventory, i)
}) if stack:get_count() > 0 then
drops[n+1] = stack:to_table()
n = n + 1
end
end
end
-- --
-- Papyrus and cactus growing -- Papyrus and cactus growing
-- --
-- wrapping the functions in abm action is necessary to make overriding them possible -- Wrapping the functions in ABM action is necessary to make overriding them possible
function default.grow_cactus(pos, node) function default.grow_cactus(pos, node)
if node.param2 >= 4 then if node.param2 >= 4 then
@ -154,6 +188,9 @@ function default.grow_cactus(pos, node)
if height == 4 or node.name ~= "air" then if height == 4 or node.name ~= "air" then
return return
end end
if minetest.get_node_light(pos) < 13 then
return
end
minetest.set_node(pos, {name = "default:cactus"}) minetest.set_node(pos, {name = "default:cactus"})
return true return true
end end
@ -177,25 +214,30 @@ function default.grow_papyrus(pos, node)
if height == 4 or node.name ~= "air" then if height == 4 or node.name ~= "air" then
return return
end end
if minetest.get_node_light(pos) < 13 then
return
end
minetest.set_node(pos, {name = "default:papyrus"}) minetest.set_node(pos, {name = "default:papyrus"})
return true return true
end end
minetest.register_abm({ minetest.register_abm({
label = "Grow cactus",
nodenames = {"default:cactus"}, nodenames = {"default:cactus"},
neighbors = {"group:sand"}, neighbors = {"group:sand"},
interval = 50, interval = 12,
chance = 20, chance = 83,
action = function(...) action = function(...)
default.grow_cactus(...) default.grow_cactus(...)
end end
}) })
minetest.register_abm({ minetest.register_abm({
label = "Grow papyrus",
nodenames = {"default:papyrus"}, nodenames = {"default:papyrus"},
neighbors = {"default:dirt", "default:dirt_with_grass", "default:sand"}, neighbors = {"default:dirt", "default:dirt_with_grass", "default:sand"},
interval = 50, interval = 14,
chance = 20, chance = 71,
action = function(...) action = function(...)
default.grow_papyrus(...) default.grow_papyrus(...)
end end
@ -203,7 +245,7 @@ minetest.register_abm({
-- --
-- dig upwards -- Dig upwards
-- --
function default.dig_up(pos, node, digger) function default.dig_up(pos, node, digger)
@ -216,182 +258,259 @@ function default.dig_up(pos, node, digger)
end end
--
-- Fence registration helper
--
function default.register_fence(name, def)
minetest.register_craft({
output = name .. " 4",
recipe = {
{ def.material, 'group:stick', def.material },
{ def.material, 'group:stick', def.material },
}
})
local fence_texture = "default_fence_overlay.png^" .. def.texture ..
"^default_fence_overlay.png^[makealpha:255,126,126"
-- Allow almost everything to be overridden
local default_fields = {
paramtype = "light",
drawtype = "nodebox",
node_box = {
type = "connected",
fixed = {{-1/8, -1/2, -1/8, 1/8, 1/2, 1/8}},
-- connect_top =
-- connect_bottom =
connect_front = {{-1/16,3/16,-1/2,1/16,5/16,-1/8},
{-1/16,-5/16,-1/2,1/16,-3/16,-1/8}},
connect_left = {{-1/2,3/16,-1/16,-1/8,5/16,1/16},
{-1/2,-5/16,-1/16,-1/8,-3/16,1/16}},
connect_back = {{-1/16,3/16,1/8,1/16,5/16,1/2},
{-1/16,-5/16,1/8,1/16,-3/16,1/2}},
connect_right = {{1/8,3/16,-1/16,1/2,5/16,1/16},
{1/8,-5/16,-1/16,1/2,-3/16,1/16}},
},
connects_to = {"group:fence", "group:wood", "group:tree", "group:wall"},
inventory_image = fence_texture,
wield_image = fence_texture,
tiles = {def.texture},
sunlight_propagates = true,
is_ground_content = false,
groups = {},
}
for k, v in pairs(default_fields) do
if def[k] == nil then
def[k] = v
end
end
-- Always add to the fence group, even if no group provided
def.groups.fence = 1
def.texture = nil
def.material = nil
minetest.register_node(name, def)
end
--
-- Fence rail registration helper
--
function default.register_fence_rail(name, def)
minetest.register_craft({
output = name .. " 16",
recipe = {
{ def.material, def.material },
{ "", ""},
{ def.material, def.material },
}
})
local fence_rail_texture = "default_fence_rail_overlay.png^" .. def.texture ..
"^default_fence_rail_overlay.png^[makealpha:255,126,126"
-- Allow almost everything to be overridden
local default_fields = {
paramtype = "light",
drawtype = "nodebox",
node_box = {
type = "connected",
fixed = {
{-1/16, 3/16, -1/16, 1/16, 5/16, 1/16},
{-1/16, -3/16, -1/16, 1/16, -5/16, 1/16}
},
-- connect_top =
-- connect_bottom =
connect_front = {
{-1/16, 3/16, -1/2, 1/16, 5/16, -1/16},
{-1/16, -5/16, -1/2, 1/16, -3/16, -1/16}},
connect_left = {
{-1/2, 3/16, -1/16, -1/16, 5/16, 1/16},
{-1/2, -5/16, -1/16, -1/16, -3/16, 1/16}},
connect_back = {
{-1/16, 3/16, 1/16, 1/16, 5/16, 1/2},
{-1/16, -5/16, 1/16, 1/16, -3/16, 1/2}},
connect_right = {
{1/16, 3/16, -1/16, 1/2, 5/16, 1/16},
{1/16, -5/16, -1/16, 1/2, -3/16, 1/16}},
},
connects_to = {"group:fence", "group:wall"},
inventory_image = fence_rail_texture,
wield_image = fence_rail_texture,
tiles = {def.texture},
sunlight_propagates = true,
is_ground_content = false,
groups = {},
}
for k, v in pairs(default_fields) do
if def[k] == nil then
def[k] = v
end
end
-- Always add to the fence group, even if no group provided
def.groups.fence = 1
def.texture = nil
def.material = nil
minetest.register_node(name, def)
end
-- --
-- Leafdecay -- Leafdecay
-- --
default.leafdecay_trunk_cache = {} -- Prevent decay of placed leaves
default.leafdecay_enable_cache = true
-- Spread the load of finding trunks
default.leafdecay_trunk_find_allow_accumulator = 0
minetest.register_globalstep(function(dtime)
local finds_per_second = 5000
default.leafdecay_trunk_find_allow_accumulator =
math.floor(dtime * finds_per_second)
end)
default.after_place_leaves = function(pos, placer, itemstack, pointed_thing) default.after_place_leaves = function(pos, placer, itemstack, pointed_thing)
local node = minetest.get_node(pos) if placer and placer:is_player() and not placer:get_player_control().sneak then
node.param2 = 1 local node = minetest.get_node(pos)
minetest.set_node(pos, node) node.param2 = 1
minetest.set_node(pos, node)
end
end end
minetest.register_abm({ -- Leafdecay
nodenames = {"group:leafdecay"}, local function leafdecay_after_destruct(pos, oldnode, def)
neighbors = {"air", "group:liquid"}, for _, v in pairs(minetest.find_nodes_in_area(vector.subtract(pos, def.radius),
-- A low interval and a high inverse chance spreads the load vector.add(pos, def.radius), def.leaves)) do
interval = 2, local node = minetest.get_node(v)
chance = 5, local timer = minetest.get_node_timer(v)
if node.param2 == 0 and not timer:is_started() then
action = function(p0, node, _, _) timer:start(math.random(20, 120) / 10)
--print("leafdecay ABM at "..p0.x..", "..p0.y..", "..p0.z..")")
local do_preserve = false
local d = minetest.registered_nodes[node.name].groups.leafdecay
if not d or d == 0 then
--print("not groups.leafdecay")
return
end
local n0 = minetest.get_node(p0)
if n0.param2 ~= 0 then
--print("param2 ~= 0")
return
end
local p0_hash = nil
if default.leafdecay_enable_cache then
p0_hash = minetest.hash_node_position(p0)
local trunkp = default.leafdecay_trunk_cache[p0_hash]
if trunkp then
local n = minetest.get_node(trunkp)
local reg = minetest.registered_nodes[n.name]
-- Assume ignore is a trunk, to make the thing
-- work at the border of the active area
if n.name == "ignore" or (reg and reg.groups.tree and
reg.groups.tree ~= 0) then
--print("cached trunk still exists")
return
end
--print("cached trunk is invalid")
-- Cache is invalid
table.remove(default.leafdecay_trunk_cache, p0_hash)
end
end
if default.leafdecay_trunk_find_allow_accumulator <= 0 then
return
end
default.leafdecay_trunk_find_allow_accumulator =
default.leafdecay_trunk_find_allow_accumulator - 1
-- Assume ignore is a trunk, to make the thing
-- work at the border of the active area
local p1 = minetest.find_node_near(p0, d, {"ignore", "group:tree"})
if p1 then
do_preserve = true
if default.leafdecay_enable_cache then
--print("caching trunk")
-- Cache the trunk
default.leafdecay_trunk_cache[p0_hash] = p1
end
end
if not do_preserve then
-- Drop stuff other than the node itself
local itemstacks = minetest.get_node_drops(n0.name)
for _, itemname in ipairs(itemstacks) do
if minetest.get_item_group(n0.name, "leafdecay_drop") ~= 0 or
itemname ~= n0.name then
local p_drop = {
x = p0.x - 0.5 + math.random(),
y = p0.y - 0.5 + math.random(),
z = p0.z - 0.5 + math.random(),
}
minetest.add_item(p_drop, itemname)
end
end
-- Remove node
minetest.remove_node(p0)
nodeupdate(p0)
end end
end end
}) end
local function leafdecay_on_timer(pos, def)
if minetest.find_node_near(pos, def.radius, def.trunks) then
return false
end
local node = minetest.get_node(pos)
local drops = minetest.get_node_drops(node.name)
for _, item in ipairs(drops) do
local is_leaf
for _, v in pairs(def.leaves) do
if v == item then
is_leaf = true
end
end
if minetest.get_item_group(item, "leafdecay_drop") ~= 0 or
not is_leaf then
minetest.add_item({
x = pos.x - 0.5 + math.random(),
y = pos.y - 0.5 + math.random(),
z = pos.z - 0.5 + math.random(),
}, item)
end
end
minetest.remove_node(pos)
minetest.check_for_falling(pos)
end
function default.register_leafdecay(def)
assert(def.leaves)
assert(def.trunks)
assert(def.radius)
for _, v in pairs(def.trunks) do
minetest.override_item(v, {
after_destruct = function(pos, oldnode)
leafdecay_after_destruct(pos, oldnode, def)
end,
})
end
for _, v in pairs(def.leaves) do
minetest.override_item(v, {
on_timer = function(pos)
leafdecay_on_timer(pos, def)
end,
})
end
end
-- --
-- Grass growing on well-lit dirt -- Convert dirt to something that fits the environment
-- --
minetest.register_abm({ minetest.register_abm({
label = "Grass spread",
nodenames = {"default:dirt"}, nodenames = {"default:dirt"},
interval = 2, neighbors = {
chance = 200, "air",
"group:grass",
"group:dry_grass",
"default:snow",
},
interval = 6,
chance = 50,
catch_up = false, catch_up = false,
action = function(pos, node) action = function(pos, node)
-- Check for darkness: night, shadow or under a light-blocking node
-- Returns if ignore above
local above = {x = pos.x, y = pos.y + 1, z = pos.z} local above = {x = pos.x, y = pos.y + 1, z = pos.z}
if (minetest.get_node_light(above) or 0) < 13 then
return
end
-- Look for spreading dirt-type neighbours
local p2 = minetest.find_node_near(pos, 1, "group:spreading_dirt_type")
if p2 then
local n3 = minetest.get_node(p2)
minetest.set_node(pos, {name = n3.name})
return
end
-- Else, any seeding nodes on top?
local name = minetest.get_node(above).name local name = minetest.get_node(above).name
local nodedef = minetest.registered_nodes[name] -- Snow check is cheapest, so comes first
if nodedef and (nodedef.sunlight_propagates or nodedef.paramtype == "light") and if name == "default:snow" then
nodedef.liquidtype == "none" and minetest.set_node(pos, {name = "default:dirt_with_snow"})
(minetest.get_node_light(above) or 0) >= 13 then -- Most likely case first
if name == "default:snow" or name == "default:snowblock" then elseif minetest.get_item_group(name, "grass") ~= 0 then
minetest.set_node(pos, {name = "default:dirt_with_snow"}) minetest.set_node(pos, {name = "default:dirt_with_grass"})
else elseif minetest.get_item_group(name, "dry_grass") ~= 0 then
minetest.set_node(pos, {name = "default:dirt_with_grass"}) minetest.set_node(pos, {name = "default:dirt_with_dry_grass"})
end
end end
end end
}) })
--
-- Snowballs
--
snowball_GRAVITY=9
snowball_VELOCITY=19
--Shoot snowball.
snow_shoot_snowball=function (item, player, pointed_thing)
local playerpos=player:get_pos()
local obj=minetest.add_entity({x=playerpos.x,y=playerpos.y+1.5,z=playerpos.z}, "default:snowball_entity")
local dir=player:get_look_dir()
obj:setvelocity({x=dir.x*snowball_VELOCITY, y=dir.y*snowball_VELOCITY, z=dir.z*snowball_VELOCITY})
obj:set_acceleration({x=dir.x*-3, y=-snowball_GRAVITY, z=dir.z*-3})
item:take_item()
return item
end
--The snowball Entity
snowball_ENTITY={
physical = false,
timer=0,
textures = {"default_snowball.png"},
lastpos={},
collisionbox = {0,0,0,0,0,0},
}
--Snowball_entity.on_step()--> called when snowball is moving.
snowball_ENTITY.on_step = function(self, dtime)
self.timer=self.timer+dtime
local pos = self.object:getpos()
local node = minetest.get_node(pos)
--Become item when hitting a node.
if self.lastpos.x~=nil then --If there is no lastpos for some reason.
if node.name ~= "air" then
self.object:remove()
end
end
self.lastpos={x=pos.x, y=pos.y, z=pos.z} -- Set lastpos-->Node will be added at last pos outside the node
end
minetest.register_entity("default:snowball_entity", snowball_ENTITY)
-- --
-- Grass and dry grass removed in darkness -- Grass and dry grass removed in darkness
-- --
minetest.register_abm({ minetest.register_abm({
nodenames = {"default:dirt_with_grass", "default:dirt_with_dry_grass"}, label = "Grass covered",
interval = 2, nodenames = {"group:spreading_dirt_type"},
chance = 20, interval = 8,
chance = 50,
catch_up = false, catch_up = false,
action = function(pos, node) action = function(pos, node)
local above = {x = pos.x, y = pos.y + 1, z = pos.z} local above = {x = pos.x, y = pos.y + 1, z = pos.z}
@ -410,37 +529,67 @@ minetest.register_abm({
-- Moss growth on cobble near water -- Moss growth on cobble near water
-- --
local moss_correspondences = {
["default:cobble"] = "default:mossycobble",
-- ["stairs:slab_cobble"] = "stairs:slab_mossycobble",
-- ["stairs:stair_cobble"] = "stairs:stair_mossycobble",
-- ["stairs:stair_inner_cobble"] = "stairs:stair_inner_mossycobble",
-- ["stairs:stair_outer_cobble"] = "stairs:stair_outer_mossycobble",
-- ["walls:cobble"] = "walls:mossycobble",
}
minetest.register_abm({ minetest.register_abm({
nodenames = {"default:cobble"}, label = "Moss growth",
nodenames = {"default:cobble", "stairs:slab_cobble", "stairs:stair_cobble",
"stairs:stair_inner_cobble", "stairs:stair_outer_cobble",
"walls:cobble"},
neighbors = {"group:water"}, neighbors = {"group:water"},
interval = 17, interval = 16,
chance = 200, chance = 200,
catch_up = false, catch_up = false,
action = function(pos, node) action = function(pos, node)
minetest.set_node(pos, {name = "default:mossycobble"}) node.name = moss_correspondences[node.name]
minetest.set_node(pos, node)
end end
}) })
------------------------ --
-- Create Color Glass -- -- Snowballs
------------------------ --
function AddGlass(desc, recipeitem, color)
minetest.register_node("default:glass"..color, { -- Shoot snowball
description = desc, snow_shoot_snowball = function (item, player, pointed_thing)
drawtype = "glasslike", local playerpos = player:get_pos()
tiles = {"xpanes_pane_glass"..color..".png"}, local obj = minetest.add_entity({x = playerpos.x, y = playerpos.y + 1.5, z = playerpos.z}, "default:snowball_entity")
paramtype = "light", local dir = player:get_look_dir()
use_texture_alpha = true, obj:setvelocity({x = dir.x * 19, y = dir.y * 19, z = dir.z * 19})
groups = {cracky=3, oddly_breakable_by_hand = 3, building = 1}, obj:set_acceleration({x = dir.x * -3, y = -9.81, z = dir.z * -3})
sounds = default.node_sound_glass_defaults(), item:take_item()
drop = "", return item
}) end
minetest.register_craft({ -- Snowball entity
output = 'default:glass_'..color..'', snowball_ENTITY = {
recipe = { physical = false,
{'default:glass', 'group:dye,'..recipeitem} textures = "default_snowball.png",
} lastpos = "",
}) collisionbox = {0,0,0,0,0,0},
end }
-- Called when snowball is moving.
snowball_ENTITY.on_step = function(self, dtime)
self.timer = self.timer+dtime
local pos = self.object:getpos()
local node = minetest.get_node(pos)
-- Become item when hitting a node.
-- If there is no lastpos for some reason.
if self.lastpos.x ~= nil then
if node.name ~= "air" then
self.object:remove()
end
end
-- Node will be added at last pos outside the node
self.lastpos = {x = pos.x, y = pos.y, z = pos.z}
end
minetest.register_entity("default:snowball_entity", snowball_ENTITY)

View File

@ -22,6 +22,7 @@ dofile(default_path.."/crafting.lua")
dofile(default_path.."/mapgen.lua") dofile(default_path.."/mapgen.lua")
dofile(default_path.."/aliases.lua") dofile(default_path.."/aliases.lua")
dofile(default_path.."/workbench.lua") dofile(default_path.."/workbench.lua")
dofile(default_path.."/torch.lua")
if not minetest.setting_getbool("creative_mode") then if not minetest.setting_getbool("creative_mode") then
minetest.register_on_newplayer(function (player) minetest.register_on_newplayer(function (player)

View File

@ -997,66 +997,185 @@ end
function default.register_decorations() function default.register_decorations()
minetest.clear_registered_decorations() minetest.clear_registered_decorations()
-- Apple tree -- Apple tree and log
minetest.register_decoration({ minetest.register_decoration({
name = "default:apple_tree",
deco_type = "schematic", deco_type = "schematic",
place_on = {"default:dirt_with_grass"}, place_on = {"default:dirt_with_grass"},
sidelen = 16, sidelen = 16,
noise_params = { noise_params = {
offset = 0.04, offset = 0.024,
scale = 0.02, scale = 0.015,
spread = {x = 250, y = 250, z = 250}, spread = {x = 250, y = 250, z = 250},
seed = 2, seed = 2,
octaves = 3, octaves = 3,
persist = 0.66 persist = 0.66
}, },
biomes = {"deciduous_forest"}, biomes = {"deciduous_forest"},
y_max = 31000,
y_min = 1, y_min = 1,
y_max = 31000, schematic = minetest.get_modpath("default") .. "/schematics/apple_tree.mts",
schematic = minetest.get_modpath("default").."/schematics/apple_tree.mts",
flags = "place_center_x, place_center_z",
})
-- Jungle tree
minetest.register_decoration({
deco_type = "schematic",
place_on = {"default:dirt_with_grass", "default:dirt"},
sidelen = 80,
fill_ratio = 0.09,
biomes = {"rainforest", "rainforest_swamp"},
y_min = 0,
y_max = 31000,
schematic = minetest.get_modpath("default").."/schematics/jungle_tree.mts",
flags = "place_center_x, place_center_z", flags = "place_center_x, place_center_z",
rotation = "random", rotation = "random",
}) })
-- Taiga and temperate coniferous forest pine tree
minetest.register_decoration({ minetest.register_decoration({
name = "default:apple_log",
deco_type = "schematic", deco_type = "schematic",
place_on = {"default:dirt_with_snow", "default:dirt_with_grass"}, place_on = {"default:dirt_with_grass"},
place_offset_y = 1,
sidelen = 16, sidelen = 16,
noise_params = { noise_params = {
offset = 0.04, offset = 0.0012,
scale = 0.02, scale = 0.0007,
spread = {x = 250, y = 250, z = 250}, spread = {x = 250, y = 250, z = 250},
seed = 2, seed = 2,
octaves = 3, octaves = 3,
persist = 0.66 persist = 0.66
}, },
biomes = {"taiga", "coniferous_forest"}, biomes = {"deciduous_forest"},
y_min = 2,
y_max = 31000, y_max = 31000,
schematic = minetest.get_modpath("default").."/schematics/pine_tree.mts", y_min = 1,
schematic = minetest.get_modpath("default") .. "/schematics/apple_log.mts",
flags = "place_center_x",
rotation = "random",
spawn_by = "default:dirt_with_grass",
num_spawn_by = 8,
})
-- Emergent jungle tree
-- Due to 32 node height, altitude is limited and prescence depends on chunksize
local chunksize = tonumber(minetest.get_mapgen_setting("chunksize"))
if chunksize >= 5 then
minetest.register_decoration({
name = "default:emergent_jungle_tree",
deco_type = "schematic",
-- place_on = {"default:dirt_with_rainforest_litter"},
place_on = {"default:dirt_with_grass", "default:dirt"},
sidelen = 80,
noise_params = {
offset = 0.0,
scale = 0.0025,
spread = {x = 250, y = 250, z = 250},
seed = 2685,
octaves = 3,
persist = 0.7
},
biomes = {"rainforest"},
y_max = 32,
y_min = 1,
schematic = minetest.get_modpath("default") ..
"/schematics/emergent_jungle_tree.mts",
flags = "place_center_x, place_center_z",
rotation = "random",
place_offset_y = -4,
})
end
-- Jungle tree and log
minetest.register_decoration({
name = "default:jungle_tree",
deco_type = "schematic",
-- place_on = {"default:dirt_with_rainforest_litter", "default:dirt"},
place_on = {"default:dirt_with_grass", "default:dirt"},
sidelen = 80,
fill_ratio = 0.1,
biomes = {"rainforest", "rainforest_swamp"},
y_max = 31000,
y_min = -1,
schematic = minetest.get_modpath("default") .. "/schematics/jungle_tree.mts",
flags = "place_center_x, place_center_z", flags = "place_center_x, place_center_z",
rotation = "random",
})
minetest.register_decoration({
name = "default:jungle_log",
deco_type = "schematic",
-- place_on = {"default:dirt_with_rainforest_litter"},
place_on = {"default:dirt_with_grass", "default:dirt"},
place_offset_y = 1,
sidelen = 80,
fill_ratio = 0.005,
biomes = {"rainforest", "rainforest_swamp"},
y_max = 31000,
y_min = 1,
schematic = minetest.get_modpath("default") .. "/schematics/jungle_log.mts",
flags = "place_center_x",
rotation = "random",
--spawn_by = "default:dirt_with_rainforest_litter",
num_spawn_by = 8,
})
-- Taiga and temperate coniferous forest pine tree, small pine tree and log
minetest.register_decoration({
name = "default:pine_tree",
deco_type = "schematic",
-- place_on = {"default:dirt_with_snow", "default:dirt_with_coniferous_litter"},
place_on = {"default:dirt_with_snow", "default:dirt_with_grass"},
sidelen = 16,
noise_params = {
offset = 0.010,
scale = 0.048,
spread = {x = 250, y = 250, z = 250},
seed = 2,
octaves = 3,
persist = 0.66
},
biomes = {"taiga", "coniferous_forest", "floatland_coniferous_forest"},
y_max = 31000,
y_min = 4,
schematic = minetest.get_modpath("default") .. "/schematics/pine_tree.mts",
flags = "place_center_x, place_center_z",
})
minetest.register_decoration({
name = "default:small_pine_tree",
deco_type = "schematic",
-- place_on = {"default:dirt_with_snow", "default:dirt_with_coniferous_litter"},
place_on = {"default:dirt_with_snow", "default:dirt_with_grass"},
sidelen = 16,
noise_params = {
offset = 0.010,
scale = -0.048,
spread = {x = 250, y = 250, z = 250},
seed = 2,
octaves = 3,
persist = 0.66
},
biomes = {"taiga", "coniferous_forest", "floatland_coniferous_forest"},
y_max = 31000,
y_min = 4,
schematic = minetest.get_modpath("default") .. "/schematics/small_pine_tree.mts",
flags = "place_center_x, place_center_z",
})
minetest.register_decoration({
name = "default:pine_log",
deco_type = "schematic",
-- place_on = {"default:dirt_with_snow", "default:dirt_with_coniferous_litter"},
place_on = {"default:dirt_with_snow", "default:dirt_with_grass"},
place_offset_y = 1,
sidelen = 80,
fill_ratio = 0.0018,
biomes = {"taiga", "coniferous_forest", "floatland_coniferous_forest"},
y_max = 31000,
y_min = 4,
schematic = minetest.get_modpath("default") .. "/schematics/pine_log.mts",
flags = "place_center_x",
rotation = "random",
-- spawn_by = {"default:dirt_with_snow", "default:dirt_with_coniferous_litter"},
spawn_by = {"default:dirt_with_snow", "default:dirt_with_grass"},
num_spawn_by = 8,
}) })
-- Acacia tree -- Acacia tree
minetest.register_decoration({ minetest.register_decoration({
name = "default:acacia_tree",
deco_type = "schematic", deco_type = "schematic",
place_on = {"default:dirt_with_dry_grass"}, place_on = {"default:dirt_with_dry_grass"},
sidelen = 16, sidelen = 16,
@ -1069,13 +1188,37 @@ function default.register_decorations()
persist = 0.66 persist = 0.66
}, },
biomes = {"savanna"}, biomes = {"savanna"},
y_min = 1,
y_max = 31000, y_max = 31000,
schematic = minetest.get_modpath("default").."/schematics/acacia_tree.mts", y_min = 1,
schematic = minetest.get_modpath("default") .. "/schematics/acacia_tree.mts",
flags = "place_center_x, place_center_z", flags = "place_center_x, place_center_z",
rotation = "random", rotation = "random",
}) })
minetest.register_decoration({
name = "default:acacia_log",
deco_type = "schematic",
place_on = {"default:dirt_with_dry_grass"},
place_offset_y = 1,
sidelen = 16,
noise_params = {
offset = 0,
scale = 0.001,
spread = {x = 250, y = 250, z = 250},
seed = 2,
octaves = 3,
persist = 0.66
},
biomes = {"savanna"},
y_max = 31000,
y_min = 1,
schematic = minetest.get_modpath("default") .. "/schematics/acacia_log.mts",
flags = "place_center_x",
rotation = "random",
spawn_by = "default:dirt_with_dry_grass",
num_spawn_by = 8,
})
-- Large cactus -- Large cactus
minetest.register_decoration({ minetest.register_decoration({

View File

@ -118,31 +118,31 @@ minetest.register_node("default:stonebrickmossy", {
minetest.register_node("default:dirt_with_grass", { minetest.register_node("default:dirt_with_grass", {
description = "Dirt with Grass", description = "Dirt with Grass",
tiles = {"default_grass.png", "default_dirt.png", "default_grass_side.png"}, tiles = {"default_grass.png", "default_dirt.png", "default_grass_side.png"},
groups = {crumbly = 3, soil=1, building = 1}, groups = {crumbly = 3, soil=1, building = 1, spreading_dirt_type = 1},
drop = 'default:dirt', drop = 'default:dirt',
sounds = default.node_sound_dirt_defaults({ sounds = default.node_sound_dirt_defaults({
footstep = {name="default_grass_footstep", gain=0.4}, footstep = {name="default_grass_footstep", gain=0.4},
}), }),
}) })
minetest.register_node("default:dirt_with_grass_footsteps", {
description = "Dirt with Grass and Footsteps",
tiles = {"default_grass.png", "default_dirt.png", "default_dirt.png^default_grass_side.png"},
groups = {crumbly = 3, soil = 1, not_in_creative_inventory = 1},
drop = 'default:dirt',
sounds = default.node_sound_dirt_defaults({
footstep = {name = "default_grass_footstep", gain = 0.25},
}),
})
minetest.register_node("default:dirt_with_dry_grass", { minetest.register_node("default:dirt_with_dry_grass", {
description = "Dirt with Dry Grass", description = "Dirt with Dry Grass",
tiles = {"default_dry_grass.png", "default_dirt.png", tiles = {"default_dry_grass.png", "default_dirt.png",
"default_dry_grass_side.png"}, "default_dry_grass_side.png"},
groups = {crumbly = 3, soil=1, building = 1}, groups = {crumbly = 3, soil=1, building = 1, spreading_dirt_type = 1},
drop = "default:dirt", drop = 'default:dirt',
sounds = default.node_sound_dirt_defaults({ sounds = default.node_sound_dirt_defaults({
footstep = {name="default_grass_footstep", gain=0.6}, footstep = {name = "default_grass_footstep", gain = 0.4},
}),
})
minetest.register_node("default:dirt_with_grass_footsteps", {
description = "Dirt with Grass and Footsteps",
tiles = {"default_grass.png", "default_dirt.png", "default_dirt.png^default_grass_side.png"},
groups = {crumbly = 3, not_in_creative_inventory=1, soil=1},
drop = 'default:dirt',
sounds = default.node_sound_dirt_defaults({
footstep = {name="default_grass_footstep", gain=0.4},
}), }),
}) })
@ -151,7 +151,7 @@ minetest.register_node("default:dirt_with_snow", {
tiles = {"default_snow.png", "default_dirt.png", tiles = {"default_snow.png", "default_dirt.png",
{name = "default_snow_side.png", {name = "default_snow_side.png",
tileable_vertical = false}}, tileable_vertical = false}},
groups = {crumbly = 3, soil = 1, building = 1}, groups = {crumbly = 3, soil = 1, building = 1, spreading_dirt_type = 1, snowy = 1},
drop = 'default:dirt', drop = 'default:dirt',
sounds = default.node_sound_dirt_defaults({ sounds = default.node_sound_dirt_defaults({
footstep = {name = "default_snow_footstep", gain = 0.4}, footstep = {name = "default_snow_footstep", gain = 0.4},
@ -686,23 +686,6 @@ minetest.register_node("default:glass", {
drop = "", drop = "",
}) })
---- colored glass
AddGlass( "Glass Red", "basecolor_red", "_red")
AddGlass( "Glass Green", "unicolor_dark_green", "_green")
AddGlass( "Glass Blue", "basecolor_blue", "_blue")
AddGlass( "Glass Light Blue", "basecolor_cyan", "_light_blue")
AddGlass( "Glass Black", "basecolor_black", "_black")
AddGlass( "Glass White", "basecolor_white", "_white")
AddGlass( "Glass Yellow", "basecolor_yellow", "_yellow")
AddGlass( "Glass Brown", "unicolor_dark_orange", "_brown")
AddGlass( "Glass Orange", "excolor_orange", "_orange")
AddGlass( "Glass Pink", "unicolor_light_red", "_pink")
AddGlass( "Glass Gray", "unicolor_darkgrey", "_gray")
AddGlass( "Glass Lime", "basecolor_green", "_lime")
AddGlass( "Glass Silver", "basecolor_grey", "_silver")
AddGlass( "Glass Magenta", "basecolor_magenta", "_magenta")
AddGlass( "Glass Purple", "excolor_violet", "_purple")
minetest.register_node("default:ladder", { minetest.register_node("default:ladder", {
description = "Ladder", description = "Ladder",
drawtype = "signlike", drawtype = "signlike",
@ -814,7 +797,7 @@ minetest.register_node("default:water_source", {
liquid_alternative_source = "default:water_source", liquid_alternative_source = "default:water_source",
liquid_viscosity = 1, liquid_viscosity = 1,
post_effect_color = {a = 103, r = 30, g = 60, b = 90}, post_effect_color = {a = 103, r = 30, g = 60, b = 90},
groups = {water = 3, liquid = 3, puts_out_fire = 1}, groups = {water = 3, liquid = 3, puts_out_fire = 1, not_in_creative_inventory = 1},
sounds = default.node_sound_water_defaults(), sounds = default.node_sound_water_defaults(),
}) })
@ -907,7 +890,7 @@ minetest.register_node("default:river_water_source", {
liquid_renewable = false, liquid_renewable = false,
liquid_range = 2, liquid_range = 2,
post_effect_color = {a = 103, r = 30, g = 76, b = 90}, post_effect_color = {a = 103, r = 30, g = 76, b = 90},
groups = {water = 3, liquid = 3, puts_out_fire = 1}, groups = {water = 3, liquid = 3, puts_out_fire = 1, not_in_creative_inventory = 1},
sounds = default.node_sound_water_defaults(), sounds = default.node_sound_water_defaults(),
}) })
@ -1003,7 +986,7 @@ minetest.register_node("default:lava_source", {
liquid_renewable = false, liquid_renewable = false,
damage_per_second = 4 * 2, damage_per_second = 4 * 2,
post_effect_color = {a = 191, r = 255, g = 64, b = 0}, post_effect_color = {a = 191, r = 255, g = 64, b = 0},
groups = {lava = 3, liquid = 2, hot = 3, igniter = 1}, groups = {lava = 3, liquid = 2, hot = 3, igniter = 1, not_in_creative_inventory = 1},
}) })
minetest.register_node("default:lava_flowing", { minetest.register_node("default:lava_flowing", {
@ -1053,84 +1036,6 @@ minetest.register_node("default:lava_flowing", {
not_in_creative_inventory = 1}, not_in_creative_inventory = 1},
}) })
minetest.register_node("default:torch", {
inventory_image = "default_torch_on_floor.png",
wield_image = "default_torch_on_floor.png",
tiles = {
"default_torch_on_floor_top.png",
"default_torch_on_floor_bottom.png",
"default_torch_on_floor.png",
"default_torch_on_floor.png",
"default_torch_on_floor.png",
"default_torch_on_floor.png"
},
paramtype = "light",
paramtype2 = "wallmounted",
sunlight_propagates = true,
is_ground_content = false,
walkable = false,
light_source = default.LIGHT_MAX - 1,
groups = {choppy = 2, dig_immediate = 3, flammable = 1, attached_node = 1},
legacy_wallmounted = true,
sounds = default.node_sound_defaults(),
liquids_pointable = false,
drawtype = "nodebox",
paramtype = "light",
node_box = {
type = "fixed",
fixed = {
{-0.0625, -0.5, -0.0625, 0.0625, 0.125, 0.0625}, -- NodeBox1
}
},
selection_box = {
type = "wallmounted",
wall_top = {-0.1, 0.5 - 0.6, -0.1, 0.1, 0.5, 0.1},
wall_bottom = {-0.1, -0.5, -0.1, 0.1, -0.5 + 0.6, 0.1},
wall_side = {-0.5, -0.3, -0.1, -0.5 + 0.3, 0.3, 0.1},
},
})
local function get_chest_neighborpos(pos, param2, side)
if side == "right" then
if param2 == 0 then
return {x=pos.x-1, y=pos.y, z=pos.z}
elseif param2 == 1 then
return {x=pos.x, y=pos.y, z=pos.z+1}
elseif param2 == 2 then
return {x=pos.x+1, y=pos.y, z=pos.z}
elseif param2 == 3 then
return {x=pos.x, y=pos.y, z=pos.z-1}
end
else
if param2 == 0 then
return {x=pos.x+1, y=pos.y, z=pos.z}
elseif param2 == 1 then
return {x=pos.x, y=pos.y, z=pos.z-1}
elseif param2 == 2 then
return {x=pos.x-1, y=pos.y, z=pos.z}
elseif param2 == 3 then
return {x=pos.x, y=pos.y, z=pos.z+1}
end
end
end
local function hacky_swap_node(pos,name, param2)
local node = minetest.env:get_node(pos)
local meta = minetest.env:get_meta(pos)
if node.name == name then
return
end
node.name = name
node.param2 = param2 or node.param2
local meta0 = meta:to_table()
minetest.env:set_node(pos,node)
meta = minetest.env:get_meta(pos)
meta:from_table(meta0)
end
minetest.register_node("default:chest", { minetest.register_node("default:chest", {
description = "Chest", description = "Chest",
tiles = {"default_chest_top.png", "default_chest_top.png", "default_chest_side.png", tiles = {"default_chest_top.png", "default_chest_top.png", "default_chest_side.png",
@ -1185,7 +1090,12 @@ minetest.register_node("default:chest", {
"list[current_player;main;0,10.5;9,1;]") "list[current_player;main;0,10.5;9,1;]")
m:set_string("infotext", "Large Chest") m:set_string("infotext", "Large Chest")
else else
meta:set_string("formspec", default.chest_formspec) meta:set_string("formspec",
"size[9,8.5]"..
"image_button_exit[8.4,-0.1;0.75,0.75;close.png;exit;;true;true;]"..
"list[current_name;main;0,0;9,3;]"..
"list[current_player;main;0,4;9,3;9]"..
"list[current_player;main;0,7.5.5;9,1;]")
meta:set_string("infotext", "Chest") meta:set_string("infotext", "Chest")
end end
local inv = meta:get_inventory() local inv = meta:get_inventory()
@ -1217,7 +1127,7 @@ minetest.register_node("default:chest", {
minetest.log("action", player:get_player_name().. minetest.log("action", player:get_player_name()..
" takes stuff from chest at "..minetest.pos_to_string(pos)) " takes stuff from chest at "..minetest.pos_to_string(pos))
end, end,
on_receive_fields = function(pos, formname, fields, sender) on_receive_fields = function(pos, formname, fields, sender)
if fields.exit then if fields.exit then
print('test') print('test')
fields.quit = true fields.quit = true
@ -1655,12 +1565,53 @@ minetest.register_node("default:snow", {
}) })
minetest.register_node("default:snowblock", { minetest.register_node("default:snowblock", {
description = "Snow Block", description = "Snow Block",
tiles = {"default_snow.png"}, tiles = {"default_snow.png"},
groups = {crumbly = 3, building = 1}, groups = {crumbly = 3, building = 1},
sounds = default.node_sound_dirt_defaults({ sounds = default.node_sound_dirt_defaults({
footstep = {name = "default_snow_footstep", gain = 0.4}, footstep = {name = "default_snow_footstep", gain = 0.4},
dug = {name = "default_snow_footstep", gain = 0.75}, dug = {name = "default_snow_footstep", gain = 0.75},
}), }),
drop = "default:snow 4", drop = "default:snow 4",
}) })
--
-- Color Glass
--
function AddGlass(desc, recipeitem, color)
minetest.register_node("default:glass"..color, {
description = desc,
drawtype = "glasslike",
tiles = {"xpanes_pane_glass"..color..".png"},
paramtype = "light",
use_texture_alpha = true,
groups = {cracky = 3, oddly_breakable_by_hand = 3, building = 1},
sounds = default.node_sound_glass_defaults(),
drop = "",
})
minetest.register_craft({
output = 'default:glass_'..color..'',
recipe = {
{'default:glass', 'group:dye,'..recipeitem}
}
})
end
-- Colored glass
AddGlass( "Glass Red", "basecolor_red", "_red")
AddGlass( "Glass Green", "unicolor_dark_green", "_green")
AddGlass( "Glass Blue", "basecolor_blue", "_blue")
AddGlass( "Glass Light Blue", "basecolor_cyan", "_light_blue")
AddGlass( "Glass Black", "basecolor_black", "_black")
AddGlass( "Glass White", "basecolor_white", "_white")
AddGlass( "Glass Yellow", "basecolor_yellow", "_yellow")
AddGlass( "Glass Brown", "unicolor_dark_orange", "_brown")
AddGlass( "Glass Orange", "excolor_orange", "_orange")
AddGlass( "Glass Pink", "unicolor_light_red", "_pink")
AddGlass( "Glass Gray", "unicolor_darkgrey", "_gray")
AddGlass( "Glass Lime", "basecolor_green", "_lime")
AddGlass( "Glass Silver", "basecolor_grey", "_silver")
AddGlass( "Glass Magenta", "basecolor_magenta", "_magenta")
AddGlass( "Glass Purple", "excolor_violet", "_purple")

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,14 +1,10 @@
-- mods/default/tools.lua -- mods/default/tools.lua
--
-- Tool definition
--
-- The hand -- The hand
minetest.register_item(":", { minetest.register_item(":", {
type = "none", type = "none",
wield_image = "wieldhand.png", wield_image = "wieldhand.png",
wield_scale = {x=0.7,y=2,z=0.0001}, wield_scale = {x=0.7,y=2,z=0.0001},
tool_capabilities = { tool_capabilities = {
full_punch_interval = 0.9, full_punch_interval = 0.9,
max_drop_level = 0, max_drop_level = 0,
@ -23,7 +19,10 @@ minetest.register_item(":", {
} }
}) })
--
-- Picks -- Picks
--
minetest.register_tool("default:pick_wood", { minetest.register_tool("default:pick_wood", {
description = "Wooden Pickaxe", description = "Wooden Pickaxe",
inventory_image = "default_tool_woodpick.png", inventory_image = "default_tool_woodpick.png",

View File

@ -0,0 +1,76 @@
minetest.register_node("default:torch", {
description = "Torch",
inventory_image = "default_torch_on_floor.png",
wield_image = "default_torch_on_floor.png",
tiles = {
"default_torch_on_floor_top.png",
"default_torch_on_floor_bottom.png",
"default_torch_on_floor.png",
"default_torch_on_floor.png",
"default_torch_on_floor.png",
"default_torch_on_floor.png"
},
paramtype = "light",
paramtype2 = "wallmounted",
sunlight_propagates = true,
is_ground_content = false,
walkable = false,
light_source = default.LIGHT_MAX - 1,
groups = {choppy = 2, dig_immediate = 3, flammable = 1, attached_node = 1},
legacy_wallmounted = true,
sounds = default.node_sound_defaults(),
liquids_pointable = false,
drawtype = "nodebox",
paramtype = "light",
node_box = {
type = "fixed",
fixed = {
{-0.0625, -0.5, -0.0625, 0.0625, 0.125, 0.0625}, -- NodeBox1
}
},
selection_box = {
type = "wallmounted",
wall_top = {-0.1, 0.5 - 0.6, -0.1, 0.1, 0.5, 0.1},
wall_bottom = {-0.1, -0.5, -0.1, 0.1, -0.5 + 0.6, 0.1},
wall_side = {-0.5, -0.3, -0.1, -0.5 + 0.3, 0.3, 0.1},
},
})
local function get_chest_neighborpos(pos, param2, side)
if side == "right" then
if param2 == 0 then
return {x=pos.x-1, y=pos.y, z=pos.z}
elseif param2 == 1 then
return {x=pos.x, y=pos.y, z=pos.z+1}
elseif param2 == 2 then
return {x=pos.x+1, y=pos.y, z=pos.z}
elseif param2 == 3 then
return {x=pos.x, y=pos.y, z=pos.z-1}
end
else
if param2 == 0 then
return {x=pos.x+1, y=pos.y, z=pos.z}
elseif param2 == 1 then
return {x=pos.x, y=pos.y, z=pos.z-1}
elseif param2 == 2 then
return {x=pos.x-1, y=pos.y, z=pos.z}
elseif param2 == 3 then
return {x=pos.x, y=pos.y, z=pos.z+1}
end
end
end
local function hacky_swap_node(pos,name, param2)
local node = minetest.env:get_node(pos)
local meta = minetest.env:get_meta(pos)
if node.name == name then
return
end
node.name = name
node.param2 = param2 or node.param2
local meta0 = meta:to_table()
minetest.env:set_node(pos,node)
meta = minetest.env:get_meta(pos)
meta:from_table(meta0)
end

View File

@ -1,10 +1,10 @@
local random = math.random
-- --
-- Grow trees from saplings -- Grow trees from saplings
-- --
-- 'Can grow' function -- 'can grow' function
local random = math.random
function default.can_grow(pos) function default.can_grow(pos)
local node_under = minetest.get_node_or_nil({x = pos.x, y = pos.y - 1, z = pos.z}) local node_under = minetest.get_node_or_nil({x = pos.x, y = pos.y - 1, z = pos.z})
@ -24,23 +24,28 @@ function default.can_grow(pos)
end end
-- Sapling ABM -- 'is snow nearby' function
minetest.register_abm({ local function is_snow_nearby(pos)
nodenames = {"default:sapling", "default:junglesapling", return minetest.find_node_near(pos, 1, {"group:snowy"})
"default:pine_sapling", "default:acacia_sapling"}, end
interval = 10,
chance = 50,
action = function(pos, node)
if not default.can_grow(pos) then
return
end
local mapgen = minetest.get_mapgen_params().mgname
-- Grow sapling
function default.grow_sapling(pos)
if not default.can_grow(pos) then
-- try again 5 min later
minetest.get_node_timer(pos):start(300)
return
end
local mg_name = minetest.get_mapgen_setting("mg_name")
local node = minetest.get_node(pos)
if node.name == "default:sapling" then if node.name == "default:sapling" then
minetest.log("action", "A sapling grows into a tree at ".. minetest.log("action", "A sapling grows into a tree at "..
minetest.pos_to_string(pos)) minetest.pos_to_string(pos))
if mapgen == "v6" then if mg_name == "v6" then
default.grow_tree(pos, random(1, 4) == 1) default.grow_tree(pos, random(1, 4) == 1)
else else
default.grow_new_apple_tree(pos) default.grow_new_apple_tree(pos)
@ -48,7 +53,7 @@ minetest.register_abm({
elseif node.name == "default:junglesapling" then elseif node.name == "default:junglesapling" then
minetest.log("action", "A jungle sapling grows into a tree at ".. minetest.log("action", "A jungle sapling grows into a tree at "..
minetest.pos_to_string(pos)) minetest.pos_to_string(pos))
if mapgen == "v6" then if mg_name == "v6" then
default.grow_jungle_tree(pos) default.grow_jungle_tree(pos)
else else
default.grow_new_jungle_tree(pos) default.grow_new_jungle_tree(pos)
@ -56,19 +61,34 @@ minetest.register_abm({
elseif node.name == "default:pine_sapling" then elseif node.name == "default:pine_sapling" then
minetest.log("action", "A pine sapling grows into a tree at ".. minetest.log("action", "A pine sapling grows into a tree at "..
minetest.pos_to_string(pos)) minetest.pos_to_string(pos))
if mapgen == "v6" then local snow = is_snow_nearby(pos)
default.grow_pine_tree(pos) if mg_name == "v6" then
else default.grow_pine_tree(pos, snow)
elseif snow then
default.grow_new_snowy_pine_tree(pos)
else
default.grow_new_pine_tree(pos) default.grow_new_pine_tree(pos)
end end
elseif node.name == "default:acacia_sapling" then elseif node.name == "default:acacia_sapling" then
minetest.log("action", "An acacia sapling grows into a tree at ".. minetest.log("action", "An acacia sapling grows into a tree at "..
minetest.pos_to_string(pos)) minetest.pos_to_string(pos))
default.grow_new_acacia_tree(pos) default.grow_new_acacia_tree(pos)
elseif node.name == "default:emergent_jungle_sapling" then
minetest.log("action", "An emergent jungle sapling grows into a tree at "..
minetest.pos_to_string(pos))
default.grow_new_emergent_jungle_tree(pos)
end end
end end
})
minetest.register_lbm({
name = "default:convert_saplings_to_node_timer",
nodenames = {"default:sapling", "default:junglesapling",
"default:pine_sapling", "default:acacia_sapling",
"default:aspen_sapling"},
action = function(pos)
minetest.get_node_timer(pos):start(math.random(300, 1500))
end
})
-- --
-- Tree generation -- Tree generation
@ -153,8 +173,8 @@ function default.grow_tree(pos, is_apple_tree, bad)
local vm = minetest.get_voxel_manip() local vm = minetest.get_voxel_manip()
local minp, maxp = vm:read_from_map( local minp, maxp = vm:read_from_map(
{x = pos.x - 2, y = pos.y, z = pos.z - 2}, {x = x - 2, y = y, z = z - 2},
{x = pos.x + 2, y = pos.y + height + 1, z = pos.z + 2} {x = x + 2, y = y + height + 1, z = z + 2}
) )
local a = VoxelArea:new({MinEdge = minp, MaxEdge = maxp}) local a = VoxelArea:new({MinEdge = minp, MaxEdge = maxp})
local data = vm:get_data() local data = vm:get_data()
@ -188,13 +208,14 @@ function default.grow_jungle_tree(pos, bad)
local vm = minetest.get_voxel_manip() local vm = minetest.get_voxel_manip()
local minp, maxp = vm:read_from_map( local minp, maxp = vm:read_from_map(
{x = pos.x - 3, y = pos.y - 1, z = pos.z - 3}, {x = x - 3, y = y - 1, z = z - 3},
{x = pos.x + 3, y = pos.y + height + 1, z = pos.z + 3} {x = x + 3, y = y + height + 1, z = z + 3}
) )
local a = VoxelArea:new({MinEdge = minp, MaxEdge = maxp}) local a = VoxelArea:new({MinEdge = minp, MaxEdge = maxp})
local data = vm:get_data() local data = vm:get_data()
add_trunk_and_leaves(data, a, pos, c_jungletree, c_jungleleaves, height, 3, 30, false) add_trunk_and_leaves(data, a, pos, c_jungletree, c_jungleleaves,
height, 3, 30, false)
-- Roots -- Roots
for z_dist = -1, 1 do for z_dist = -1, 1 do
@ -235,7 +256,7 @@ local function add_snow(data, vi, c_air, c_ignore, c_snow)
end end
end end
function default.grow_pine_tree(pos) function default.grow_pine_tree(pos, snow)
local x, y, z = pos.x, pos.y, pos.z local x, y, z = pos.x, pos.y, pos.z
local maxy = y + random(9, 13) -- Trunk top local maxy = y + random(9, 13) -- Trunk top
@ -244,32 +265,15 @@ function default.grow_pine_tree(pos)
local c_pine_tree = minetest.get_content_id("default:pine_tree") local c_pine_tree = minetest.get_content_id("default:pine_tree")
local c_pine_needles = minetest.get_content_id("default:pine_needles") local c_pine_needles = minetest.get_content_id("default:pine_needles")
local c_snow = minetest.get_content_id("default:snow") local c_snow = minetest.get_content_id("default:snow")
local c_snowblock = minetest.get_content_id("default:snowblock")
local c_dirtsnow = minetest.get_content_id("default:dirt_with_snow")
local vm = minetest.get_voxel_manip() local vm = minetest.get_voxel_manip()
local minp, maxp = vm:read_from_map( local minp, maxp = vm:read_from_map(
{x = x - 3, y = y - 1, z = z - 3}, {x = x - 3, y = y, z = z - 3},
{x = x + 3, y = maxy + 3, z = z + 3} {x = x + 3, y = maxy + 3, z = z + 3}
) )
local a = VoxelArea:new({MinEdge = minp, MaxEdge = maxp}) local a = VoxelArea:new({MinEdge = minp, MaxEdge = maxp})
local data = vm:get_data() local data = vm:get_data()
-- Scan for snow nodes near sapling to enable snow on branches
local snow = false
for yy = y - 1, y + 1 do
for zz = z - 1, z + 1 do
local vi = a:index(x - 1, yy, zz)
for xx = x - 1, x + 1 do
local nodid = data[vi]
if nodid == c_snow or nodid == c_snowblock or nodid == c_dirtsnow then
snow = true
end
vi = vi + 1
end
end
end
-- Upper branches layer -- Upper branches layer
local dev = 3 local dev = 3
for yy = maxy - 1, maxy + 1 do for yy = maxy - 1, maxy + 1 do
@ -324,7 +328,7 @@ function default.grow_pine_tree(pos)
end end
end end
local dev = 2 dev = 2
for yy = my + 1, my + 2 do for yy = my + 1, my + 2 do
for zz = z - dev, z + dev do for zz = z - dev, z + dev do
local vi = a:index(x - dev, yy, zz) local vi = a:index(x - dev, yy, zz)
@ -345,7 +349,8 @@ function default.grow_pine_tree(pos)
end end
-- Trunk -- Trunk
data[a:index(x, y, z)] = c_pine_tree -- Force-place lowest trunk node to replace sapling -- Force-place lowest trunk node to replace sapling
data[a:index(x, y, z)] = c_pine_tree
for yy = y + 1, maxy do for yy = y + 1, maxy do
local vi = a:index(x, yy, z) local vi = a:index(x, yy, z)
local node_id = data[vi] local node_id = data[vi]
@ -364,34 +369,89 @@ end
-- New apple tree -- New apple tree
function default.grow_new_apple_tree(pos) function default.grow_new_apple_tree(pos)
local path = minetest.get_modpath("default") .. "/schematics/apple_tree_from_sapling.mts" local path = minetest.get_modpath("default") ..
minetest.place_schematic({x = pos.x - 2, y = pos.y - 1, z = pos.z - 2}, "/schematics/apple_tree_from_sapling.mts"
path, 0, nil, false) minetest.place_schematic({x = pos.x - 3, y = pos.y - 1, z = pos.z - 3},
path, "random", nil, false)
end end
-- New jungle tree -- New jungle tree
function default.grow_new_jungle_tree(pos) function default.grow_new_jungle_tree(pos)
local path = minetest.get_modpath("default") .. "/schematics/jungle_tree_from_sapling.mts" local path = minetest.get_modpath("default") ..
"/schematics/jungle_tree_from_sapling.mts"
minetest.place_schematic({x = pos.x - 2, y = pos.y - 1, z = pos.z - 2}, minetest.place_schematic({x = pos.x - 2, y = pos.y - 1, z = pos.z - 2},
path, 0, nil, false) path, "random", nil, false)
end
-- New emergent jungle tree
function default.grow_new_emergent_jungle_tree(pos)
local path = minetest.get_modpath("default") ..
"/schematics/emergent_jungle_tree_from_sapling.mts"
minetest.place_schematic({x = pos.x - 3, y = pos.y - 5, z = pos.z - 3},
path, "random", nil, false)
end end
-- New pine tree -- New pine tree
function default.grow_new_pine_tree(pos) function default.grow_new_pine_tree(pos)
local path = minetest.get_modpath("default") .. "/schematics/pine_tree_from_sapling.mts" local path
if math.random() > 0.5 then
path = minetest.get_modpath("default") ..
"/schematics/pine_tree_from_sapling.mts"
else
path = minetest.get_modpath("default") ..
"/schematics/small_pine_tree_from_sapling.mts"
end
minetest.place_schematic({x = pos.x - 2, y = pos.y - 1, z = pos.z - 2}, minetest.place_schematic({x = pos.x - 2, y = pos.y - 1, z = pos.z - 2},
path, 0, nil, false) path, "0", nil, false)
end
-- New snowy pine tree
function default.grow_new_snowy_pine_tree(pos)
local path
if math.random() > 0.5 then
path = minetest.get_modpath("default") ..
"/schematics/snowy_pine_tree_from_sapling.mts"
else
path = minetest.get_modpath("default") ..
"/schematics/snowy_small_pine_tree_from_sapling.mts"
end
minetest.place_schematic({x = pos.x - 2, y = pos.y - 1, z = pos.z - 2},
path, "random", nil, false)
end end
-- New acacia tree -- New acacia tree
function default.grow_new_acacia_tree(pos) function default.grow_new_acacia_tree(pos)
local path = minetest.get_modpath("default") .. "/schematics/acacia_tree_from_sapling.mts" local path = minetest.get_modpath("default") ..
"/schematics/acacia_tree_from_sapling.mts"
minetest.place_schematic({x = pos.x - 4, y = pos.y - 1, z = pos.z - 4}, minetest.place_schematic({x = pos.x - 4, y = pos.y - 1, z = pos.z - 4},
path, random, nil, false) path, "random", nil, false)
end
-- New aspen tree
function default.grow_new_aspen_tree(pos)
local path = minetest.get_modpath("default") ..
"/schematics/aspen_tree_from_sapling.mts"
minetest.place_schematic({x = pos.x - 2, y = pos.y - 1, z = pos.z - 2},
path, "0", nil, false)
end
-- Large cactus
function default.grow_large_cactus(pos)
local path = minetest.get_modpath("default") ..
"/schematics/large_cactus.mts"
minetest.place_schematic({x = pos.x - 2, y = pos.y - 1, z = pos.z - 2},
path, "random", nil, false)
end end

View File

@ -1,4 +1,4 @@
Minetest Game mod: dungeon_loot MultiCraft Game mod: dungeon_loot
=============================== ===============================
Adds randomly generated chests with some "loot" to generated dungeons, Adds randomly generated chests with some "loot" to generated dungeons,
an API to register additional loot is provided. an API to register additional loot is provided.

View File

@ -1,4 +1,4 @@
Minetest Game mod: player_api MultiCraft Game mod: player_api
============================= =============================
See license.txt for license information. See license.txt for license information.

View File

@ -43,7 +43,7 @@ function signs.generate_sign_texture(string)
row = row + 1 row = row + 1
end end
return texture return texture
end end
minetest.register_entity("signs:sign_text", { minetest.register_entity("signs:sign_text", {
initial_properties = { initial_properties = {
@ -83,6 +83,7 @@ local function check_text(pos, wall)
end end
if not found then if not found then
local p2 = minetest.get_node(pos).param2 local p2 = minetest.get_node(pos).param2
if not p2 then return end
if wall then if wall then
local obj = minetest.add_entity(vector.add(pos, local obj = minetest.add_entity(vector.add(pos,
signs.wall_sign_positions[p2][1]), "signs:sign_text") signs.wall_sign_positions[p2][1]), "signs:sign_text")
@ -191,7 +192,7 @@ minetest.register_node("signs:sign", {
end end
end end
if not found then if not found then
local obj = minetest.add_entity(vector.add(pos, local obj = minetest.add_entity(vector.add(pos,
signs.sign_positions[p2][1]), "signs:sign_text") signs.sign_positions[p2][1]), "signs:sign_text")
obj:set_properties({ obj:set_properties({
textures = {signs.generate_sign_texture(fields.text), "blank.png"} textures = {signs.generate_sign_texture(fields.text), "blank.png"}
@ -254,7 +255,7 @@ minetest.register_node("signs:wall_sign", {
end end
end end
if not found then if not found then
local obj = minetest.add_entity(vector.add(pos, local obj = minetest.add_entity(vector.add(pos,
signs.wall_sign_positions[p2][1]), "signs:sign_text") signs.wall_sign_positions[p2][1]), "signs:sign_text")
obj:set_properties({ obj:set_properties({
textures = {signs.generate_sign_texture(fields.text), "blank.png"} textures = {signs.generate_sign_texture(fields.text), "blank.png"}
@ -269,4 +270,3 @@ minetest.register_node("signs:wall_sign", {
}) })
dofile(minetest.get_modpath("signs") .. "/legacy.lua") dofile(minetest.get_modpath("signs") .. "/legacy.lua")

View File

@ -9,7 +9,7 @@ minetest.register_node(":default:sign_wall_wood", {
oddly_breakable_by_hand = 3, not_in_creative_inventory = 1}, oddly_breakable_by_hand = 3, not_in_creative_inventory = 1},
legacy_wallmounted = true, legacy_wallmounted = true,
}) })
minetest.register_lbm({ minetest.register_lbm({
label = "Upgrade legacy signs", label = "Upgrade legacy signs",
name = "signs:sign_wall_update", name = "signs:sign_wall_update",

View File

@ -1,5 +1,5 @@
function round(num) function round(num)
return math.floor(num + 0.5) return math.floor(num + 0.5)
end end
local lasttime = "default" local lasttime = "default"
@ -60,4 +60,4 @@ minetest.register_craft({
{'default:gold_ingot', 'default:bluestone_dust', 'default:gold_ingot'}, {'default:gold_ingot', 'default:bluestone_dust', 'default:gold_ingot'},
{'', 'default:gold_ingot', ''} {'', 'default:gold_ingot', ''}
} }
}) })