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

master
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({ minetest.register_craft({
output = 'craft "bucket_empty" 1', output = 'craft "bucket:bucket_empty" 1',
recipe = { recipe = {
{'craft "steel_ingot"', '', 'craft "steel_ingot"'}, {'craft "steel_ingot"', '', 'craft "steel_ingot"'},
{'', 'craft "steel_ingot"', ''}, {'', 'craft "steel_ingot"', ''},
} }
}) })
minetest.register_craftitem("bucket_empty", { minetest.register_craftitem("bucket:bucket_empty", {
image = "bucket.png", image = "bucket.png",
stack_max = 1, stack_max = 1,
liquids_pointable = true, liquids_pointable = true,
@ -16,11 +16,11 @@ minetest.register_craftitem("bucket_empty", {
n = minetest.env:get_node(pointed_thing.under) n = minetest.env:get_node(pointed_thing.under)
if n.name == "water_source" then if n.name == "water_source" then
minetest.env:add_node(pointed_thing.under, {name="air"}) 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 return true
elseif n.name == "lava_source" then elseif n.name == "lava_source" then
minetest.env:add_node(pointed_thing.under, {name="air"}) 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 return true
end end
end end
@ -28,8 +28,8 @@ minetest.register_craftitem("bucket_empty", {
end, end,
}) })
minetest.register_craftitem("bucket_water", { minetest.register_craftitem("bucket:bucket_water", {
image = "bucket_water.png", image = "bucket:bucket_water.png",
stack_max = 1, stack_max = 1,
liquids_pointable = true, liquids_pointable = true,
on_place_on_ground = minetest.craftitem_place_item, on_place_on_ground = minetest.craftitem_place_item,
@ -43,15 +43,15 @@ minetest.register_craftitem("bucket_water", {
else else
minetest.env:add_node(pointed_thing.above, {name="water_source"}) minetest.env:add_node(pointed_thing.above, {name="water_source"})
end end
player:add_to_inventory_later('craft "bucket_empty" 1') player:add_to_inventory_later('craft "bucket:bucket_empty" 1')
return true return true
end end
return false return false
end, end,
}) })
minetest.register_craftitem("bucket_lava", { minetest.register_craftitem("bucket:bucket_lava", {
image = "bucket_lava.png", image = "bucket:bucket_lava.png",
stack_max = 1, stack_max = 1,
liquids_pointable = true, liquids_pointable = true,
on_place_on_ground = minetest.craftitem_place_item, on_place_on_ground = minetest.craftitem_place_item,
@ -65,7 +65,7 @@ minetest.register_craftitem("bucket_lava", {
else else
minetest.env:add_node(pointed_thing.above, {name="lava_source"}) minetest.env:add_node(pointed_thing.above, {name="lava_source"})
end end
player:add_to_inventory_later('craft "bucket_empty" 1') player:add_to_inventory_later('craft "bucket:bucket_empty" 1')
return true return true
end end
return false return false

View File

@ -21,17 +21,21 @@
-- --
-- Naming convention for registered textual names -- 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 -- This is to prevent conflicting names from corrupting maps and is
-- enforced by the mod loader. -- enforced by the mod loader.
-- --
-- Example: mod "experimental", ideal item/node/entity name "tnt": -- 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 -- Enforcement can be overridden by prefixing the name with ":". This can
-- be used for overriding the registrations of some other mod. -- 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. -- Default mod uses ":" for maintaining backwards compatibility.
-- --
-- Textures -- Textures
@ -1426,7 +1430,7 @@ function nodeupdate_single(p)
n_bottom = minetest.env:get_node(p_bottom) n_bottom = minetest.env:get_node(p_bottom)
if n_bottom.name == "air" then if n_bottom.name == "air" then
minetest.env:remove_node(p) 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) nodeupdate(p)
end end
end end
@ -1448,7 +1452,7 @@ end
-- --
function register_falling_node(nodename, texture) function register_falling_node(nodename, texture)
minetest.register_entity("default_falling_"..nodename, { minetest.register_entity("default:falling_"..nodename, {
-- Static definition -- Static definition
physical = true, physical = true,
collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5}, 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 -- 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", tile_images = {"lava.png", "furnace_side.png", "furnace_side.png",
"furnace_side.png", "furnace_side.png", "furnace_front.png"}, "furnace_side.png", "furnace_side.png", "furnace_front.png"},
--inventory_image = "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) minetest.register_on_placenode(function(pos, newnode, placer)
if newnode.name == "experimental_luafurnace" then if newnode.name == "experimental:luafurnace" then
print("get_meta"); print("get_meta");
local meta = minetest.env:get_meta(pos) local meta = minetest.env:get_meta(pos)
print("inventory_set_list"); print("inventory_set_list");
@ -42,7 +42,7 @@ minetest.register_on_placenode(function(pos, newnode, placer)
end) end)
minetest.register_abm({ minetest.register_abm({
nodenames = {"experimental_luafurnace"}, nodenames = {"experimental:luafurnace"},
interval = 1.0, interval = 1.0,
chance = 1, chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider) action = function(pos, node, active_object_count, active_object_count_wider)
@ -97,7 +97,7 @@ minetest.register_abm({
}) })
minetest.register_craft({ minetest.register_craft({
output = 'node "experimental_luafurnace" 1', output = 'node "experimental:luafurnace" 1',
recipe = { recipe = {
{'node "cobble"', 'node "cobble"', 'node "cobble"'}, {'node "cobble"', 'node "cobble"', 'node "cobble"'},
{'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"}, tile_images = {"lava.png", "mese.png", "stone.png", "grass.png", "cobble.png", "tree_top.png"},
inventory_image = "treeprop.png", inventory_image = "treeprop.png",
material = { material = {
@ -151,7 +151,7 @@ minetest.register_node("experimental_somenode", {
-- --
minetest.register_craft({ minetest.register_craft({
output = 'node "experimental_tnt" 4', output = 'node "experimental:tnt" 4',
recipe = { recipe = {
{'node "wood" 1'}, {'node "wood" 1'},
{'craft "lump_of_coal" 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"}, 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", inventory_image = "tnt_side.png",
dug_item = '', -- Get nothing dug_item = '', -- Get nothing
@ -169,9 +169,9 @@ minetest.register_node("experimental_tnt", {
}) })
minetest.register_on_punchnode(function(p, node) 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:remove_node(p)
minetest.env:add_luaentity(p, "experimental_tnt") minetest.env:add_luaentity(p, "experimental:tnt")
nodeupdate(p) nodeupdate(p)
end end
end) end)
@ -235,13 +235,13 @@ end
--print("TNT dump: "..dump(TNT)) --print("TNT dump: "..dump(TNT))
--print("Registering 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 -- A test entity for testing animated and yaw-modulated sprites
-- --
minetest.register_entity("experimental_testentity", { minetest.register_entity("experimental:testentity", {
-- Static definition -- Static definition
physical = true, -- Collides with things physical = true, -- Collides with things
-- weight = 5, -- weight = 5,

View File

@ -154,10 +154,17 @@ void check_modname_prefix(lua_State *L, std::string &name)
if(modname == "__builtin") if(modname == "__builtin")
return; return;
if(name.substr(0, modname.size()+1) != modname + "_") if(name.substr(0, modname.size()+1) != modname + ":")
throw LuaError(L, std::string("Name \"")+name throw LuaError(L, std::string("Name \"")+name
+"\" does not follow naming conventions: " +"\" 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) static v3f readFloatPos(lua_State *L, int index)