Guest User

Untitled

a guest
Nov 11th, 2013
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.42 KB | None | 0 0
  1. -- Neekow's Printer [WIP]
  2.  
  3. local version = 0.1
  4. local pageChoisie = {}
  5.  
  6.   pageOrganisee = {
  7.     " _______________________ ",
  8.     "|                       |",
  9.     "|                       |",
  10.     "|                       |",
  11.     "|                       |",
  12.     "|                       |",
  13.     "|                       |",
  14.     "|                       |",
  15.     "|                       |",
  16.     "|                       |",
  17.     "|                       |",
  18.     "|                       |",
  19.     "|                       |",
  20.     "|                       |",
  21.     "|                       |",
  22.     "|                       |",
  23.     "|                       |",
  24.     "|                       |",
  25.     "|_______________________|",
  26.     "|            | Page:    |",
  27.     "|____________|__________|"}
  28.    
  29.   pageTitre = {
  30.     " _______________________ ",
  31.     "|                       |",
  32.     "|                       |",
  33.     "|                       |",
  34.     "|                       |",
  35.     "|                       |",
  36.     "|                       |",
  37.     "|                       |",
  38.     "|                       |",
  39.     "|                       |",
  40.     "|                       |",
  41.     "|                       |",
  42.     "|                       |",
  43.     "|                       |",
  44.     "|                       |",
  45.     "|                       |",
  46.     "|                       |",
  47.     "|_______________________|",
  48.     "|      Writen by:       |",
  49.     "|                       |",
  50.     "|_______________________|"}
  51.    
  52.   pageLibre = {
  53.     "                         ",
  54.     "                         ",
  55.     "                         ",
  56.     "                         ",
  57.     "                         ",
  58.     "                         ",
  59.     "                         ",
  60.     "                         ",
  61.     "                         ",
  62.     "                         ",
  63.     "                         ",
  64.     "                         ",
  65.     "                         ",
  66.     "                         ",
  67.     "                         ",
  68.     "                         ",
  69.     "                         ",
  70.     "                         ",
  71.     "                         ",
  72.     "                         ",
  73.     "                         "}
  74.    
  75.   barreoption= {
  76.     "#########################",
  77.     "#                       #",
  78.     "#########################",
  79.     "  _____________________  ",
  80.     " |                     | ",
  81.     " |                     | ",
  82.     " |____________ ________| ",
  83.     " |            |        | ",
  84.     " |            |        | ",
  85.     " |            |________| ",
  86.     " |            |        | ",
  87.     " |            |        | ",
  88.     " |            |________| ",
  89.     " |            |        | ",
  90.     " |            |        | ",
  91.     " |____________|________| ",
  92.     " |                     | ",
  93.     " |                     | ",
  94.     " |_____________________| ",
  95.     "                         "}
  96.    
  97.   buttonPage = {
  98.     -- nom, Xpos, Ypox, TextColor, BGColor, pageChoisie
  99.     {"FAQ",32,9,colors.lightGray,colors.black,pageFAQ},
  100.     {"Title",31,10,colors.gray,colors.white,pageTitre},
  101.     {"Organized",29,11,colors.lightGray,colors.black,pageOrganisee},
  102.     {"Free page",29,12,colors.gray,colors.white,pageLibre}}
  103.  
  104.   buttonTitre = {
  105.     -- nom, Xpos, Ypox, TextColor, BGColor
  106.     {"Neekow's Printer V"..tostring(version),29,2,colors.white,colors.black},
  107.     {"Page title:",34,5,colors.white,colors.black},
  108.     {"Page type:",30,8,colors.white,colors.black}}
  109.    
  110.   buttonProg = {
  111.     -- nom, Xpos, Ypox, TextColor, BGColor
  112.     {"New Page",42,9,colors.white,colors.black},
  113.     {"Print",43,12,colors.white,colors.black},
  114.     {"Quit",44,15,colors.white,colors.black}}
  115.  
  116.  
  117. function ecran()
  118.   for i= 1, #barreoption do
  119.     term.setCursorPos(27,i)
  120.     term.setBackgroundColor(colors.black)
  121.     term.setTextColor(colors.white)
  122.     term.write(barreoption[i])
  123.   end
  124.   for i, buttonP in ipairs(buttonPage) do
  125.    term.setCursorPos(29,buttonP[3])
  126.    term.setBackgroundColor(buttonP[4])
  127.    term.write("            ")
  128.    term.setCursorPos(buttonP[2],buttonP[3])
  129.    term.setTextColor(buttonP[5])
  130.    term.write(buttonP[1])
  131.    pageChoisie = buttonP[6]
  132.   end
  133.   for i,buttonT in ipairs(buttonTitre) do
  134.     term.setCursorPos(buttonT[2],buttonT[3])
  135.     term.setTextColor(buttonT[4])
  136.     term.setBackgroundColor(buttonT[5])
  137.     term.write(buttonT[1])
  138.   end
  139.   for i,buttonPr in ipairs(buttonProg) do
  140.     term.setCursorPos(buttonPr[2],buttonPr[3])
  141.     term.setTextColor(buttonPr[4])
  142.     term.setBackgroundColor(buttonPr[5])
  143.     term.write(buttonPr[1])
  144.   end
  145.  
  146. end
  147.  
  148. function page()    
  149.  -- if pageChoisie == nil then pageChoisie = pageLibre end
  150.   for i= 1, #pageChoisie do
  151.     term.setCursorPos(1,i-1)
  152.     term.setBackgroundColor(colors.white)
  153.     term.setTextColor(colors.black)
  154.     term.write(pageChoisie[i])
  155.   end
  156. end
  157.  
  158. function croix()
  159.   for i, buttonP in ipairs(buttonPage) do
  160.     if pageChoisie == buttonP[6] then
  161.       term.setBackgroundColor(buttonP[4])
  162.       term.setTextColor(colors.lime)
  163.       term.setCursorPos(39,buttonP[3])
  164.       term.write("x")
  165.     end
  166.   end
  167. end  
  168.    
  169. --- programme ---  
  170.    
  171. ecran()
  172.  
  173.  
  174. while true do
  175. event, button, xPos, yPos = os.pullEvent("mouse_click")
  176.       for i, buttonP in ipairs(buttonPage) do
  177.         if xPos >= 29 and xPos <= 31 and yPos == buttonP then
  178.           pageChoisie = buttonP[6]        
  179.         end
  180.       end
  181.  croix()
  182.  page(pageChoisie)
  183.  end
Advertisement
Add Comment
Please, Sign In to add comment