-
Notifications
You must be signed in to change notification settings - Fork 11
/
chatcmd.lua
32 lines (26 loc) · 913 Bytes
/
chatcmd.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
minetest.register_privilege("givexp", {"Can give or take xp with /givexp", give_to_singleplayer = false})
minetest.register_chatcommand("givexp", {
params = "<username> <xp>",
description = "Give or take experience points",
privs = {givexp=true},
func = function(caller, param)
local _, _, name, xp = string.find(param, "^([^%s]+)%s+([^%s]+)%s*$")
if name == nil or xp == nil then
minetest.chat_send_player(caller, "syntax: /givexp <username> <xp>")
return
end
local newXp = xp_redo.add_xp(name, xp)
if newXp == nil then
return
end
minetest.chat_send_player(caller, "XP of player " .. name .. " = " .. newXp)
end,
})
minetest.register_chatcommand("highscore", {
description = "show xp highscore",
func = function(caller)
for _,entry in pairs(xp_redo.highscore) do
minetest.chat_send_player(caller, entry.name .. ": " .. entry.xp)
end
end,
})