Advertisement
Guest User

utils

a guest
May 26th, 2019
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.67 KB | None | 0 0
  1. function tableLength(T)
  2.     local count = 0
  3.  
  4.     for _ in pairs(T) do
  5.         count = count + 1
  6.     end
  7.  
  8.     return count
  9. end
  10.  
  11. function split(s, delimiter)
  12.     result = {}
  13.     for match in (s..delimiter):gmatch("(.-)"..delimiter) do
  14.         table.insert(result, match)
  15.     end
  16.     return result
  17. end
  18.  
  19. function commandVerif(args, nbArgs, command)
  20.     if #args ~= nbArgs then
  21.         print("Le nombre d'argument n'est pas correct. " .. command)
  22.  
  23.         local text = "Il y'a " .. #args .. " arguments.\n Les arguments sont : "
  24.  
  25.         term.setTextColor(colors.yellow)
  26.  
  27.         for i = 1, #args do
  28.             text = text .. "\"" .. args[i] .. "\"" .. " "
  29.         end
  30.  
  31.         print(text)
  32.  
  33.         return false
  34.     else
  35.         return true
  36.     end
  37. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement