Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- -- -- -- -- -- -- -- -- -- -- --
- -- Properate ad finis --
- -- by Daniel_Kerman --
- -- -- -- -- -- -- -- -- -- -- -- --
- local win = false; local tries;
- local game = {};
- local draw = {};
- local function checkNumber(var)
- assert(type(var) == "number", "Error: Expected type number. Got different type instead.");
- end
- local function GOE(inNumber,compNumber) -- greater or equal
- inNumber = tonumber(inNumber);
- compNumber = tonumber(compNumber);
- assert(compNumber <= inNumber, "Error: Expected number greater or equal.");
- end
- local function getCenter(coordinate,subtraction)
- subtraction = subtraction or 0;
- checkNumber(subtraction);
- coordinate = coordinate or "x";
- x, y = term.getSize();
- assert(math.floor(x/2-subtraction)>=1,"Error: Subraction too high.");
- --assert(math.floor(y/2-subtraction)>=1,"Error: Subraction too high.");
- if coordinate == "x" then return math.floor(x/2 - subtraction) elseif coordinate == "y" then
- return math.floor(y/2 - subtraction) else
- return 1; end
- end
- local function drawRectangle(xCoor,yCoor,width,height,color,fillType)
- 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";
- checkNumber(xCoor); checkNumber(yCoor); checkNumber(width); checkNumber(height); checkNumber(color);
- GOE(xCoor,1); GOE(yCoor,1); GOE(width,1); GOE(height,1);
- if (fillType == "fill") then
- paintutils.drawFilledBox(xCoor,yCoor,xCoor+width-1,yCoor+height-1,color);
- else
- paintutils.drawBox(xCoor,yCoor,xCoor+width-1,yCoor+height-1,color);
- end
- end
- local function clean(cursorPosX,cursorPosY,bgColor,textColor)
- cursorPosX = cursorPosX or 1; cursorPosY = cursorPosY or 1; bgColor = bgColor or colors.white; textColor = textColor or colors.black;
- checkNumber(cursorPosX); checkNumber(cursorPosY); checkNumber(bgColor); checkNumber(textColor);
- GOE(cursorPosX,1); GOE(cursorPosY,1);
- term.setCursorPos(cursorPosX,cursorPosY);
- term.setBackgroundColor(bgColor); term.setTextColor(textColor);
- term.clear();
- end
- local function color(bgColor,textColor)
- bgColor = bgColor or colors.white; textColor = textColor or colors.black;
- term.setBackgroundColor(bgColor); term.setTextColor(textColor);
- end
- -- Startscreen --
- clean(getCenter("x",10),getCenter("y",0));
- textutils.slowWrite("Properate ad finis!");
- term.setCursorPos(getCenter("x",7),getCenter("y",-1));
- textutils.slowWrite("by Daniel Kerman");
- sleep(0.75);
- -- MENU SCREEN --
- while (true) do
- clean(getCenter("x",23),getCenter("y",1))
- print("Enter a command (type help for list of cmds):");
- local cx, cy = term.getCursorPos();
- term.setCursorPos(getCenter("x",23),cy);
- io.read();
- end
Advertisement
Add Comment
Please, Sign In to add comment