Add mods: technic, moreores, paintings, Nyancat (Pbj_pup). Small fix: sandwiches
This commit is contained in:
parent
15e8e696a2
commit
fb09deddc1
1404 changed files with 156555 additions and 211 deletions
53
mods/fakelib/init.lua
Normal file
53
mods/fakelib/init.lua
Normal file
|
@ -0,0 +1,53 @@
|
|||
|
||||
fakelib = {}
|
||||
|
||||
local function check(n, v, a, b)
|
||||
local t = type(v)
|
||||
if t == a or t == b then
|
||||
return v
|
||||
end
|
||||
local info = debug.getinfo(2, "n")
|
||||
local f = info.name or "?"
|
||||
if info.namewhat ~= "method" then
|
||||
-- Offset argument number when called using '.' instead of ':'
|
||||
n = n + 1
|
||||
end
|
||||
error(string.format("bad argument #%i to '%s' (%s expected, got %s)", n, f, a, t), 3)
|
||||
end
|
||||
|
||||
local function secure_table(t, index, id)
|
||||
setmetatable(t, {
|
||||
__index = index,
|
||||
__newindex = {},
|
||||
__metatable = id,
|
||||
})
|
||||
return t
|
||||
end
|
||||
|
||||
local path = minetest.get_modpath("fakelib")
|
||||
|
||||
for _,file in pairs({"metadata", "inventory", "player"}) do
|
||||
loadfile(path.."/"..file..".lua")(check, secure_table)
|
||||
end
|
||||
|
||||
dofile(path.."/misc.lua")
|
||||
|
||||
-- Tests are not included in releases, so check for them before registering the command.
|
||||
|
||||
local tests = loadfile(path.."/tests.lua")
|
||||
|
||||
if tests and minetest.is_singleplayer() then
|
||||
minetest.register_chatcommand("fakelib_test", {
|
||||
description = "Test fakelib's API.",
|
||||
params = "[<run error tests>]",
|
||||
func = function(_, param)
|
||||
local start_time = minetest.get_us_time()
|
||||
local success = tests(param == "true")
|
||||
local end_time = minetest.get_us_time()
|
||||
if success then
|
||||
return true, string.format("Testing completed in %i us", end_time - start_time)
|
||||
end
|
||||
return true, "Testing failed. See console for errors."
|
||||
end,
|
||||
})
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue