}
})
---
--- Crafting (tool repair)
---
+-- Tool repair
minetest.register_craft({
type = "toolrepair",
additional_wear = -0.02,
recipe = "default:tree",
})
-minetest.register_craft({
- type = "cooking",
- output = "default:coal_lump",
- recipe = "default:jungletree",
-})
-
minetest.register_craft({
type = "cooking",
output = "default:stone",
burntime = 30,
})
-minetest.register_craft({
- type = "fuel",
- recipe = "default:jungletree",
- burntime = 30,
-})
-
minetest.register_craft({
type = "fuel",
recipe = "default:junglegrass",
{name="", gain=0.5}
--table.dug = table.dug or
-- {name="default_dirt_break", gain=0.5}
+ table.place = table.place or
+ {name="default_grass_footstep", gain=0.5}
default.node_sound_defaults(table)
return table
end
return table
end
---
+-- Register nodes
minetest.register_node("default:stone", {
description = "Stone",
tiles ={"default_stone.png"},
- is_ground_content = true,
groups = {cracky=3},
drop = 'default:cobble',
legacy_mineral = true,
minetest.register_node("default:stone_with_coal", {
description = "Stone with coal",
tiles ={"default_stone.png^default_mineral_coal.png"},
- is_ground_content = true,
groups = {cracky=3},
drop = 'default:coal_lump',
sounds = default.node_sound_stone_defaults(),
minetest.register_node("default:stone_with_iron", {
description = "Stone with iron",
tiles ={"default_stone.png^default_mineral_iron.png"},
- is_ground_content = true,
groups = {cracky=3},
drop = 'default:iron_lump',
sounds = default.node_sound_stone_defaults(),
minetest.register_node("default:dirt_with_grass", {
description = "Dirt with grass",
- tiles ={"default_grass.png", "default_dirt.png", "default_dirt.png^default_grass_side.png"},
- is_ground_content = true,
- groups = {crumbly=3},
+ tiles ={"default_grass.png", "default_dirt.png",
+ {name = "default_dirt.png^default_grass_side.png",
+ tileable_vertical = false}},
+ groups = {crumbly=3, soil=1},
drop = 'default:dirt',
sounds = default.node_sound_dirt_defaults({
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_footsteps.png", "default_dirt.png", "default_dirt.png^default_grass_side.png"},
- is_ground_content = true,
- groups = {crumbly=3},
+ tiles ={"default_grass_footsteps.png", "default_dirt.png",
+ {name = "default_dirt.png^default_grass_side.png",
+ tileable_vertical = false}},
+ groups = {crumbly=3, soil=1},
drop = 'default:dirt',
sounds = default.node_sound_dirt_defaults({
footstep = {name="default_grass_footstep", gain=0.4},
minetest.register_node("default:dirt", {
description = "Dirt",
tiles ={"default_dirt.png"},
- is_ground_content = true,
- groups = {crumbly=3},
+ groups = {crumbly=3, soil=1},
sounds = default.node_sound_dirt_defaults(),
})
minetest.register_node("default:sand", {
description = "Sand",
tiles ={"default_sand.png"},
- is_ground_content = true,
- groups = {crumbly=3},
+ groups = {crumbly=3, falling_node=1},
sounds = default.node_sound_sand_defaults(),
})
minetest.register_node("default:gravel", {
description = "Gravel",
tiles ={"default_gravel.png"},
- is_ground_content = true,
- groups = {crumbly=2},
+ groups = {crumbly=2, falling_node=1},
sounds = default.node_sound_dirt_defaults({
footstep = {name="default_gravel_footstep", gain=0.45},
}),
minetest.register_node("default:sandstone", {
description = "Sandstone",
tiles ={"default_sandstone.png"},
- is_ground_content = true,
groups = {crumbly=2,cracky=2},
drop = 'default:sand',
sounds = default.node_sound_stone_defaults(),
minetest.register_node("default:clay", {
description = "Clay",
tiles ={"default_clay.png"},
- is_ground_content = true,
groups = {crumbly=3},
drop = 'default:clay_lump 4',
sounds = default.node_sound_dirt_defaults({
minetest.register_node("default:brick", {
description = "Brick",
tiles ={"default_brick.png"},
- is_ground_content = true,
+ is_ground_content = false,
groups = {cracky=3},
drop = 'default:clay_brick 4',
sounds = default.node_sound_stone_defaults(),
minetest.register_node("default:tree", {
description = "Tree",
tiles ={"default_tree_top.png", "default_tree_top.png", "default_tree.png"},
- is_ground_content = true,
- groups = {snappy=2,choppy=2,oddly_breakable_by_hand=1},
- sounds = default.node_sound_wood_defaults(),
-})
-
-minetest.register_node("default:jungletree", {
- description = "Jungle Tree",
- tiles ={"default_jungletree_top.png", "default_jungletree_top.png", "default_jungletree.png"},
- is_ground_content = true,
+ is_ground_content = false,
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=1},
sounds = default.node_sound_wood_defaults(),
})
wield_image = "default_junglegrass.png",
paramtype = "light",
walkable = false,
- groups = {snappy=3},
+ groups = {snappy=3,attached_node=1},
sounds = default.node_sound_leaves_defaults(),
})
visual_scale = 1.3,
tiles ={"default_leaves.png"},
paramtype = "light",
+ is_ground_content = false,
groups = {snappy=3},
drop = {
max_items = 1,
minetest.register_node("default:cactus", {
description = "Cactus",
tiles ={"default_cactus_top.png", "default_cactus_top.png", "default_cactus_side.png"},
- is_ground_content = true,
groups = {snappy=2,choppy=3},
sounds = default.node_sound_wood_defaults(),
})
inventory_image = "default_papyrus.png",
wield_image = "default_papyrus.png",
paramtype = "light",
- is_ground_content = true,
walkable = false,
groups = {snappy=3},
sounds = default.node_sound_leaves_defaults(),
minetest.register_node("default:bookshelf", {
description = "Bookshelf",
tiles ={"default_wood.png", "default_wood.png", "default_bookshelf.png"},
- is_ground_content = true,
+ is_ground_content = false,
groups = {snappy=2,choppy=3,oddly_breakable_by_hand=2},
sounds = default.node_sound_wood_defaults(),
})
description = "Glass",
drawtype = "glasslike",
tiles ={"default_glass.png"},
- inventory_image = minetest.inventorycube("default_glass.png"),
paramtype = "light",
+ is_ground_content = false,
sunlight_propagates = true,
- is_ground_content = true,
groups = {snappy=2,cracky=3,oddly_breakable_by_hand=3},
sounds = default.node_sound_glass_defaults(),
})
inventory_image = "default_fence.png",
wield_image = "default_fence.png",
paramtype = "light",
- is_ground_content = true,
+ is_ground_content = false,
selection_box = {
type = "fixed",
fixed = {-1/7, -1/2, -1/7, 1/7, 1/2, 1/7},
inventory_image = "default_rail.png",
wield_image = "default_rail.png",
paramtype = "light",
- is_ground_content = true,
+ is_ground_content = false,
walkable = false,
selection_box = {
type = "fixed",
wield_image = "default_ladder.png",
paramtype = "light",
paramtype2 = "wallmounted",
- is_ground_content = true,
+ is_ground_content = false,
walkable = false,
climbable = true,
selection_box = {
minetest.register_node("default:wood", {
description = "Wood",
tiles ={"default_wood.png"},
- is_ground_content = true,
+ is_ground_content = false,
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
sounds = default.node_sound_wood_defaults(),
})
minetest.register_node("default:mese", {
description = "Mese",
tiles ={"default_mese.png"},
- is_ground_content = true,
groups = {cracky=1,level=2},
sounds = default.node_sound_defaults(),
})
minetest.register_node("default:cloud", {
description = "Cloud",
tiles ={"default_cloud.png"},
- is_ground_content = true,
+ is_ground_content = false,
sounds = default.node_sound_defaults(),
})
pointable = false,
diggable = false,
buildable_to = true,
+ is_ground_content = false,
+ drowning = 1,
liquidtype = "flowing",
liquid_alternative_flowing = "default:water_flowing",
liquid_alternative_source = "default:water_source",
pointable = false,
diggable = false,
buildable_to = true,
+ is_ground_content = false,
+ drowning = 1,
liquidtype = "source",
liquid_alternative_flowing = "default:water_flowing",
liquid_alternative_source = "default:water_source",
pointable = false,
diggable = false,
buildable_to = true,
+ is_ground_content = false,
+ drowning = 1,
liquidtype = "flowing",
liquid_alternative_flowing = "default:lava_flowing",
liquid_alternative_source = "default:lava_source",
pointable = false,
diggable = false,
buildable_to = true,
+ is_ground_content = false,
+ drowning = 1,
liquidtype = "source",
liquid_alternative_flowing = "default:lava_flowing",
liquid_alternative_source = "default:lava_source",
paramtype = "light",
paramtype2 = "wallmounted",
sunlight_propagates = true,
+ is_ground_content = false,
walkable = false,
light_source = LIGHT_MAX-1,
selection_box = {
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},
},
- groups = {choppy=2,dig_immediate=3},
+ groups = {choppy=2,dig_immediate=3,attached_node=1},
legacy_wallmounted = true,
sounds = default.node_sound_defaults(),
})
paramtype = "light",
paramtype2 = "wallmounted",
sunlight_propagates = true,
+ is_ground_content = false,
walkable = false,
selection_box = {
type = "wallmounted",
--wall_bottom = <default>
--wall_side = <default>
},
- groups = {choppy=2,dig_immediate=2},
+ groups = {choppy=2,dig_immediate=2,attached_node=1},
legacy_wallmounted = true,
sounds = default.node_sound_defaults(),
on_construct = function(pos)
- --local n = minetest.env:get_node(pos)
- local meta = minetest.env:get_meta(pos)
+ --local n = minetest.get_node(pos)
+ local meta = minetest.get_meta(pos)
meta:set_string("formspec", "field[text;;${text}]")
meta:set_string("infotext", "\"\"")
end,
on_receive_fields = function(pos, formname, fields, sender)
--print("Sign at "..minetest.pos_to_string(pos).." got "..dump(fields))
- local meta = minetest.env:get_meta(pos)
+ local meta = minetest.get_meta(pos)
fields.text = fields.text or ""
print((sender:get_player_name() or "").." wrote \""..fields.text..
"\" to sign at "..minetest.pos_to_string(pos))
paramtype2 = "facedir",
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
legacy_facedir_simple = true,
+ is_ground_content = false,
sounds = default.node_sound_wood_defaults(),
on_construct = function(pos)
- local meta = minetest.env:get_meta(pos)
+ local meta = minetest.get_meta(pos)
meta:set_string("formspec",
"size[8,9]"..
"list[current_name;main;0,0;8,4;]"..
- "list[current_player;main;0,5;8,4;]")
+ "list[current_player;main;0,5;8,4;]" ..
+ "listring[]")
meta:set_string("infotext", "Chest")
local inv = meta:get_inventory()
inv:set_size("main", 8*4)
end,
can_dig = function(pos,player)
- local meta = minetest.env:get_meta(pos);
+ local meta = minetest.get_meta(pos);
local inv = meta:get_inventory()
return inv:is_empty("main")
end,
paramtype2 = "facedir",
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
legacy_facedir_simple = true,
+ is_ground_content = false,
sounds = default.node_sound_wood_defaults(),
after_place_node = function(pos, placer)
- local meta = minetest.env:get_meta(pos)
+ local meta = minetest.get_meta(pos)
meta:set_string("owner", placer:get_player_name() or "")
meta:set_string("infotext", "Locked Chest (owned by "..
meta:get_string("owner")..")")
end,
on_construct = function(pos)
- local meta = minetest.env:get_meta(pos)
+ local meta = minetest.get_meta(pos)
meta:set_string("formspec",
"size[8,9]"..
"list[current_name;main;0,0;8,4;]"..
- "list[current_player;main;0,5;8,4;]")
+ "list[current_player;main;0,5;8,4;]" ..
+ "listring[]")
meta:set_string("infotext", "Locked Chest")
meta:set_string("owner", "")
local inv = meta:get_inventory()
inv:set_size("main", 8*4)
end,
can_dig = function(pos,player)
- local meta = minetest.env:get_meta(pos);
+ local meta = minetest.get_meta(pos);
local inv = meta:get_inventory()
return inv:is_empty("main")
end,
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
- local meta = minetest.env:get_meta(pos)
+ local meta = minetest.get_meta(pos)
if not has_locked_chest_privilege(meta, player) then
minetest.log("action", player:get_player_name()..
" tried to access a locked chest belonging to "..
return count
end,
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
- local meta = minetest.env:get_meta(pos)
+ local meta = minetest.get_meta(pos)
if not has_locked_chest_privilege(meta, player) then
minetest.log("action", player:get_player_name()..
" tried to access a locked chest belonging to "..
return stack:get_count()
end,
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
- local meta = minetest.env:get_meta(pos)
+ local meta = minetest.get_meta(pos)
if not has_locked_chest_privilege(meta, player) then
minetest.log("action", player:get_player_name()..
" tried to access a locked chest belonging to "..
"list[current_name;fuel;2,3;1,1;]"..
"list[current_name;src;2,1;1,1;]"..
"list[current_name;dst;5,1;2,2;]"..
- "list[current_player;main;0,5;8,4;]"
+ "list[current_player;main;0,5;8,4;]" ..
+ "listring[current_name;dst]" ..
+ "listring[current_player;main]" ..
+ "listring[current_name;src]" ..
+ "listring[current_player;main]"
minetest.register_node("default:furnace", {
description = "Furnace",
paramtype2 = "facedir",
groups = {cracky=2},
legacy_facedir_simple = true,
+ is_ground_content = false,
sounds = default.node_sound_stone_defaults(),
on_construct = function(pos)
- local meta = minetest.env:get_meta(pos)
+ local meta = minetest.get_meta(pos)
meta:set_string("formspec", default.furnace_inactive_formspec)
meta:set_string("infotext", "Furnace")
local inv = meta:get_inventory()
inv:set_size("dst", 4)
end,
can_dig = function(pos,player)
- local meta = minetest.env:get_meta(pos);
+ local meta = minetest.get_meta(pos);
local inv = meta:get_inventory()
if not inv:is_empty("fuel") then
return false
drop = "default:furnace",
groups = {cracky=2},
legacy_facedir_simple = true,
+ is_ground_content = false,
sounds = default.node_sound_stone_defaults(),
on_construct = function(pos)
- local meta = minetest.env:get_meta(pos)
+ local meta = minetest.get_meta(pos)
meta:set_string("formspec", default.furnace_inactive_formspec)
meta:set_string("infotext", "Furnace");
local inv = meta:get_inventory()
inv:set_size("dst", 4)
end,
can_dig = function(pos,player)
- local meta = minetest.env:get_meta(pos);
+ local meta = minetest.get_meta(pos);
local inv = meta:get_inventory()
if not inv:is_empty("fuel") then
return false
end,
})
-function hacky_swap_node(pos,name)
- local node = minetest.env:get_node(pos)
- local meta = minetest.env:get_meta(pos)
- local meta0 = meta:to_table()
+function swap_node(pos,name)
+ local node = minetest.get_node(pos)
if node.name == name then
return
end
node.name = name
- local meta0 = meta:to_table()
- minetest.env:set_node(pos,node)
- meta = minetest.env:get_meta(pos)
- meta:from_table(meta0)
+ minetest.swap_node(pos, node)
end
minetest.register_abm({
interval = 1.0,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
- local meta = minetest.env:get_meta(pos)
+ local meta = minetest.get_meta(pos)
for i, name in ipairs({
"fuel_totaltime",
"fuel_time",
srcstack:take_item()
inv:set_stack("src", 1, srcstack)
else
- print("Could not insert '"..cooked.item.."'")
+ print("Could not insert '"..cooked.item:to_string().."'")
end
meta:set_string("src_time", 0)
end
local percent = math.floor(meta:get_float("fuel_time") /
meta:get_float("fuel_totaltime") * 100)
meta:set_string("infotext","Furnace active: "..percent.."%")
- hacky_swap_node(pos,"default:furnace_active")
+ swap_node(pos,"default:furnace_active")
meta:set_string("formspec",
"size[8,9]"..
"image[2,2;1,1;default_furnace_fire_bg.png^[lowpart:"..
"list[current_name;fuel;2,3;1,1;]"..
"list[current_name;src;2,1;1,1;]"..
"list[current_name;dst;5,1;2,2;]"..
- "list[current_player;main;0,5;8,4;]")
+ "list[current_player;main;0,5;8,4;]" ..
+ "listring[current_name;dst]" ..
+ "listring[current_player;main]" ..
+ "listring[current_name;src]" ..
+ "listring[current_player;main]")
return
end
if fuel.time <= 0 then
meta:set_string("infotext","Furnace out of fuel")
- hacky_swap_node(pos,"default:furnace")
+ swap_node(pos,"default:furnace")
meta:set_string("formspec", default.furnace_inactive_formspec)
return
end
if cooked.item:is_empty() then
if was_active then
meta:set_string("infotext","Furnace is empty")
- hacky_swap_node(pos,"default:furnace")
+ swap_node(pos,"default:furnace")
meta:set_string("formspec", default.furnace_inactive_formspec)
end
return
minetest.register_node("default:cobble", {
description = "Cobble",
tiles ={"default_cobble.png"},
- is_ground_content = true,
+ is_ground_content = false,
groups = {cracky=3},
sounds = default.node_sound_stone_defaults(),
})
minetest.register_node("default:mossycobble", {
description = "Mossy Cobble",
tiles ={"default_mossycobble.png"},
- is_ground_content = true,
+ is_ground_content = false,
groups = {cracky=3},
sounds = default.node_sound_stone_defaults(),
})
minetest.register_node("default:steelblock", {
description = "Steel Block",
tiles ={"default_steel_block.png"},
- is_ground_content = true,
+ is_ground_content = false,
groups = {snappy=1,bendy=2},
sounds = default.node_sound_stone_defaults(),
})
paramtype2 = "facedir",
groups = {cracky=2},
legacy_facedir_simple = true,
+ is_ground_content = false,
sounds = default.node_sound_defaults(),
})
description = "Nyancat Rainbow",
tiles ={"default_nc_rb.png"},
inventory_image = "default_nc_rb.png",
+ is_ground_content = false,
groups = {cracky=2},
sounds = default.node_sound_defaults(),
})
wield_image = "default_sapling.png",
paramtype = "light",
walkable = false,
- groups = {snappy=2,dig_immediate=3},
+ groups = {snappy=2,dig_immediate=3,attached_node=1},
sounds = default.node_sound_defaults(),
})
tiles ={"default_apple.png"},
inventory_image = "default_apple.png",
paramtype = "light",
+ is_ground_content = false,
sunlight_propagates = true,
walkable = false,
groups = {fleshy=3,dig_immediate=3},
sounds = default.node_sound_defaults(),
})
+--
+-- Grow tree function
+--
+
+local c_air = minetest.get_content_id("air")
+local c_ignore = minetest.get_content_id("ignore")
+local c_tree = minetest.get_content_id("default:tree")
+local c_leaves = minetest.get_content_id("default:leaves")
+local c_apple = minetest.get_content_id("default:apple")
+function default.grow_tree(data, a, pos, is_apple_tree, seed)
+ --[[
+ NOTE: Tree-placing code is currently duplicated in the engine
+ and in games that have saplings; both are deprecated but not
+ replaced yet
+ ]]--
+ local pr = PseudoRandom(seed)
+ local th = pr:next(4, 5)
+ local x, y, z = pos.x, pos.y, pos.z
+ for yy = y, y+th-1 do
+ local vi = a:index(x, yy, z)
+ if a:contains(x, yy, z) and (data[vi] == c_air or yy == y) then
+ data[vi] = c_tree
+ end
+ end
+ y = y+th-1 -- (x, y, z) is now last piece of trunk
+ local leaves_a = VoxelArea:new{MinEdge={x=-2, y=-1, z=-2}, MaxEdge={x=2, y=2, z=2}}
+ local leaves_buffer = {}
+
+ -- Force leaves near the trunk
+ local d = 1
+ for xi = -d, d do
+ for yi = -d, d do
+ for zi = -d, d do
+ leaves_buffer[leaves_a:index(xi, yi, zi)] = true
+ end
+ end
+ end
+
+ -- Add leaves randomly
+ for iii = 1, 8 do
+ local d = 1
+ local xx = pr:next(leaves_a.MinEdge.x, leaves_a.MaxEdge.x - d)
+ local yy = pr:next(leaves_a.MinEdge.y, leaves_a.MaxEdge.y - d)
+ local zz = pr:next(leaves_a.MinEdge.z, leaves_a.MaxEdge.z - d)
+
+ for xi = 0, d do
+ for yi = 0, d do
+ for zi = 0, d do
+ leaves_buffer[leaves_a:index(xx+xi, yy+yi, zz+zi)] = true
+ end
+ end
+ end
+ end
+
+ -- Add the leaves
+ for xi = leaves_a.MinEdge.x, leaves_a.MaxEdge.x do
+ for yi = leaves_a.MinEdge.y, leaves_a.MaxEdge.y do
+ for zi = leaves_a.MinEdge.z, leaves_a.MaxEdge.z do
+ if a:contains(x+xi, y+yi, z+zi) then
+ local vi = a:index(x+xi, y+yi, z+zi)
+ if data[vi] == c_air or data[vi] == c_ignore then
+ if leaves_buffer[leaves_a:index(xi, yi, zi)] then
+ if is_apple_tree and pr:next(1, 100) <= 10 then
+ data[vi] = c_apple
+ else
+ data[vi] = c_leaves
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+end
+
+--
+-- ABMs
+--
+
+minetest.register_abm({
+ nodenames = {"default:sapling"},
+ interval = 10,
+ chance = 50,
+ action = function(pos, node)
+ if minetest.get_item_group(minetest.get_node(
+ {x = pos.x, y = pos.y - 1, z = pos.z}).name, "soil") == 0 then
+ return
+ end
+ print("A sapling grows into a tree at "..minetest.pos_to_string(pos))
+ local vm = minetest.get_voxel_manip()
+ local minp, maxp = vm:read_from_map({x=pos.x-16, y=pos.y, z=pos.z-16}, {x=pos.x+16, y=pos.y+16, z=pos.z+16})
+ local a = VoxelArea:new{MinEdge=minp, MaxEdge=maxp}
+ local data = vm:get_data()
+ default.grow_tree(data, a, pos, math.random(1, 4) == 1, math.random(1,100000))
+ vm:set_data(data)
+ vm:write_to_map(data)
+ vm:update_map()
+ end
+})
+
+minetest.register_abm({
+ nodenames = {"default:dirt"},
+ interval = 2,
+ chance = 200,
+ action = function(pos, node)
+ local above = {x=pos.x, y=pos.y+1, z=pos.z}
+ local name = minetest.get_node(above).name
+ local nodedef = minetest.registered_nodes[name]
+ if nodedef and (nodedef.sunlight_propagates or nodedef.paramtype == "light")
+ and nodedef.liquidtype == "none"
+ and (minetest.get_node_light(above) or 0) >= 13 then
+ if name == "default:snow" or name == "default:snowblock" then
+ minetest.set_node(pos, {name = "default:dirt_with_snow"})
+ else
+ minetest.set_node(pos, {name = "default:dirt_with_grass"})
+ end
+ end
+ end
+})
+
+minetest.register_abm({
+ nodenames = {"default:dirt_with_grass"},
+ interval = 2,
+ chance = 20,
+ action = function(pos, node)
+ local above = {x=pos.x, y=pos.y+1, z=pos.z}
+ local name = minetest.get_node(above).name
+ local nodedef = minetest.registered_nodes[name]
+ if name ~= "ignore" and nodedef
+ and not ((nodedef.sunlight_propagates or nodedef.paramtype == "light")
+ and nodedef.liquidtype == "none") then
+ minetest.set_node(pos, {name = "default:dirt"})
+ end
+ end
+})
+
--
-- Crafting items
--
})
--
--- Creative inventory
---
-
-minetest.add_to_creative_inventory('default:pick_mese')
-minetest.add_to_creative_inventory('default:pick_steel')
-minetest.add_to_creative_inventory('default:axe_steel')
-minetest.add_to_creative_inventory('default:shovel_steel')
-
-minetest.add_to_creative_inventory('default:torch')
-minetest.add_to_creative_inventory('default:cobble')
-minetest.add_to_creative_inventory('default:dirt')
-minetest.add_to_creative_inventory('default:stone')
-minetest.add_to_creative_inventory('default:sand')
-minetest.add_to_creative_inventory('default:sandstone')
-minetest.add_to_creative_inventory('default:clay')
-minetest.add_to_creative_inventory('default:brick')
-minetest.add_to_creative_inventory('default:tree')
-minetest.add_to_creative_inventory('default:wood')
-minetest.add_to_creative_inventory('default:leaves')
-minetest.add_to_creative_inventory('default:cactus')
-minetest.add_to_creative_inventory('default:papyrus')
-minetest.add_to_creative_inventory('default:bookshelf')
-minetest.add_to_creative_inventory('default:glass')
-minetest.add_to_creative_inventory('default:fence_wood')
-minetest.add_to_creative_inventory('default:rail')
-minetest.add_to_creative_inventory('default:mese')
-minetest.add_to_creative_inventory('default:chest')
-minetest.add_to_creative_inventory('default:furnace')
-minetest.add_to_creative_inventory('default:sign_wall')
-minetest.add_to_creative_inventory('default:water_source')
-minetest.add_to_creative_inventory('default:lava_source')
-minetest.add_to_creative_inventory('default:ladder')
-
---
--- Aliases for the current map generator outputs
---
-
-minetest.register_alias("mapgen_air", "air")
-minetest.register_alias("mapgen_stone", "default:stone")
-minetest.register_alias("mapgen_tree", "default:tree")
-minetest.register_alias("mapgen_leaves", "default:leaves")
-minetest.register_alias("mapgen_apple", "default:apple")
-minetest.register_alias("mapgen_water_source", "default:water_source")
-minetest.register_alias("mapgen_dirt", "default:dirt")
-minetest.register_alias("mapgen_sand", "default:sand")
-minetest.register_alias("mapgen_gravel", "default:gravel")
-minetest.register_alias("mapgen_clay", "default:clay")
-minetest.register_alias("mapgen_lava_source", "default:lava_source")
-minetest.register_alias("mapgen_cobble", "default:cobble")
-minetest.register_alias("mapgen_mossycobble", "default:mossycobble")
-minetest.register_alias("mapgen_dirt_with_grass", "default:dirt_with_grass")
-minetest.register_alias("mapgen_junglegrass", "default:junglegrass")
-minetest.register_alias("mapgen_stone_with_coal", "default:stone_with_coal")
-minetest.register_alias("mapgen_stone_with_iron", "default:stone_with_iron")
-minetest.register_alias("mapgen_mese", "default:mese")
-
---
--- Some common functions
+-- Support old code
--
-default.falling_node_names = {}
-
-function nodeupdate_single(p)
- n = minetest.env:get_node(p)
- if default.falling_node_names[n.name] ~= nil then
- p_bottom = {x=p.x, y=p.y-1, z=p.z}
- n_bottom = minetest.env:get_node(p_bottom)
- if n_bottom.name == "air" then
- minetest.env:remove_node(p)
- minetest.env:add_entity(p, "default:falling_"..n.name)
- nodeupdate(p)
- end
- end
-end
-
-function nodeupdate(p)
- for x = -1,1 do
- for y = -1,1 do
- for z = -1,1 do
- p2 = {x=p.x+x, y=p.y+y, z=p.z+z}
- nodeupdate_single(p2)
- end
- end
- end
+function default.spawn_falling_node(p, nodename)
+ spawn_falling_node(p, nodename)
end
---
--- Falling stuff
---
-
+-- Horrible crap to support old code
+-- Don't use this and never do what this does, it's completely wrong!
+-- (More specifically, the client and the C++ code doesn't get the group)
function default.register_falling_node(nodename, texture)
- default.falling_node_names[nodename] = true
- -- Override naming conventions for stuff like :default:falling_default:sand
- minetest.register_entity(":default:falling_"..nodename, {
- -- Static definition
- physical = true,
- collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5},
- visual = "cube",
- textures = {texture,texture,texture,texture,texture,texture},
- -- State
- -- Methods
- on_step = function(self, dtime)
- -- Set gravity
- self.object:setacceleration({x=0, y=-10, z=0})
- -- Turn to actual sand when collides to ground or just move
- local pos = self.object:getpos()
- local bcp = {x=pos.x, y=pos.y-0.7, z=pos.z} -- Position of bottom center point
- local bcn = minetest.env:get_node(bcp)
- if bcn.name ~= "air" then
- -- Turn to a sand node
- local np = {x=bcp.x, y=bcp.y+1, z=bcp.z}
- minetest.env:add_node(np, {name=nodename})
- self.object:remove()
- else
- -- Do nothing
- end
- end
- })
+ minetest.log("error", debug.traceback())
+ minetest.log('error', "WARNING: default.register_falling_node is deprecated")
+ if minetest.registered_nodes[nodename] then
+ minetest.registered_nodes[nodename].groups.falling_node = 1
+ end
end
-default.register_falling_node("default:sand", "default_sand.png")
-default.register_falling_node("default:gravel", "default_gravel.png")
-
--
-- Global callbacks
--
function on_placenode(p, node)
--print("on_placenode")
- nodeupdate(p)
end
minetest.register_on_placenode(on_placenode)
function on_dignode(p, node)
--print("on_dignode")
- nodeupdate(p)
end
minetest.register_on_dignode(on_dignode)
--dump2(minetest.registered_entities)
-- END
+