Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function checkNumber(var)
- assert(type(var) == "number", "Error: Expected type number. Got different type instead.");
- end
- function clc(clr,bOrW)
- bOrW = bOrW or 0
- if term.isColor then
- return clr;
- else
- if bOrW == true or bOrW == 1 then
- return colors.white
- else
- return colors.black
- end
- end
- end
- function GOE(inNumber,compNumber,debugNr) -- greater or equal
- debugNr = debugNr or "";
- inNumber = tonumber(inNumber);
- compNumber = tonumber(compNumber);
- assert(compNumber <= inNumber, "Error: Expected number greater or equal. "..debugNr);
- end
- 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
- 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,"1"); GOE(yCoor,1,"2"); GOE(width,1,"3"); GOE(height,1,"4");
- 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
- 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
- function color(bgColor,textColor)
- bgColor = bgColor or colors.white; textColor = textColor or colors.black;
- term.setBackgroundColor(bgColor); term.setTextColor(textColor);
- end
- function save(table,name)
- local file = fs.open(name,"w")
- file.write(textutils.serialize(table))
- file.close()
- end
- function load(name)
- local file = fs.open(name,"r")
- if file == nil then
- return 0;
- else
- local data = file.readAll()
- file.close()
- return textutils.unserialize(data)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment