minetest.register_craft({
- output = 'craft "bucket_empty" 1',
+ output = 'craft "bucket:bucket_empty" 1',
recipe = {
{'craft "steel_ingot"', '', 'craft "steel_ingot"'},
{'', 'craft "steel_ingot"', ''},
}
})
-minetest.register_craftitem("bucket_empty", {
+minetest.register_craftitem("bucket:bucket_empty", {
image = "bucket.png",
stack_max = 1,
liquids_pointable = true,
n = minetest.env:get_node(pointed_thing.under)
if n.name == "water_source" then
minetest.env:add_node(pointed_thing.under, {name="air"})
- player:add_to_inventory_later('craft "bucket_water" 1')
+ player:add_to_inventory_later('craft "bucket:bucket_water" 1')
return true
elseif n.name == "lava_source" then
minetest.env:add_node(pointed_thing.under, {name="air"})
- player:add_to_inventory_later('craft "bucket_lava" 1')
+ player:add_to_inventory_later('craft "bucket:bucket_lava" 1')
return true
end
end
end,
})
-minetest.register_craftitem("bucket_water", {
- image = "bucket_water.png",
+minetest.register_craftitem("bucket:bucket_water", {
+ image = "bucket:bucket_water.png",
stack_max = 1,
liquids_pointable = true,
on_place_on_ground = minetest.craftitem_place_item,
else
minetest.env:add_node(pointed_thing.above, {name="water_source"})
end
- player:add_to_inventory_later('craft "bucket_empty" 1')
+ player:add_to_inventory_later('craft "bucket:bucket_empty" 1')
return true
end
return false
end,
})
-minetest.register_craftitem("bucket_lava", {
- image = "bucket_lava.png",
+minetest.register_craftitem("bucket:bucket_lava", {
+ image = "bucket:bucket_lava.png",
stack_max = 1,
liquids_pointable = true,
on_place_on_ground = minetest.craftitem_place_item,
else
minetest.env:add_node(pointed_thing.above, {name="lava_source"})
end
- player:add_to_inventory_later('craft "bucket_empty" 1')
+ player:add_to_inventory_later('craft "bucket:bucket_empty" 1')
return true
end
return false
--
-- Naming convention for registered textual names
-- ----------------------------------------------
--- "modname_<whatever>"
+-- "modname:<whatever>" (<whatever> can have characters a-zA-Z0-9_)
--
-- This is to prevent conflicting names from corrupting maps and is
-- enforced by the mod loader.
--
-- Example: mod "experimental", ideal item/node/entity name "tnt":
--- -> the name should be "experimental_tnt".
+-- -> the name should be "experimental:tnt".
--
-- Enforcement can be overridden by prefixing the name with ":". This can
-- be used for overriding the registrations of some other mod.
--
+-- Example: Any mod can redefine experimental:tnt by using the name
+-- ":experimental:tnt" when registering it.
+-- (also that mods is required to have "experimental" as a dependency)
+--
-- Default mod uses ":" for maintaining backwards compatibility.
--
-- Textures
n_bottom = minetest.env:get_node(p_bottom)
if n_bottom.name == "air" then
minetest.env:remove_node(p)
- minetest.env:add_luaentity(p, "default_falling_"..n.name)
+ minetest.env:add_luaentity(p, "default:falling_"..n.name)
nodeupdate(p)
end
end
--
function register_falling_node(nodename, texture)
- minetest.register_entity("default_falling_"..nodename, {
+ minetest.register_entity("default:falling_"..nodename, {
-- Static definition
physical = true,
collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5},
-- An example furnace-thing implemented in Lua
-minetest.register_node("experimental_luafurnace", {
+minetest.register_node("experimental:luafurnace", {
tile_images = {"lava.png", "furnace_side.png", "furnace_side.png",
"furnace_side.png", "furnace_side.png", "furnace_front.png"},
--inventory_image = "furnace_front.png",
})
minetest.register_on_placenode(function(pos, newnode, placer)
- if newnode.name == "experimental_luafurnace" then
+ if newnode.name == "experimental:luafurnace" then
print("get_meta");
local meta = minetest.env:get_meta(pos)
print("inventory_set_list");
end)
minetest.register_abm({
- nodenames = {"experimental_luafurnace"},
+ nodenames = {"experimental:luafurnace"},
interval = 1.0,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
})
minetest.register_craft({
- output = 'node "experimental_luafurnace" 1',
+ output = 'node "experimental:luafurnace" 1',
recipe = {
{'node "cobble"', 'node "cobble"', 'node "cobble"'},
{'node "cobble"', 'node "cobble"', 'node "cobble"'},
}
})
-minetest.register_node("experimental_somenode", {
+minetest.register_node("experimental:somenode", {
tile_images = {"lava.png", "mese.png", "stone.png", "grass.png", "cobble.png", "tree_top.png"},
inventory_image = "treeprop.png",
material = {
--
minetest.register_craft({
- output = 'node "experimental_tnt" 4',
+ output = 'node "experimental:tnt" 4',
recipe = {
{'node "wood" 1'},
{'craft "lump_of_coal" 1'},
}
})
-minetest.register_node("experimental_tnt", {
+minetest.register_node("experimental:tnt", {
tile_images = {"tnt_top.png", "tnt_bottom.png", "tnt_side.png", "tnt_side.png", "tnt_side.png", "tnt_side.png"},
inventory_image = "tnt_side.png",
dug_item = '', -- Get nothing
})
minetest.register_on_punchnode(function(p, node)
- if node.name == "experimental_tnt" then
+ if node.name == "experimental:tnt" then
minetest.env:remove_node(p)
- minetest.env:add_luaentity(p, "experimental_tnt")
+ minetest.env:add_luaentity(p, "experimental:tnt")
nodeupdate(p)
end
end)
--print("TNT dump: "..dump(TNT))
--print("Registering TNT");
-minetest.register_entity("experimental_tnt", TNT)
+minetest.register_entity("experimental:tnt", TNT)
--
-- A test entity for testing animated and yaw-modulated sprites
--
-minetest.register_entity("experimental_testentity", {
+minetest.register_entity("experimental:testentity", {
-- Static definition
physical = true, -- Collides with things
-- weight = 5,
// For __builtin, anything goes
if(modname == "__builtin")
return;
-
- if(name.substr(0, modname.size()+1) != modname + "_")
+
+ if(name.substr(0, modname.size()+1) != modname + ":")
+ throw LuaError(L, std::string("Name \"")+name
+ +"\" does not follow naming conventions: "
+ +"\"modname:\" or \":\" prefix required)");
+
+ std::string subname = name.substr(modname.size()+1);
+ if(!string_allowed(subname, "abcdefghijklmnopqrstuvwxyz"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_"))
throw LuaError(L, std::string("Name \"")+name
+"\" does not follow naming conventions: "
- +"\"modname_\" or \":\" prefix required)");
+ +"\"contains unallowed characters)");
}
static v3f readFloatPos(lua_State *L, int index)