Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Rounds decimals.
- --Put input in parenthesis
- --Output is (rounded)
- function round(number)
- roundUp = (math.ceil(number)-number)
- roundDown = (number - math.floor(number))
- if roundUp <= roundDown then
- rounded = math.ceil(number)
- elseif roundUp > roundDown then
- rounded = math.floor(number)
- end
- return rounded
- end
- --Clears screen and sets cursor to top
- function resetCursor()
- term.clear()
- term.setCursorPos(1, 1)
- end
- --Checks if a number is even.
- function isEven(number)
- if (number/2) == bry.round(number/2) then
- return true
- else
- return false
- end
- end
- --Emits a 1/2 second redstone pulse.
- function redPulse(side)
- redstone.setOutput(side, true)
- sleep(0.5)
- redstone.setOutput(side, false)
- end
- --Changes terminal text color if it can
- function textColor(color)
- if term.isColor() then
- term.setTextColor(color)
- end
- end
- --Averages a table of numbers
- function average(table)
- i = 1
- temp = 0
- while i < #table + 1 do
- temp = temp + table[i]
- i = i + 1
- end
- result = temp/#table
- return(result)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement