-- dump2(obj, name="_", dumped={})
-- dump(obj, dumped={})
--
--- Textures:
--- Mods should prefix their textures with modname_, eg. given the mod
--- name "foomod", a texture could be called "foomod_superfurnace.png"
--- Due to historical reasons, the default mod does not follow this rule.
+-- Naming convention for registered textual names
+-- ----------------------------------------------
+-- "modname_<whatever>"
+--
+-- 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".
+--
+-- Enforcement can be overridden by prefixing the name with ":". This can
+-- be used for overriding the registrations of some other mod.
+--
+-- Default mod uses ":" for maintaining backwards compatibility.
+--
+-- Textures
+-- --------
+-- Mods should generally prefix their textures with modname_, eg. given
+-- the mod name "foomod", a texture could be called "foomod_superfurnace.png"
+--
+-- This is not crucial and a conflicting name will not corrupt maps.
+--
+-- Representations of simple things
+-- --------------------------------
--
-- MapNode representation:
-- {name="name", param1=num, param2=num}
-- }
--
-- Craftitem definition options:
--- minetest.register_craftitem("name", {
+-- minetest.register_craftitem(":name", {
-- image = "image.png",
-- stack_max = <maximum number of items in stack>,
-- cookresult_item = itemstring (result of cooking),
-- Tool definition
--
-minetest.register_tool("WPick", {
+minetest.register_tool(":WPick", {
image = "tool_woodpick.png",
basetime = 2.0,
dt_weight = 0,
dd_crumbliness = 0,
dd_cuttability = 0,
})
-minetest.register_tool("STPick", {
+minetest.register_tool(":STPick", {
image = "tool_stonepick.png",
basetime = 1.5,
dt_weight = 0,
dd_crumbliness = 0,
dd_cuttability = 0,
})
-minetest.register_tool("SteelPick", {
+minetest.register_tool(":SteelPick", {
image = "tool_steelpick.png",
basetime = 1.0,
dt_weight = 0,
dd_crumbliness = 0,
dd_cuttability = 0,
})
-minetest.register_tool("MesePick", {
+minetest.register_tool(":MesePick", {
image = "tool_mesepick.png",
basetime = 0,
dt_weight = 0,
dd_crumbliness = 0,
dd_cuttability = 0,
})
-minetest.register_tool("WShovel", {
+minetest.register_tool(":WShovel", {
image = "tool_woodshovel.png",
basetime = 2.0,
dt_weight = 0.5,
dd_crumbliness = 0,
dd_cuttability = 0,
})
-minetest.register_tool("STShovel", {
+minetest.register_tool(":STShovel", {
image = "tool_stoneshovel.png",
basetime = 1.5,
dt_weight = 0.5,
dd_crumbliness = 0,
dd_cuttability = 0,
})
-minetest.register_tool("SteelShovel", {
+minetest.register_tool(":SteelShovel", {
image = "tool_steelshovel.png",
basetime = 1.0,
dt_weight = 0.5,
dd_crumbliness = 0,
dd_cuttability = 0,
})
-minetest.register_tool("WAxe", {
+minetest.register_tool(":WAxe", {
image = "tool_woodaxe.png",
basetime = 2.0,
dt_weight = 0.5,
dd_crumbliness = 0,
dd_cuttability = 0,
})
-minetest.register_tool("STAxe", {
+minetest.register_tool(":STAxe", {
image = "tool_stoneaxe.png",
basetime = 1.5,
dt_weight = 0.5,
dd_crumbliness = 0,
dd_cuttability = 0,
})
-minetest.register_tool("SteelAxe", {
+minetest.register_tool(":SteelAxe", {
image = "tool_steelaxe.png",
basetime = 1.0,
dt_weight = 0.5,
dd_crumbliness = 0,
dd_cuttability = 0,
})
-minetest.register_tool("WSword", {
+minetest.register_tool(":WSword", {
image = "tool_woodsword.png",
basetime = 3.0,
dt_weight = 3,
dd_crumbliness = 0,
dd_cuttability = 0,
})
-minetest.register_tool("STSword", {
+minetest.register_tool(":STSword", {
image = "tool_stonesword.png",
basetime = 2.5,
dt_weight = 3,
dd_crumbliness = 0,
dd_cuttability = 0,
})
-minetest.register_tool("SteelSword", {
+minetest.register_tool(":SteelSword", {
image = "tool_steelsword.png",
basetime = 2.0,
dt_weight = 3,
dd_cuttability = 0,
})
-- The hand
-minetest.register_tool("", {
+minetest.register_tool(":", {
image = "",
basetime = 0.5,
dt_weight = 1,
-- Legacy nodes
-minetest.register_node("stone", {
+minetest.register_node(":stone", {
tile_images = {"stone.png"},
inventory_image = inventorycube("stone.png"),
paramtype = "mineral",
dug_item = 'node "cobble" 1',
})
-minetest.register_node("dirt_with_grass", {
+minetest.register_node(":dirt_with_grass", {
tile_images = {"grass.png", "mud.png", "mud.png^grass_side.png"},
inventory_image = inventorycube("mud.png^grass_side.png"),
is_ground_content = true,
dug_item = 'node "dirt" 1',
})
-minetest.register_node("dirt_with_grass_footsteps", {
+minetest.register_node(":dirt_with_grass_footsteps", {
tile_images = {"grass_footsteps.png", "mud.png", "mud.png^grass_side.png"},
inventory_image = "grass_footsteps.png",
is_ground_content = true,
dug_item = 'node "dirt" 1',
})
-minetest.register_node("dirt", {
+minetest.register_node(":dirt", {
tile_images = {"mud.png"},
inventory_image = inventorycube("mud.png"),
is_ground_content = true,
material = digprop_dirtlike(1.0),
})
-minetest.register_node("sand", {
+minetest.register_node(":sand", {
tile_images = {"sand.png"},
inventory_image = inventorycube("sand.png"),
is_ground_content = true,
cookresult_item = 'node "glass" 1',
})
-minetest.register_node("gravel", {
+minetest.register_node(":gravel", {
tile_images = {"gravel.png"},
inventory_image = inventorycube("gravel.png"),
is_ground_content = true,
material = digprop_gravellike(1.0),
})
-minetest.register_node("sandstone", {
+minetest.register_node(":sandstone", {
tile_images = {"sandstone.png"},
inventory_image = inventorycube("sandstone.png"),
is_ground_content = true,
dug_item = 'node "sand" 1', -- FIXME is this intentional?
})
-minetest.register_node("clay", {
+minetest.register_node(":clay", {
tile_images = {"clay.png"},
inventory_image = inventorycube("clay.png"),
is_ground_content = true,
dug_item = 'craft "lump_of_clay" 4',
})
-minetest.register_node("brick", {
+minetest.register_node(":brick", {
tile_images = {"brick.png"},
inventory_image = inventorycube("brick.png"),
is_ground_content = true,
dug_item = 'craft "clay_brick" 4',
})
-minetest.register_node("tree", {
+minetest.register_node(":tree", {
tile_images = {"tree_top.png", "tree_top.png", "tree.png"},
inventory_image = inventorycube("tree_top.png", "tree.png", "tree.png"),
is_ground_content = true,
furnace_burntime = 30,
})
-minetest.register_node("jungletree", {
+minetest.register_node(":jungletree", {
tile_images = {"jungletree_top.png", "jungletree_top.png", "jungletree.png"},
inventory_image = inventorycube("jungletree_top.png", "jungletree.png", "jungletree.png"),
is_ground_content = true,
furnace_burntime = 30,
})
-minetest.register_node("junglegrass", {
+minetest.register_node(":junglegrass", {
drawtype = "plantlike",
visual_scale = 1.3,
tile_images = {"junglegrass.png"},
furnace_burntime = 2,
})
-minetest.register_node("leaves", {
+minetest.register_node(":leaves", {
drawtype = "allfaces_optional",
visual_scale = 1.3,
tile_images = {"leaves.png"},
furnace_burntime = 1,
})
-minetest.register_node("cactus", {
+minetest.register_node(":cactus", {
tile_images = {"cactus_top.png", "cactus_top.png", "cactus_side.png"},
inventory_image = inventorycube("cactus_top.png", "cactus_side.png", "cactus_side.png"),
is_ground_content = true,
furnace_burntime = 15,
})
-minetest.register_node("papyrus", {
+minetest.register_node(":papyrus", {
drawtype = "plantlike",
tile_images = {"papyrus.png"},
inventory_image = "papyrus.png",
furnace_burntime = 1,
})
-minetest.register_node("bookshelf", {
+minetest.register_node(":bookshelf", {
tile_images = {"wood.png", "wood.png", "bookshelf.png"},
-- FIXME: inventorycube only cares for the first texture
--inventory_image = inventorycube("wood.png", "bookshelf.png", "bookshelf.png")
furnace_burntime = 30,
})
-minetest.register_node("glass", {
+minetest.register_node(":glass", {
drawtype = "glasslike",
tile_images = {"glass.png"},
inventory_image = inventorycube("glass.png"),
material = digprop_glasslike(1.0),
})
-minetest.register_node("wooden_fence", {
+minetest.register_node(":wooden_fence", {
drawtype = "fencelike",
tile_images = {"wood.png"},
inventory_image = "fence.png",
material = digprop_woodlike(0.75),
})
-minetest.register_node("rail", {
+minetest.register_node(":rail", {
drawtype = "raillike",
tile_images = {"rail.png", "rail_curved.png", "rail_t_junction.png", "rail_crossing.png"},
inventory_image = "rail.png",
material = digprop_dirtlike(0.75),
})
-minetest.register_node("ladder", {
+minetest.register_node(":ladder", {
drawtype = "signlike",
tile_images = {"ladder.png"},
inventory_image = "ladder.png",
material = digprop_woodlike(0.5),
})
-minetest.register_node("coalstone", {
+minetest.register_node(":coalstone", {
tile_images = {"stone.png^mineral_coal.png"},
inventory_image = "stone.png^mineral_coal.png",
is_ground_content = true,
material = digprop_stonelike(1.5),
})
-minetest.register_node("wood", {
+minetest.register_node(":wood", {
tile_images = {"wood.png"},
inventory_image = inventorycube("wood.png"),
is_ground_content = true,
material = digprop_woodlike(0.75),
})
-minetest.register_node("mese", {
+minetest.register_node(":mese", {
tile_images = {"mese.png"},
inventory_image = inventorycube("mese.png"),
is_ground_content = true,
material = digprop_stonelike(0.5),
})
-minetest.register_node("cloud", {
+minetest.register_node(":cloud", {
tile_images = {"cloud.png"},
inventory_image = inventorycube("cloud.png"),
is_ground_content = true,
})
-minetest.register_node("water_flowing", {
+minetest.register_node(":water_flowing", {
drawtype = "flowingliquid",
tile_images = {"water.png"},
alpha = WATER_ALPHA,
},
})
-minetest.register_node("water_source", {
+minetest.register_node(":water_source", {
drawtype = "liquid",
tile_images = {"water.png"},
alpha = WATER_ALPHA,
},
})
-minetest.register_node("lava_flowing", {
+minetest.register_node(":lava_flowing", {
drawtype = "flowingliquid",
tile_images = {"lava.png"},
inventory_image = inventorycube("lava.png"),
},
})
-minetest.register_node("lava_source", {
+minetest.register_node(":lava_source", {
drawtype = "liquid",
tile_images = {"lava.png"},
inventory_image = inventorycube("lava.png"),
furnace_burntime = 60,
})
-minetest.register_node("torch", {
+minetest.register_node(":torch", {
drawtype = "torchlike",
tile_images = {"torch_on_floor.png", "torch_on_ceiling.png", "torch.png"},
inventory_image = "torch_on_floor.png",
furnace_burntime = 4,
})
-minetest.register_node("sign_wall", {
+minetest.register_node(":sign_wall", {
drawtype = "signlike",
tile_images = {"sign_wall.png"},
inventory_image = "sign_wall.png",
furnace_burntime = 10,
})
-minetest.register_node("chest", {
+minetest.register_node(":chest", {
tile_images = {"chest_top.png", "chest_top.png", "chest_side.png",
"chest_side.png", "chest_side.png", "chest_front.png"},
inventory_image = "chest_top.png",
furnace_burntime = 30,
})
-minetest.register_node("locked_chest", {
+minetest.register_node(":locked_chest", {
tile_images = {"chest_top.png", "chest_top.png", "chest_side.png",
"chest_side.png", "chest_side.png", "chest_lock.png"},
inventory_image = "chest_lock.png",
furnace_burntime = 30,
})
-minetest.register_node("furnace", {
+minetest.register_node(":furnace", {
tile_images = {"furnace_side.png", "furnace_side.png", "furnace_side.png",
"furnace_side.png", "furnace_side.png", "furnace_front.png"},
inventory_image = "furnace_front.png",
material = digprop_stonelike(3.0),
})
-minetest.register_node("cobble", {
+minetest.register_node(":cobble", {
tile_images = {"cobble.png"},
inventory_image = inventorycube("cobble.png"),
is_ground_content = true,
material = digprop_stonelike(0.9),
})
-minetest.register_node("mossycobble", {
+minetest.register_node(":mossycobble", {
tile_images = {"mossycobble.png"},
inventory_image = inventorycube("mossycobble.png"),
is_ground_content = true,
material = digprop_stonelike(0.8),
})
-minetest.register_node("steelblock", {
+minetest.register_node(":steelblock", {
tile_images = {"steel_block.png"},
inventory_image = inventorycube("steel_block.png"),
is_ground_content = true,
material = digprop_stonelike(5.0),
})
-minetest.register_node("nyancat", {
+minetest.register_node(":nyancat", {
tile_images = {"nc_side.png", "nc_side.png", "nc_side.png",
"nc_side.png", "nc_back.png", "nc_front.png"},
inventory_image = "nc_front.png",
furnace_burntime = 1,
})
-minetest.register_node("nyancat_rainbow", {
+minetest.register_node(":nyancat_rainbow", {
tile_images = {"nc_rb.png"},
inventory_image = "nc_rb.png",
material = digprop_stonelike(3.0),
furnace_burntime = 1,
})
-minetest.register_node("sapling", {
+minetest.register_node(":sapling", {
drawtype = "plantlike",
visual_scale = 1.0,
tile_images = {"sapling.png"},
furnace_burntime = 10,
})
-minetest.register_node("apple", {
+minetest.register_node(":apple", {
drawtype = "plantlike",
visual_scale = 1.0,
tile_images = {"apple.png"},
-- Crafting items
--
-minetest.register_craftitem("Stick", {
+minetest.register_craftitem(":Stick", {
image = "stick.png",
--furnace_burntime = ...,
on_place_on_ground = minetest.craftitem_place_item,
})
-minetest.register_craftitem("paper", {
+minetest.register_craftitem(":paper", {
image = "paper.png",
on_place_on_ground = minetest.craftitem_place_item,
})
-minetest.register_craftitem("book", {
+minetest.register_craftitem(":book", {
image = "book.png",
on_place_on_ground = minetest.craftitem_place_item,
})
-minetest.register_craftitem("lump_of_coal", {
+minetest.register_craftitem(":lump_of_coal", {
image = "lump_of_coal.png",
furnace_burntime = 40;
on_place_on_ground = minetest.craftitem_place_item,
})
-minetest.register_craftitem("lump_of_iron", {
+minetest.register_craftitem(":lump_of_iron", {
image = "lump_of_iron.png",
cookresult_item = 'craft "steel_ingot" 1',
on_place_on_ground = minetest.craftitem_place_item,
})
-minetest.register_craftitem("lump_of_clay", {
+minetest.register_craftitem(":lump_of_clay", {
image = "lump_of_clay.png",
cookresult_item = 'craft "clay_brick" 1',
on_place_on_ground = minetest.craftitem_place_item,
})
-minetest.register_craftitem("steel_ingot", {
+minetest.register_craftitem(":steel_ingot", {
image = "steel_ingot.png",
on_place_on_ground = minetest.craftitem_place_item,
})
-minetest.register_craftitem("clay_brick", {
+minetest.register_craftitem(":clay_brick", {
image = "clay_brick.png",
on_place_on_ground = minetest.craftitem_place_item,
})
-minetest.register_craftitem("rat", {
+minetest.register_craftitem(":rat", {
image = "rat.png",
cookresult_item = 'craft "cooked_rat" 1',
on_drop = function(item, dropper, pos)
end,
})
-minetest.register_craftitem("cooked_rat", {
+minetest.register_craftitem(":cooked_rat", {
image = "cooked_rat.png",
cookresult_item = 'craft "scorched_stuff" 1',
on_place_on_ground = minetest.craftitem_place_item,
on_use = minetest.craftitem_eat(6),
})
-minetest.register_craftitem("scorched_stuff", {
+minetest.register_craftitem(":scorched_stuff", {
image = "scorched_stuff.png",
on_place_on_ground = minetest.craftitem_place_item,
})
-minetest.register_craftitem("firefly", {
+minetest.register_craftitem(":firefly", {
image = "firefly.png",
on_drop = function(item, dropper, pos)
minetest.env:add_firefly(pos)
end,
})
-minetest.register_craftitem("apple", {
+minetest.register_craftitem(":apple", {
image = "apple.png",
on_place_on_ground = minetest.craftitem_place_item,
on_use = minetest.craftitem_eat(4),
})
-minetest.register_craftitem("apple_iron", {
+minetest.register_craftitem(":apple_iron", {
image = "apple_iron.png",
on_place_on_ground = minetest.craftitem_place_item,
on_use = minetest.craftitem_eat(8),
n_bottom = minetest.env:get_node(p_bottom)
if n_bottom.name == "air" then
minetest.env:remove_node(p)
- minetest.env:add_luaentity(p, "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("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},
minetest.register_globalstep(on_step)
function on_placenode(p, node)
- print("on_placenode")
+ --print("on_placenode")
nodeupdate(p)
end
minetest.register_on_placenode(on_placenode)
function on_dignode(p, node)
- print("on_dignode")
+ --print("on_dignode")
nodeupdate(p)
end
minetest.register_on_dignode(on_dignode)
function on_punchnode(p, node)
- print("on_punchnode")
- if node.name == "TNT" then
- minetest.env:remove_node(p)
- minetest.env:add_luaentity(p, "TNT")
- --minetest.env:add_luaentity(p, "testentity")
- --minetest.env:add_firefly(p)
- nodeupdate(p)
- end
end
minetest.register_on_punchnode(on_punchnode)
}
};
+class ModNameStorer
+{
+private:
+ lua_State *L;
+public:
+ ModNameStorer(lua_State *L_, const std::string modname):
+ L(L_)
+ {
+ // Store current modname in registry
+ lua_pushstring(L, modname.c_str());
+ lua_setfield(L, LUA_REGISTRYINDEX, "minetest_current_modname");
+ }
+ ~ModNameStorer()
+ {
+ // Clear current modname in registry
+ lua_pushnil(L);
+ lua_setfield(L, LUA_REGISTRYINDEX, "minetest_current_modname");
+ }
+};
+
+std::string get_current_modname(lua_State *L)
+{
+ lua_getfield(L, LUA_REGISTRYINDEX, "minetest_current_modname");
+ std::string modname = "";
+ if(lua_type(L, -1) == LUA_TSTRING)
+ modname = lua_tostring(L, -1);
+ lua_pop(L, 1);
+ return modname;
+}
+
+void check_modname_prefix(lua_State *L, std::string &name)
+{
+ if(name.size() == 0)
+ throw LuaError(L, std::string("Name is empty"));
+
+ if(name[0] == ':'){
+ name = name.substr(1);
+ return;
+ }
+
+ std::string modname = get_current_modname(L);
+ assert(modname != "");
+
+ // For __builtin, anything goes
+ if(modname == "__builtin")
+ return;
+
+ if(name.substr(0, modname.size()+1) != modname + "_")
+ throw LuaError(L, std::string("Name \"")+name
+ +"\" does not follow naming conventions: "
+ +"\"modname_\" or \":\" prefix required)");
+}
+
static v3f readFloatPos(lua_State *L, int index)
{
v3f pos;
lua_pushstring(L, item->getItemString().c_str());
}
if(lua_pcall(L, 2, 0, 0))
- script_error(L, "error: %s\n", lua_tostring(L, -1));
+ script_error(L, "error: %s", lua_tostring(L, -1));
}
}
// register_entity(name, prototype)
static int l_register_entity(lua_State *L)
{
- const char *name = luaL_checkstring(L, 1);
- infostream<<"register_entity: "<<name<<std::endl;
+ std::string name = luaL_checkstring(L, 1);
+ check_modname_prefix(L, name);
+ //infostream<<"register_entity: "<<name<<std::endl;
luaL_checktype(L, 2, LUA_TTABLE);
// Get minetest.registered_entities
int registered_entities = lua_gettop(L);
lua_pushvalue(L, 2); // Object = param 2 -> stack top
// registered_entities[name] = object
- lua_setfield(L, registered_entities, name);
+ lua_setfield(L, registered_entities, name.c_str());
// Get registered object to top of stack
lua_pushvalue(L, 2);
lua_pushnumber(L, active_object_count);
lua_pushnumber(L, active_object_count_wider);
if(lua_pcall(L, 4, 0, 0))
- script_error(L, "error: %s\n", lua_tostring(L, -1));
+ script_error(L, "error: %s", lua_tostring(L, -1));
}
};
// register_abm({...})
static int l_register_abm(lua_State *L)
{
- infostream<<"register_abm"<<std::endl;
+ //infostream<<"register_abm"<<std::endl;
luaL_checktype(L, 1, LUA_TTABLE);
// Get minetest.registered_abms
// register_tool(name, {lots of stuff})
static int l_register_tool(lua_State *L)
{
- const char *name = luaL_checkstring(L, 1);
- infostream<<"register_tool: "<<name<<std::endl;
+ std::string name = luaL_checkstring(L, 1);
+ check_modname_prefix(L, name);
+ //infostream<<"register_tool: "<<name<<std::endl;
luaL_checktype(L, 2, LUA_TTABLE);
int table = 2;
// register_craftitem(name, {lots of stuff})
static int l_register_craftitem(lua_State *L)
{
- const char *name = luaL_checkstring(L, 1);
- infostream<<"register_craftitem: "<<name<<std::endl;
+ std::string name = luaL_checkstring(L, 1);
+ check_modname_prefix(L, name);
+ //infostream<<"register_craftitem: "<<name<<std::endl;
luaL_checktype(L, 2, LUA_TTABLE);
int table = 2;
craftitemdef->registerCraftItem(name, def);
lua_pushvalue(L, table);
- scriptapi_add_craftitem(L, name);
+ scriptapi_add_craftitem(L, name.c_str());
return 0; /* number of results */
}
// register_node(name, {lots of stuff})
static int l_register_node(lua_State *L)
{
- const char *name = luaL_checkstring(L, 1);
- infostream<<"register_node: "<<name<<std::endl;
+ std::string name = luaL_checkstring(L, 1);
+ check_modname_prefix(L, name);
+ //infostream<<"register_node: "<<name<<std::endl;
luaL_checktype(L, 2, LUA_TTABLE);
int nodedef_table = 2;
lua_getglobal(L, "minetest");
lua_getfield(L, -1, "registered_nodes");
luaL_checktype(L, -1, LUA_TTABLE);
- lua_pushstring(L, name);
+ lua_pushstring(L, name.c_str());
lua_pushvalue(L, nodedef_table);
lua_settable(L, -3);
// register_craft({output=item, recipe={{item00,item10},{item01,item11}})
static int l_register_craft(lua_State *L)
{
- infostream<<"register_craft"<<std::endl;
+ //infostream<<"register_craft"<<std::endl;
luaL_checktype(L, 1, LUA_TTABLE);
int table0 = 1;
std::string error;
error += "Invalid crafting recipe (output=\""
+ output + "\")";
- throw LuaError(error);
+ throw LuaError(L, error);
}
}
// removes value, keeps key for next iteration
bool scriptapi_loadmod(lua_State *L, const std::string &scriptpath,
const std::string &modname)
{
+ ModNameStorer modnamestorer(L, modname);
+
bool success = false;
try{
success = script_load(L, scriptpath.c_str());
}
catch(LuaError &e){
- errorstream<<"Error loading mod: "<<e.what()<<std::endl;
+ errorstream<<"Error loading mod \""<<modname
+ <<"\": "<<e.what()<<std::endl;
}
return success;
lua_pushvalue(L, -2); // Get previous stack top as first parameter
lua_pushstring(L, name);
if(lua_pcall(L, 2, 0, 0))
- script_error(L, "error: %s\n", lua_tostring(L, -1));
+ script_error(L, "error: %s", lua_tostring(L, -1));
}
#endif
lua_pushstring(L, name.c_str());
lua_pushstring(L, message.c_str());
if(lua_pcall(L, 2, 1, 0))
- script_error(L, "error: %s\n", lua_tostring(L, -1));
+ script_error(L, "error: %s", lua_tostring(L, -1));
bool ate = lua_toboolean(L, -1);
lua_pop(L, 1);
if(ate)
// Call function
objectref_get_or_create(L, player);
if(lua_pcall(L, 1, 0, 0))
- script_error(L, "error: %s\n", lua_tostring(L, -1));
+ script_error(L, "error: %s", lua_tostring(L, -1));
// value removed, keep key for next iteration
}
}
// Call function
objectref_get_or_create(L, player);
if(lua_pcall(L, 1, 1, 0))
- script_error(L, "error: %s\n", lua_tostring(L, -1));
+ script_error(L, "error: %s", lua_tostring(L, -1));
bool positioning_handled = lua_toboolean(L, -1);
lua_pop(L, 1);
if(positioning_handled)
objectref_get_or_create(L, dropper);
pushFloatPos(L, pos);
if(lua_pcall(L, 3, 1, 0))
- script_error(L, "error: %s\n", lua_tostring(L, -1));
+ script_error(L, "error: %s", lua_tostring(L, -1));
result = lua_toboolean(L, -1);
}
return result;
objectref_get_or_create(L, placer);
pushFloatPos(L, pos);
if(lua_pcall(L, 3, 1, 0))
- script_error(L, "error: %s\n", lua_tostring(L, -1));
+ script_error(L, "error: %s", lua_tostring(L, -1));
result = lua_toboolean(L, -1);
}
return result;
objectref_get_or_create(L, user);
pushPointedThing(L, pointed);
if(lua_pcall(L, 3, 1, 0))
- script_error(L, "error: %s\n", lua_tostring(L, -1));
+ script_error(L, "error: %s", lua_tostring(L, -1));
result = lua_toboolean(L, -1);
}
return result;
// Call function
lua_pushnumber(L, dtime);
if(lua_pcall(L, 1, 0, 0))
- script_error(L, "error: %s\n", lua_tostring(L, -1));
+ script_error(L, "error: %s", lua_tostring(L, -1));
// value removed, keep key for next iteration
}
}
pushnode(L, newnode, ndef);
objectref_get_or_create(L, placer);
if(lua_pcall(L, 3, 0, 0))
- script_error(L, "error: %s\n", lua_tostring(L, -1));
+ script_error(L, "error: %s", lua_tostring(L, -1));
// value removed, keep key for next iteration
}
}
pushnode(L, oldnode, ndef);
objectref_get_or_create(L, digger);
if(lua_pcall(L, 3, 0, 0))
- script_error(L, "error: %s\n", lua_tostring(L, -1));
+ script_error(L, "error: %s", lua_tostring(L, -1));
// value removed, keep key for next iteration
}
}
pushnode(L, node, ndef);
objectref_get_or_create(L, puncher);
if(lua_pcall(L, 3, 0, 0))
- script_error(L, "error: %s\n", lua_tostring(L, -1));
+ script_error(L, "error: %s", lua_tostring(L, -1));
// value removed, keep key for next iteration
}
}
pushpos(L, minp);
pushpos(L, maxp);
if(lua_pcall(L, 2, 0, 0))
- script_error(L, "error: %s\n", lua_tostring(L, -1));
+ script_error(L, "error: %s", lua_tostring(L, -1));
// value removed, keep key for next iteration
}
}