chat_commands.lua 765 B

1234567891011121314151617181920212223242526
  1. minetest.register_chatcommand("cd", {
  2. params = "<name>",
  3. description = "Start a countdown",
  4. func = function(name, param)
  5. -- print(name,param)
  6. local countdown=timer.countdown_default
  7. local xp= string.split(param, " ")
  8. if #xp == 1 then
  9. countdown=tonumber(xp[1])
  10. print(countdown,xp[1])
  11. if countdown == nil then
  12. if (xp[1] == "rest") or (xp[1] == "r") then
  13. minetest.chat_send_player(name,"countdown remaining: "..math.floor(100*xpfw.player_get_attribute(minetest.get_player_by_name(name),timer.prefix))/100)
  14. end
  15. end
  16. elseif #xp >1 then
  17. countdown=tonumber(xp[2])
  18. end
  19. if countdown ~=nil then
  20. xpfw.player_set_attribute(minetest.get_player_by_name(name),timer.prefix,countdown)
  21. timer.player[name]=countdown
  22. end
  23. end
  24. })