Daniel_Kerman

DTKPAF

Dec 13th, 2015
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.69 KB | None | 0 0
  1. -- -- -- -- -- -- -- -- -- -- -- --
  2. --      Properate ad finis       --
  3. --       by Daniel_Kerman        --
  4. -- -- -- -- -- -- -- -- -- -- -- --
  5.  
  6. local win = false; local tries;
  7. local game = {};
  8. local draw = {};
  9.  
  10.  
  11.  
  12. local function checkNumber(var)
  13.     assert(type(var) == "number", "Error: Expected type number. Got different type instead.");
  14. end
  15.  
  16. local function GOE(inNumber,compNumber) -- greater or equal
  17.     inNumber = tonumber(inNumber);
  18.     compNumber = tonumber(compNumber);
  19.     assert(compNumber <= inNumber, "Error: Expected number greater or equal.");
  20. end
  21.  
  22. local function getCenter(coordinate,subtraction)
  23.     subtraction = subtraction or 0;
  24.     checkNumber(subtraction);
  25.     coordinate = coordinate or "x";
  26.     x, y = term.getSize();
  27.     assert(math.floor(x/2-subtraction)>=1,"Error: Subraction too high.");
  28.     --assert(math.floor(y/2-subtraction)>=1,"Error: Subraction too high.");
  29.     if coordinate == "x" then return math.floor(x/2 - subtraction) elseif coordinate == "y" then
  30.     return math.floor(y/2 - subtraction) else
  31.     return 1; end
  32. end
  33.  
  34. local function drawRectangle(xCoor,yCoor,width,height,color,fillType)
  35.     xCoor = xCoor or 1; yCoor = yCoor or 1; width = width or 2; height = height or 2; color = color or colors.red; fillType = fillType or "fill";
  36.     checkNumber(xCoor); checkNumber(yCoor); checkNumber(width); checkNumber(height); checkNumber(color);
  37.     GOE(xCoor,1); GOE(yCoor,1); GOE(width,1); GOE(height,1);
  38.     if (fillType == "fill") then
  39.         paintutils.drawFilledBox(xCoor,yCoor,xCoor+width-1,yCoor+height-1,color);
  40.     else
  41.         paintutils.drawBox(xCoor,yCoor,xCoor+width-1,yCoor+height-1,color);
  42.     end
  43. end
  44.  
  45. local function clean(cursorPosX,cursorPosY,bgColor,textColor)
  46.     cursorPosX = cursorPosX or 1; cursorPosY = cursorPosY or 1; bgColor = bgColor or colors.white; textColor = textColor or colors.black;
  47.     checkNumber(cursorPosX); checkNumber(cursorPosY); checkNumber(bgColor); checkNumber(textColor);
  48.     GOE(cursorPosX,1); GOE(cursorPosY,1);
  49.     term.setCursorPos(cursorPosX,cursorPosY);
  50.     term.setBackgroundColor(bgColor); term.setTextColor(textColor);
  51.     term.clear();
  52. end
  53.  
  54. local function color(bgColor,textColor)
  55.     bgColor = bgColor or colors.white; textColor = textColor or colors.black;
  56.     term.setBackgroundColor(bgColor); term.setTextColor(textColor);
  57. end
  58.  
  59. -- Startscreen --
  60.  
  61. clean(getCenter("x",10),getCenter("y",0));
  62. textutils.slowWrite("Properate ad finis!");
  63. term.setCursorPos(getCenter("x",7),getCenter("y",-1));
  64. textutils.slowWrite("by Daniel Kerman");
  65. sleep(0.75);
  66.  
  67. -- MENU SCREEN --
  68.  
  69. while (true) do
  70.     clean(getCenter("x",23),getCenter("y",1))
  71.     print("Enter a command (type help for list of cmds):");
  72.     local cx, cy = term.getCursorPos();
  73.     term.setCursorPos(getCenter("x",23),cy);
  74.     io.read();
  75.    
  76. end
Advertisement
Add Comment
Please, Sign In to add comment