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