Advertisement
Symmetryc

X

Apr 4th, 2013
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 9.78 KB | None | 0 0
  1. --[[ X ]]--
  2. local s = {}
  3. local op = {}
  4. --if not fs.exists("XData") then
  5.     fs.makeDir("XData")
  6.     fs.makeDir("/XData/ModData")
  7.     fs.makeDir("/XData/SaveData")
  8.     g = fs.open("/XData/General", "w")
  9.     g.writeLine(2^7)    --op[1]
  10.     g.writeLine(2^1)    --op[2]
  11.     g.writeLine(2^1)    --op[3]
  12.     g.writeLine(2^15)   --op[4]
  13.     g.writeLine(2)      --op[5]
  14.     g.close()
  15.     s[1] = fs.open("/XData/SaveData/Save1", "w")
  16.     s[2] = fs.open("/XData/SaveData/Save2", "w")
  17.     s[3] = fs.open("/XData/SaveData/Save3", "w")
  18.     s[1].writeLine("New")
  19.     s[2].writeLine("New")
  20.     s[3].writeLine("New")
  21.     s[1].close()
  22.     s[2].close()
  23.     s[3].close()
  24. --end
  25. g = fs.open("/XData/General", "r")
  26. s[1] = fs.open("/XData/SaveData/Save1", "r")
  27. s[2] = fs.open("/XData/SaveData/Save2", "r")
  28. s[3] = fs.open("/XData/SaveData/Save3", "r")
  29. for i=1, 5 do
  30.     op[i] = tonumber(g.readLine())
  31. end
  32. file = {
  33.     {
  34.     s[1].readLine();
  35.     };
  36.     {
  37.     s[2].readLine();
  38.     };
  39.     {
  40.     s[3].readLine();
  41.     };
  42. }
  43. g.close()
  44. s[1].close()   
  45. s[2].close()
  46. s[3].close()
  47. local stop = false
  48. local toolbar = true
  49. local tbts = " [Options] [Controls] [About] [Exit]"
  50. local space = "                                       "
  51. local menuNum = 0
  52. local noFlicker = true
  53. local pnd = {0, 0, 0, 0, 0}
  54. local function disp(a)
  55.     crsr = 1
  56.     term.setTextColor(op[4])
  57.     if a=="in" then
  58.         for i=1, string.len(tbts), op[5] do
  59.             term.setBackgroundColor(op[2])
  60.             term.setCursorPos(1, 1)
  61.             write("[+]")
  62.             write(string.sub(tbts, i, -1))
  63.             term.setBackgroundColor(op[1])
  64.             write(space)
  65.             term.setBackgroundColor(2^15)
  66.             term.setCursorPos(2, 2)                
  67.             write(string.sub(space, i, -1))
  68.             term.setBackgroundColor(op[1])
  69.             write(space)
  70.             sleep(0.05)
  71.         end
  72.         toolbar = false
  73.     elseif a=="out" then
  74.         for i=1, string.len(tbts), op[5] do
  75.             term.setBackgroundColor(op[2])
  76.             term.setCursorPos(1, 1)
  77.             write("[-]")
  78.             write(string.sub(tbts, -i, -1))
  79.             term.setBackgroundColor(2^15)
  80.             term.setCursorPos(2, 2)
  81.             write(string.sub(space, -i-3, -1))
  82.             sleep(0.05)
  83.         end
  84.         toolbar = true
  85.     end
  86.     if toolbar then
  87.         term.setBackgroundColor(op[2])
  88.         term.setCursorPos(1, 1)
  89.         write("[-]"..tbts)
  90.         term.setBackgroundColor(2^15)
  91.         term.setCursorPos(2, 2)
  92.         write(space)
  93.     else
  94.         term.setBackgroundColor(op[1])
  95.         term.setCursorPos(4, 1)
  96.         write(space)
  97.         term.setCursorPos(5, 2)
  98.         write(space)
  99.         term.setBackgroundColor(op[2])
  100.         term.setCursorPos(1, 1)
  101.         write("[+]")
  102.         term.setBackgroundColor(2^15)
  103.         term.setCursorPos(2, 2)
  104.         write("   ")
  105.     end
  106. end
  107. local function anTimeSlider()
  108.     term.setBackgroundColor(op[1])
  109.     term.setCursorPos(24, 4)
  110.     write("     ")
  111.     term.setBackgroundColor(op[4])
  112.     term.setCursorPos(23+dp5, 4)
  113.     write(" ")
  114.     term.setBackgroundColor(op[2])
  115.     term.setCursorPos(35, 4)
  116.     write("          ")
  117.     term.setCursorPos(35, 4)
  118.     if dp5==1 then
  119.         write("Slow")
  120.     elseif dp5==2 then
  121.         write("Normal")
  122.     elseif dp5==3 then
  123.         write("Fast")
  124.     elseif dp5==4 then
  125.         write("Very Fast")
  126.     elseif dp5==5 then
  127.         write("Instant")
  128.     end
  129. end
  130. local function colorArrow()
  131.     for i=5, 14, 3 do
  132.         term.setCursorPos(24, i)
  133.         for i2=0, 15 do
  134.             if 2^i2==pnd[i/3-2/3] then
  135.                 write("^")
  136.             else
  137.                 write(" ")
  138.             end
  139.         end
  140.     end
  141. end
  142. local function input(a)
  143.     if a==0 then
  144.         while true do
  145.             event, p1, p2, p3 = os.pullEvent("mouse_click")
  146.             if p2>=9 and p2<=41 and p3>1 then
  147.                 if p3>=4 and p3<=6 then
  148.                     if p1=="left" then
  149.                         --
  150.                         break
  151.                     else
  152.                         window(0, 1, p2, p3) --Menu, Win, X, Y
  153.                     end
  154.                 elseif p3>=9 and p3<=11 then
  155.                     if p1=="left" then
  156.                         --
  157.                         break
  158.                     else
  159.                         window(0, 2, p2, p3)
  160.                     end
  161.                 elseif p3>=14 and p3<=16 then
  162.                     if p1=="left" then
  163.                         --
  164.                         break
  165.                     else
  166.                         window(0, 3, p2, p3)
  167.                     end
  168.                 end
  169.             elseif p3==1 then              
  170.                 if p2>=1 and p2<=3 then
  171.                     if toolbar then
  172.                         disp("in")
  173.                     else
  174.                         disp("out")
  175.                     end
  176.                 elseif p2>=5 and p2<=13 and toolbar then
  177.                     menuNum = 1
  178.                     toolbar = false
  179.                     break
  180.                 elseif p2>=15 and p2<=24 and toolbar then
  181.                     menuNum = 2
  182.                     toolbar = false
  183.                     break
  184.                 elseif p2>=26 and p2<=32 and toolbar then
  185.                     menuNum = 3
  186.                     toolbar = false
  187.                     break
  188.                 elseif p2>=34 and p2<=39 and toolbar then
  189.                     stop = true
  190.                     break
  191.                 end
  192.             end
  193.         end
  194.     elseif a==1 then
  195.         while true do
  196.             event, p1, p2, p3 = os.pullEvent()
  197.             if crsr==1 then
  198.                 if event=="mouse_drag" and p2>=24 and p2<=28 and p3==4 then
  199.                     dp5 = p2-23
  200.                     pnd[5] = dp5
  201.                     anTimeSlider()
  202.                 elseif event=="mouse_click" and p3==2 then
  203.                     if p2>=11 and p2<=15 then
  204.                         crsr = 2
  205.                         break
  206.                     elseif p2>=45 and p2<=48 then
  207.                         crsr = 3
  208.                         break
  209.                     end
  210.                 end
  211.             elseif crsr==2 then
  212.                 if event=="mouse_click" and p2>=24 and p2<=39 then
  213.                     b = p2-24
  214.                     c = p3/3-1/3
  215.                     if c%1==0 then
  216.                         pnd[c] = 2^b
  217.                         colorArrow()
  218.                     elseif p3==13 then
  219.                         pnd[4] = 2^b
  220.                         colorArrow()
  221.                     end
  222.                 elseif event=="mouse_click" and p3==2 then
  223.                     if p2>=2 and p2<=9 then
  224.                         crsr = 1
  225.                         break
  226.                     elseif p2>=45 and p2<=48 then
  227.                         crsr = 3
  228.                         break
  229.                     end
  230.                 end
  231.             elseif crsr==3 then
  232.                 if event=="mouse_click" and p3==12 then
  233.                     if p2>=8 and p2<=19 then
  234.                         for i=1, 5 do
  235.                             if not pnd[i] then
  236.                                 pnd[i] = op[i]
  237.                             else
  238.                                 op[i] = pnd[i]
  239.                             end
  240.                         end
  241.                         if op[5]==3 then
  242.                             op[5] = 5
  243.                         elseif op[5]==4 then
  244.                             op[5] = 10
  245.                         elseif op[5]==5 then
  246.                             op[5] = 100
  247.                         end
  248.                         menuNum = 0
  249.                         break
  250.                     elseif p2>=29 and p2<=42 then
  251.                         menuNum = 0
  252.                         break
  253.                     end
  254.                 elseif event=="mouse_click" and p3==2 then
  255.                     if p2>2 and p2<=9 then
  256.                         crsr = 1
  257.                         break
  258.                     elseif p2>=11 and p2<=15 then
  259.                         crsr = 2
  260.                         break
  261.                     end
  262.                 end
  263.             end
  264.         end
  265.     end
  266. end
  267.  
  268. local function menu(a)
  269.     if menuNum==0 then
  270.         pnd[1] = op[1]
  271.         pnd[2] = op[2]
  272.         pnd[3] = op[3]
  273.         pnd[4] = op[4]
  274.         pnd[5] = op[5]
  275.         if pnd[5]==5 then
  276.             pnd[5] = 3
  277.         elseif pnd[5]==10 then
  278.             pnd[5] = 4
  279.         elseif pnd[5]==100 then
  280.             pnd[5] = 5
  281.         end
  282.         dp5 = pnd[5]
  283.         if dp5>4 then
  284.             dp5 = 5
  285.         end
  286.         crsr = 1
  287.         term.setTextColor(op[4])
  288.         term.setBackgroundColor(op[1])
  289.         term.clear()
  290.         term.setCursorPos(18, 19)
  291.         write("X, by Symmetryc")
  292.         term.setBackgroundColor(op[3])
  293.         for i=1, 3 do  
  294.             c = i*5
  295.             for i2=-1, 1 do
  296.                 term.setCursorPos(9, i2+c)
  297.                 write("                                 ")
  298.                 term.setCursorPos(42, i2+c+1)
  299.                 term.setBackgroundColor(2^15)
  300.                 write(" ")
  301.                 term.setBackgroundColor(op[3])
  302.             end
  303.             term.setCursorPos(26-string.len(file[i][1])/2, c)
  304.             write(file[i][1])
  305.             term.setBackgroundColor(2^15)
  306.             term.setCursorPos(10, c+2)
  307.             write("                                 ")
  308.             term.setBackgroundColor(op[3])
  309.         end
  310.         if a==nil then
  311.             disp()
  312.         end
  313.     elseif menuNum==1 then
  314.         term.setBackgroundColor(op[2])
  315.         term.setTextColor(op[4])
  316.         term.clear()
  317.         term.setBackgroundColor(op[1])
  318.         term.setCursorPos(1, 1)
  319.         term.clearLine()
  320.         term.setCursorPos(1, 2)
  321.         term.clearLine()
  322.         term.setCursorPos(1, 18)
  323.         term.clearLine()
  324.         term.setCursorPos(1, 19)
  325.         term.clearLine()
  326.         for i=1, 19 do
  327.             term.setCursorPos(1, i)
  328.             write(" ")
  329.             term.setCursorPos(50, i)
  330.             write(" ")
  331.             term.setCursorPos(51, i)
  332.             write(" ")
  333.         end
  334.         term.setBackgroundColor(2^15)
  335.         for i=4, 18 do
  336.             term.setCursorPos(50, i)
  337.             write(" ")
  338.         end
  339.         term.setCursorPos(3, 18)
  340.         write("                                               ")
  341.         term.setBackgroundColor(op[1])
  342.         term.setCursorPos(3, 1)
  343.         write("_______ _____                             ____")
  344.         term.setCursorPos(2, 2)
  345.         write("/General\\Color\\                           /Exit\\")
  346.         term.setTextColor(op[2])
  347.         if crsr==1 then
  348.             term.setCursorPos(2, 2)
  349.             write("/General\\")
  350.             term.setCursorPos(3, 1)
  351.             write("_______")
  352.             term.setBackgroundColor(op[2])
  353.             term.setTextColor(op[4])
  354.             term.setCursorPos(3, 4)
  355.             write("Animation Speed")
  356.             anTimeSlider()
  357.         elseif crsr==2 then
  358.             term.setCursorPos(10, 2)
  359.             write("/Color\\")
  360.             term.setCursorPos(11, 1)
  361.             write("_____")
  362.             term.setBackgroundColor(op[2])
  363.             term.setTextColor(op[4])
  364.             term.setCursorPos(3, 4)
  365.             write("Background Color")
  366.             term.setCursorPos(3, 7)
  367.             write("Toolbar Color")
  368.             term.setCursorPos(3, 10)
  369.             write("Button Color")
  370.             term.setCursorPos(3, 13)
  371.             write("Text Color")    
  372.             for i=4, 13, 3 do
  373.                 term.setCursorPos(24, i)
  374.                 for i2=0, 15 do
  375.                     term.setBackgroundColor(2^i2)                  
  376.                     write(" ")
  377.                 end
  378.             end
  379.             term.setBackgroundColor(op[2])
  380.             colorArrow()
  381.         elseif crsr==3 then
  382.             term.setCursorPos(44, 2)
  383.             write("/Exit\\")
  384.             term.setCursorPos(45, 1)
  385.             write("____")
  386.             term.setBackgroundColor(op[2])
  387.             term.setTextColor(op[4])
  388.             term.setCursorPos(8, 7)
  389.             write("Would you like to save you changes?")
  390.             term.setCursorPos(8, 12)
  391.             write("Save Changes         Cancel Changes")
  392.         end
  393.     end
  394.     if a==nil then
  395.         input(menuNum)
  396.     end
  397. end
  398. menu(true)
  399. disp("out")
  400. input(0)
  401. while true do
  402.     g = fs.open("/XData/General", "w")
  403.     s[1] = fs.open("/XData/SaveData/Save1", "w")
  404.     s[2] = fs.open("/XData/SaveData/Save2", "w")
  405.     s[3] = fs.open("/XData/SaveData/Save3", "w")
  406.     g.writeLine(op[1])
  407.     g.writeLine(op[2])
  408.     g.writeLine(op[3])
  409.     g.writeLine(op[4])
  410.     g.writeLine(op[5])
  411.     for i=1, 3 do
  412.         s[i].writeLine(file[i][1])
  413.     end
  414.     menu()
  415.     if stop==true then
  416.         g.close()
  417.         s[1].close()
  418.         s[2].close()
  419.         s[3].close()
  420.         term.setBackgroundColor(2^15)
  421.         term.setTextColor(2^0)
  422.         term.clear()
  423.         term.setCursorPos(1, 1)
  424.         break
  425.     end
  426. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement