Guest User

startup

a guest
Jun 29th, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.56 KB | None | 0 0
  1. --Created and Developed by Lapito1297(jaypar)
  2. --Some Variable
  3. set = {}
  4. line = 220
  5. filte = {}
  6. time = {}
  7. nu = {}
  8.  
  9.   os.loadAPI("LapAPI")
  10.  
  11. --Run when the chat runs for the first time
  12. _G.glass, mon, ups = LapAPI.runChatFirstTime()
  13.  
  14. --Function for finding commands
  15. function run(...)
  16.  _G.msgArgs = {}
  17.  v = 1
  18.  for i in string.gmatch(msg, "%S+") do
  19.   _G.msgArgs[v] = i
  20.   v = v + 1
  21.  end
  22.  if string.match(arg[1], "/") ~= nil and string.match(arg[1], "./") == nil then
  23.   return true
  24.  else
  25.   return false
  26.  end
  27. end
  28.  
  29. --function fade()
  30. --Will finish
  31. --end
  32.  
  33. --Load Addons
  34. function addons()
  35.  installedAddons = {}
  36.  if fs.exists("Chat/InstalledAddons") == true then
  37.   iAddons = fs.open("Chat/InstalledAddons", "r")
  38.   installedAddons = textutils.unserialize(iAddons.readAll())
  39.   for i,v in ipairs(installedAddons) do
  40.    os.loadAPI("Chat/Addons/"..installedAddons[i])
  41.    funct = loadstring(installedAddons[i]..".run()")
  42.    funct()
  43.   end
  44.   iAddons.close()
  45.  end
  46. end
  47.  
  48. --function color()
  49. --Working on it
  50. --end
  51.  
  52. --If mon present print messages to it
  53. function monitor()
  54.  if mon ~= nil then
  55.   mon.setCursorPos(1,1)
  56.   mon.setTextScale(0.75)
  57.   mon.clear()
  58.   mon.write(realName.." > "..msg)
  59.  end
  60. end
  61.  
  62.  
  63. --Main function
  64. function main()
  65.  while true do
  66. --Reset variables
  67.   _G.realName = ""
  68.   _G.facs = ""
  69.   _G.rank = ""
  70.  
  71. --Update Chat
  72.   if ups == true then
  73.    LapAPI.update("QDGKgTAh")
  74.   end
  75.  
  76.   _G.commandUser = nil
  77.  
  78. --Pull events from the Terminal Glasses
  79.   e, side, _G.user, _G.uuid, _G.msg = os.pullEvent("glasses_chat_command")
  80.  
  81. --Check for Commands
  82.   _G.isCommand = run(_G.msg)
  83.  
  84. --If Command set user to command User
  85.   if _G.isCommand then
  86.     _G.set = {}
  87.     _G.commandUser = _G.user
  88.     _G.user = ""
  89.   end
  90. --Initialize addons
  91.   addons()
  92.  
  93.   --If Factions installed check for Faction commands
  94.   if Factions then
  95.    Factions.facCommands(_G.msgArgs, _G.user)
  96.   end
  97.  
  98.  
  99. --Load Faction name of user
  100.   if not isCommand then
  101.    if Factions then
  102.     _G.facs = Factions.checkFac(_G.user)
  103.    end
  104.   end
  105.  
  106.   LapAPI.clearChat(_G.msgArgs, _G.realName)
  107.  
  108.     monitor()
  109.     LapAPI.chatSave(_G.facs, _G.rank, _G.hyph, _G.user, _G.msg, _G.isCommand)
  110.     if _G.con then
  111.      glass.addText(2, 230, "Console > ".._G.con, 0xFFFFFF)
  112.     end
  113.  
  114. --    fade()
  115. --    If a command not detected print multiple lines
  116.     if not _G.isCommand then
  117.      glass.clear()
  118.      LapAPI.chatMultiline()
  119.     end
  120.   glass.sync()
  121.  end
  122. end
  123.  
  124. --Run Multiple functions at once
  125. parallel.waitForAll(main, LapAPI.chatConsole, LapAPI.chatSaveToFile, LapAPI.userJoined, LapAPI.userLeft)
Add Comment
Please, Sign In to add comment