XoXFaby

XoXOS

Nov 1st, 2012
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.69 KB | None | 0 0
  1. serverID = 44
  2.  
  3.  
  4. function clear()
  5. term.setCursorPos(1,1)
  6. term.clear()
  7. end
  8.  
  9. function xor(a, b)
  10. if a == b then return false else return true end
  11. end
  12.  
  13. for _,v in pairs(rs.getSides()) do rednet.open(v) end
  14.  
  15.  
  16.  
  17. lsusr = true
  18. lsuser = ""
  19. lspass = ""
  20. lsres = ""
  21. lserr = ""
  22. lsiskey = false
  23. lskey = ""
  24. chars = { [14] = "backspace" ,[16] = "q",[17] = "w",[18] = "e",[19] = "r",[20] = "t",[21] = "y",[22] = "u",[23] = "i",[24] = "o",[25] = "p" ,[30] = "a",[31] = "s",[32] = "d",[33] = "f",[34] = "g",[35] = "h",[36] = "j",[37] = "k",[38] = "l",[44] = "z",[45] = "x",[46] = "c",[47] = "v",[48] = "b",[49] = "n",[50] = "m" }
  25. while true do
  26.    
  27.     lsiskey = false
  28.     lskey = ""
  29.     clear()
  30.     term.setCursorPos(1,1)
  31. print("   __   __   __   __   ____   _____   __  __ ")
  32. print("   \\ \\ / /   \\ \\ / /  / __ \\ / ____| /_ |/_ |")
  33. print("    \\ V / ___ \\ V /  | |  | | (___    | | | |")
  34. print("     > < / _ \\ > <   | |  | |\\___ \\   | | | |")
  35. print("    / . \\ (_) / . \\  | |__| |____) |  | |_| |")
  36. print("   /_/ \\_\\___/_/ \\_\\  \\____/|_____/   |_(_)_|")
  37.     term.setCursorPos(5,9)
  38.     if not rednet.send(1, "") then lsres = "guest" print("Signing in as guest because no" ); term.setCursorPos(5,10); print( "modem was found");sleep(3); break; end
  39.     if lsusr then
  40.     print("Username: " .. lsuser .. "\|" )
  41.     term.setCursorPos(5,11)
  42.     print("Password: " .. lspass )
  43.     else
  44.     print("Username: " .. lsuser  )
  45.     term.setCursorPos(5,11)
  46.     print("Password: " .. lspass .. "\|" )
  47.     end
  48.     term.setCursorPos(3,13)
  49.     print("Leave empty and press Enter to")
  50.     term.setCursorPos(3, 14)
  51.     print("to sign in as a guest.")
  52.     local lsevent, lsparam = os.pullEvent("key")
  53.     for k, v in pairs(chars) do if k == lsparam then lsiskey = true ; lskey = v end end
  54.     if lsiskey == true then        
  55.         if lsparam == 14 then
  56.             if lsusr then
  57.                 lsuser = string.sub(lsuser, 1 , -2)
  58.             else
  59.                 lspass = string.sub(lspass, 1 , -2)
  60.             end
  61.         else
  62.             if lsusr then
  63.                 lsuser = lsuser .. lskey
  64.             else
  65.                 lspass = lspass .. lskey
  66.             end
  67.         end
  68.     elseif lsparam == 28 then
  69.         if lsuser == "" and lspass == "" then
  70.             lsres = "guest"
  71.             break
  72.         end
  73.         if xor( lsuser == "", lspass == "") then
  74.             if lsusr and lspass == "" then
  75.                 lsusr = not lsusr
  76.             else
  77.                 lserr = "Invalid User/Password combination"
  78.             end        
  79.         else
  80.             rednet.send(serverID, lsuser .. ";" .. lspass )
  81.             lsrevent, lsrid, lsrmsg, _ = os.pullEvent("rednet_message")
  82.             if lsrid == serverID and lsrmsg == "OK" then
  83.                 lsres = "OK"
  84.                 break
  85.             else
  86.                 lserr = "Invalid User/Password combination"
  87.             end
  88.         end
  89.    
  90.     elseif lsparam == 200 or lsparam == 208 then
  91.         lsusr = not lsusr
  92.     end
  93. end
  94.  
  95.  
  96.  
  97. ttable = {}
  98.  
  99. ttable.copy = ""
  100.  
  101. ttable.copy = function(t1)
  102. local t2 = {}
  103. for k,v in pairs(t1) do
  104. if type(v) == "table" then
  105. t2[k] = ttable.copy(v)
  106. else
  107. t2[k] = v
  108. end
  109. end
  110. return t2
  111. end
  112.  
  113. startupprog = "none"
  114. notifytext = "XoXOS 1.1"
  115.  
  116. function saveconfig()
  117. conff = fs.open("XoXOSC", "w")
  118. conff.writeLine(startupprog)
  119. conff.close()
  120. notifytext = "Saved."
  121. end
  122.  
  123. menuIndex = 1
  124. menu = {}
  125. menu1 = {}
  126. menu2 = {}
  127. menu3 = {}
  128. menu4 = {}
  129. menu5 = {}
  130. menu6 = {}
  131.  
  132.  
  133. menu1.esc = function() end
  134. menu1[1] = { txt = "Programs" , exec = function() menu = ttable.copy( menu2 ) ; menuIndex = 1 end }
  135. menu1[2] = { txt = "Games" , exec = function() menu = ttable.copy( menu3 ) ; menuIndex = 1 end}
  136. menu1[3] = { txt = "Options", exec = function() menu = ttable.copy( menu4 ) ; menuIndex = 1 end}
  137. if lsres == "OK" then
  138. menu1[4] = { txt = "Dev", exec = function() menu = ttable.copy( menu6 ) ; menuIndex = 1 end}
  139. end
  140.  
  141.  
  142. menu2.esc = function() menu = ttable.copy( menu1 ) ; menuIndex = 1 end
  143. menu2[1] = { prog = "door", txt = "Door", exec = function() shell.run("door") end}
  144. menu2[2] = { prog = "calc", txt = "Calculator", exec = function() shell.run("calc") end}
  145.  
  146. if fs.exists("XoXOSProgs") then
  147. progsf = fs.open("XoXOSProgs" , "r" )
  148. progs = {}
  149. for i = 1, progsf.readLine() do
  150. progs[#progs + 1] = progsf.readLine()
  151. progs[#progs + 1] = progsf.readLine()
  152. end
  153. progsf.close()
  154. for i = 1, #progs, 2 do
  155. menu2[#menu2 + 1] = { prog = progs[i], txt = progs[i + 1], exec = function() shell.run(progs[i]) end}
  156. end
  157. end
  158.  
  159.  
  160.  
  161. menu3.esc = function() menu = ttable.copy( menu1 ) ; menuIndex = 1 end
  162. menu3[1] = { txt = "Text Minecraft", exec = function() shell.run("adventure") end}
  163. menu3[2] = { txt = "Snake", exec = function() shell.run("worm") end}
  164.  
  165.  
  166.  
  167. menu4.esc = function() menu = ttable.copy( menu1 ) ; menuIndex = 1 end
  168. menu4[1] =  { txt = "Startup Program", exec = function() menu = ttable.copy( menu5 ) ; menuIndex = 1 end}
  169. menu4[#menu4 + 1] = { txt = "Save" , exec = saveconfig }
  170.  
  171.  
  172. menu5.esc = function() menu = ttable.copy( menu4 ) ; menuIndex = 1 end
  173. menu5[1] = { prog = "door", txt = "Door", exec = function() shell.run("door") end}
  174. menu5[2] = { prog = "calc", txt = "Calculator", exec = function() shell.run("calc") end}
  175. table.insert(menu5, 1, { txt = "None", prog = "none"  })
  176. if fs.exists("XoXOSProgs") then
  177. for i = 1, #progs, 2 do
  178. menu5[#menu5 + 1] = { prog = progs[i], txt = progs[i + 1], exec = function() shell.run(progs[i]) end}
  179. end
  180. end
  181. for k, v in ipairs(menu5) do
  182. v.exec = function() startupprog = menu5[menuIndex].prog end
  183. end
  184.  
  185. menu6.esc = function() menu = ttable.copy( menu1 ) ; menuIndex = 1 end
  186. menu6[1] = { txt = "Lua Console", exec = function() shell.run("lua") end}
  187. menu6[2] = { txt = "File Browser", exec = function() shell.run("XoXFS") end}
  188. menu6[3] = { txt = "Edit File", exec = function() shell.run("XoXEdit") end}
  189. menu6[4] = { txt = "Execute File", exec = function() shell.run("XoXRun") end}
  190. menu6[5] = { txt = "Leave XoXOS", exec = function() return end}
  191.  
  192.  
  193.  
  194. if fs.exists("XoXOSC") then
  195. conff = fs.open("XoXOSC" , "r" )
  196. startupprog = conff.readLine()
  197. conff.close()
  198. end
  199.  
  200. if startupprog ~= "none" then
  201. shell.run(startupprog)
  202. end
  203.  
  204.  
  205.  
  206. menu = ttable.copy( menu1 )
  207. term.clear()
  208. term.setCursorPos(1,1)
  209.  
  210.  
  211. while true do
  212.  
  213. term.clear()
  214. term.setCursorPos(1,1)
  215. for k,v in ipairs(menu) do
  216. print("   ")
  217. if menuIndex == k then
  218. print( ">> " .. v.txt .. " <<")
  219. else
  220. print( "   " .. v.txt)
  221. end
  222. end
  223.  
  224. term.setCursorPos(1,16)
  225. if lsres == "guest" then
  226. print("Signed in as Guest")
  227. elseif lsres == "OK" then
  228. print("Signed in as " .. lsuser )
  229. end
  230. term.setCursorPos(1,17)
  231. print(notifytext)
  232.  
  233. conf = fs.open("XoXOSDev", "w")
  234. conf.writeLine("Nope.")
  235. conf.close()
  236.  
  237. local event, param1 = os.pullEvent("key")
  238. notifytext = "XoXOS 1.1"
  239. if param1 == 200 then
  240. menuIndex = menuIndex - 1
  241. if menuIndex < 1 then menuIndex = #menu end
  242. elseif param1 == 208 then
  243. menuIndex = menuIndex + 1
  244. if menuIndex > #menu then menuIndex = 1 end
  245. elseif param1 == 28 or param1 == 205 then
  246. term.clear()
  247. term.setCursorPos(1,1)
  248. menu[menuIndex].exec()
  249. elseif param1 == 14 or param1 == 203 then
  250. menu.esc()
  251. elseif param1 == 60 then
  252. term.clear()
  253. term.setCursorPos(1,1)
  254. print("Enter Developer Password:")
  255. local pwwd = read("*")
  256. if pwwd == "luadev" then
  257. conf = fs.open("XoXOSDev", "w")
  258. conf.writeLine("Let's go")
  259. conf.close()
  260. return
  261. end
  262. end
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269.  
  270.  
  271.  
  272.  
  273.  
  274. end
Advertisement
Add Comment
Please, Sign In to add comment