commands.lua 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. --[[
  2. Debug console built-in commands
  3. @author : Eiyeron Fulmincendii
  4. cls : clears the console log
  5. help (aliases : ls) : displays the list of registered commands and display their help.
  6. ]]--
  7. Commands = {
  8. cls = {
  9. fun = function(console)
  10. console.logs = {}
  11. console.scroll_to_bottom = true
  12. end,
  13. help = "Clears the log"
  14. },
  15. help = {
  16. fun = function(console, fun)
  17. if fun then
  18. if console.command_helps[fun] then
  19. console:log(fun .. " " .. console.command_helps[fun])
  20. elseif console.commands[fun] then
  21. console:log(fun.." doesn't have help info.")
  22. else
  23. console:log("Command not found : "..fun)
  24. end
  25. return
  26. end
  27. local res = ""
  28. for k,v in pairs(console.commands) do
  29. res = res .. k .. " "
  30. end
  31. console:log(res)
  32. end,
  33. help = "[fun] : List commands or show help of a given command."
  34. },
  35. collectgarbage = {
  36. fun = function(console, opt, arg)
  37. collectgarbage(opt, arg)
  38. end,
  39. help = "[opt][, arg] : calls lua's collectgarbage'"
  40. }
  41. }
  42. -- Aliases
  43. Commands.ls = Commands.help
  44. return Commands