For example, if I have a mod named 'stairs' in ~/.minetest/mods/minetest/stairs/, my stairs mod will not run, but the default stairs mod in /usr/share/minetest/games/minetest_game/mods/stairs will.
could we get this changed so it checks the world directory first (~/.minetest/worlds/WORLDNAME/mods/), then the per user folder (~/.minetest/mods/minetest/), then the global folder (/usr/share/minetest/games/GAME/mods)?
Also, the stairs mod needs to use minetest.get_current_modname() in it's stairs.register_* functions in order to play nice with other mods.
code like this:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
-- add glass and desert stone stairs and slabs
stairs.register_stair_and_slab(
"desert_stone",
"default:desert_stone",
{cracky=3},
{"default_desert_stone.png"},
"Desert Stone Stair",
"Desert Stone Slab")
stairs.register_stair_and_slab(
"glass",
"default:glass",
{snappy=2,cracky=3,oddly_breakable_by_hand=3},
{"default_glass.png"},
"Glass Stair",
"Glass Slab")
in another mod gives errors like this:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
00:04:52: ERROR[main]: ========== ERROR FROM LUA ===========
00:04:52: ERROR[main]: Failed to load and run script from
00:04:52: ERROR[main]: /home/user/.minetest/mods/minetest/llubnek/init.lua:
00:04:52: ERROR[main]: /usr/share/minetest/builtin/misc_register.lua:62: Name stairs:stair_desert_stone does not follow naming conventions: "modname:" or ":" prefix required
00:04:52: ERROR[main]: stack traceback:
00:04:52: ERROR[main]: [C]: in function 'error'
00:04:52: ERROR[main]: /usr/share/minetest/builtin/misc_register.lua:62: in function 'check_modname_prefix'
00:04:52: ERROR[main]: /usr/share/minetest/builtin/misc_register.lua:98: in function 'register_item'
00:04:52: ERROR[main]: /usr/share/minetest/builtin/misc_register.lua:154: in function 'register_node'
00:04:52: ERROR[main]: ...re/minetest/games/minetest_game/mods/stairs/init.lua:8: in function 'register_stair'
00:04:52: ERROR[main]: ...re/minetest/games/minetest_game/mods/stairs/init.lua:114: in function 'register_stair_and_slab'
00:04:52: ERROR[main]: ...ome/user/.minetest/mods/minetest/llubnek/init.lua:36: in main chunk
00:04:52: ERROR[main]: =======END OF ERROR FROM LUA ========
here's a modified init.lua that should fix this (maybe... see first bug for why this isn't tested):
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
-- Minetest 0.4 mod: stairs
-- See README.txt for licensing and other information.
stairs = {}
-- Node will be called stairs:stair_<subname>
function stairs.register_stair(subname, recipeitem, groups, images, description)
minetest.register_node(minetest.get_current_modname()..":stair_" .. subname, {
description = description,
drawtype = "nodebox",
tiles = images,
paramtype = "light",
paramtype2 = "facedir",
is_ground_content = true,
groups = groups,
node_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, 0, 0.5},
{-0.5, 0, 0, 0.5, 0.5, 0.5},
},
},
})
minetest.register_craft({
output = minetest.get_current_modname()..':stair_' .. subname .. ' 4',
recipe = {
{recipeitem, "", ""},
{recipeitem, recipeitem, ""},
{recipeitem, recipeitem, recipeitem},
},
})
-- Flipped recipe for the silly minecrafters
minetest.register_craft({
output = minetest.get_current_modname()..':stair_' .. subname .. ' 4',
recipe = {
{"", "", recipeitem},
{"", recipeitem, recipeitem},
{recipeitem, recipeitem, recipeitem},
},
})
end
-- Node will be called stairs:slab_<subname>
function stairs.register_slab(subname, recipeitem, groups, images, description)
minetest.register_node(minetest.get_current_modname()..":slab_" .. subname, {
description = description,
drawtype = "nodebox",
tiles = images,
paramtype = "light",
is_ground_content = true,
groups = groups,
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
},
selection_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
},
on_place = function(itemstack, placer, pointed_thing)
if pointed_thing.type ~= "node" then
return itemstack
end
-- If it's being placed on an another similar one, replace it with
-- a full block
local slabpos = nil
local slabnode = nil
local p0 = pointed_thing.under
local p1 = pointed_thing.above
local n0 = minetest.env:get_node(p0)
local n1 = minetest.env:get_node(p1)
if n0.name == minetest.get_current_modname()..":slab_" .. subname then
slabpos = p0
slabnode = n0
elseif n1.name == minetest.get_current_modname()..":slab_" .. subname then
slabpos = p1
slabnode = n1
end
if slabpos then
-- Remove the slab at slabpos
minetest.env:remove_node(slabpos)
-- Make a fake stack of a single item and try to place it
local fakestack = ItemStack(recipeitem)
pointed_thing.above = slabpos
fakestack = minetest.item_place(fakestack, placer, pointed_thing)
-- If the item was taken from the fake stack, decrement original
if not fakestack or fakestack:is_empty() then
itemstack:take_item(1)
-- Else put old node back
else
minetest.env:set_node(slabpos, slabnode)
end
return itemstack
end
-- Otherwise place regularly
return minetest.item_place(itemstack, placer, pointed_thing)
end,
})
minetest.register_craft({
output = minetest.get_current_modname()..':slab_' .. subname .. ' 3',
recipe = {
{recipeitem, recipeitem, recipeitem},
},
})
end
-- Nodes will be called stairs:{stair,slab}_<subname>
function stairs.register_stair_and_slab(subname, recipeitem, groups, images, desc_stair, desc_slab)
stairs.register_stair(subname, recipeitem, groups, images, desc_stair)
stairs.register_slab(subname, recipeitem, groups, images, desc_slab)
end
stairs.register_stair_and_slab("wood", "default:wood",
{snappy=2,choppy=2,oddly_breakable_by_hand=2},
{"default_wood.png"},
"Wooden stair",
"Wooden slab")
stairs.register_stair_and_slab("stone", "default:stone",
{cracky=3},
{"default_stone.png"},
"Stone stair",
"Stone slab")
stairs.register_stair_and_slab("cobble", "default:cobble",
{cracky=3},
{"default_cobble.png"},
"Cobble stair",
"Cobble slab")
stairs.register_stair_and_slab("brick", "default:brick",
{cracky=3},
{"default_brick.png"},
"Brick stair",
"Brick slab")
stairs.register_stair_and_slab("sandstone", "default:sandstone",
{crumbly=2,cracky=2},
{"default_sandstone.png"},
"Sandstone stair",
"Sandstone slab")