Change naming convention to be modname:* instead of modname_* (sorry modders!)

This commit is contained in:
Perttu Ahola 2011-12-03 11:41:52 +02:00
parent 1c785c32ef
commit 760416b81f
4 changed files with 39 additions and 28 deletions

View File

@ -1,12 +1,12 @@
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,
@ -16,11 +16,11 @@ minetest.register_craftitem("bucket_empty", {
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
@ -28,8 +28,8 @@ minetest.register_craftitem("bucket_empty", {
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,
@ -43,15 +43,15 @@ minetest.register_craftitem("bucket_water", {
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,
@ -65,7 +65,7 @@ minetest.register_craftitem("bucket_lava", {
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

View File

@ -21,17 +21,21 @@
--
-- 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
@ -1426,7 +1430,7 @@ function nodeupdate_single(p)
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
@ -1448,7 +1452,7 @@ 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},

View File

@ -4,7 +4,7 @@
-- 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",
@ -15,7 +15,7 @@ minetest.register_node("experimental_luafurnace", {
})
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");
@ -42,7 +42,7 @@ minetest.register_on_placenode(function(pos, newnode, placer)
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)
@ -97,7 +97,7 @@ minetest.register_abm({
})
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"'},
@ -132,7 +132,7 @@ minetest.register_craft({
}
})
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 = {
@ -151,7 +151,7 @@ minetest.register_node("experimental_somenode", {
--
minetest.register_craft({
output = 'node "experimental_tnt" 4',
output = 'node "experimental:tnt" 4',
recipe = {
{'node "wood" 1'},
{'craft "lump_of_coal" 1'},
@ -159,7 +159,7 @@ minetest.register_craft({
}
})
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
@ -169,9 +169,9 @@ minetest.register_node("experimental_tnt", {
})
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)
@ -235,13 +235,13 @@ 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,

View File

@ -154,10 +154,17 @@ void check_modname_prefix(lua_State *L, std::string &name)
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)");
+"\"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: "
+"\"contains unallowed characters)");
}
static v3f readFloatPos(lua_State *L, int index)