cmdlib/test.lua

72 lines
2.2 KiB
Lua
Raw Normal View History

2019-08-12 03:37:54 -07:00
function test_format()
minetest.after(1, function()
minetest.chat_send_all(minetest.get_color_escape_sequence("#FF0000")..[[ Looks like there's an error ! (!) /!\
]]..minetest.get_color_escape_sequence("#00FF00")..[[✓ All is alright yay ! (i) (x)]])
end)
end
function test_chatcommands(explicit_supercommand)
if explicit_supercommand then
cmdlib.register_chatcommand("cmdlib_test", {
params = "<param1>",
privs = {fast = true},
description = "Test command for cmdlib.",
func = function(sendername, params)
return true, "You shouted "..(params.param1)
end
})
end
2020-03-23 12:20:14 -07:00
cmdlib.register_chatcommand("this", {
params = "<param1>",
func = function() end
2019-08-12 03:37:54 -07:00
})
2020-03-23 12:20:14 -07:00
cmdlib.unregister_chatcommand("this")
2020-02-29 03:55:29 -08:00
cmdlib.register_chatcommand("cmdlib_test say", {
2019-08-12 03:37:54 -07:00
params = "<param1>",
privs = {fast = true, noclip = false},
description = "Test command for cmdlib.",
func = function(sendername, params)
return true, "You said "..(params.param1)
end
})
2020-03-23 12:20:14 -07:00
cmdlib.register_chatcommand("cmdlib_test repeat", {
2019-08-12 03:37:54 -07:00
params = "<param1>",
privs = {fast = true},
description = "Test command for cmdlib.",
func = function(sendername, params)
2020-03-23 12:20:14 -07:00
return true, "Param1: "..(params.param1)
2019-08-12 03:37:54 -07:00
end
})
2020-03-23 12:20:14 -07:00
cmdlib.register_chatcommand("cmdlib_test shout loud", {
2019-08-12 03:37:54 -07:00
params = "[param1]",
privs = {fast = true},
2020-03-23 12:20:14 -07:00
description = "Test command with a different description.",
2019-08-12 03:37:54 -07:00
func = function(sendername, params)
2020-03-23 12:20:14 -07:00
return true, "You SHOUTED "..(params.param1 or "IDK")
2019-08-12 03:37:54 -07:00
end
})
2020-03-23 12:20:14 -07:00
cmdlib.unregister_chatcommand("cmdlib_test shout loud")
2019-08-12 03:37:54 -07:00
end
function test_trie()
local t = trie.new()
trie.insert(t, "help")
trie.insert(t, "heap")
trie.insert(t, "me")
print(trie.search(t, "hewp"))
trie.remove(t, "heap")
print(trie.search(t, "help"))
print(trie.search(t, "heap"))
end
function test_info()
minetest.register_on_mods_loaded(function()
print(dump(cmdlib.chatcommand_info))
print(dump(cmdlib.chatcommand_info_by_mod))
2019-08-12 03:37:54 -07:00
end)
end
-- test_chatcommands()
2019-08-12 03:37:54 -07:00
-- test_format()
-- test_trie()
2020-03-23 12:20:14 -07:00
-- test_info()