Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- a = []
- b = 0
- c = ""
- d = 0
- h = 0
- num = 0
- t = new Date()
- time = t.getTime()
- save = 0
- u = 0
- ud = 0
- // NEW tracking variables
- lastX = null
- lastY = null
- lastLen = 0
- // Toggle milliseconds display
- showMillis = true
- function omega(n) {
- num = 1
- a = []
- h = 64
- while (n > h) {
- h = h + h
- }
- while (h != 32) {
- ud = (n * num) % h
- u = 1
- while (ud >= h / 2) {
- u = u * 2
- ud = (ud * 2) % h
- }
- num = num * u
- a = a.concat(u)
- h = h / 2
- }
- return a
- }
- function infinity(n) {
- return omega(n)
- }
- function update() {
- if (d % 7 == 0) {
- // current cursor position (where ticker should appear)
- let x = cursor.x
- let y = cursor.y
- // ERASE old ticker text if it existed
- if (lastX !== null) {
- cursor.x = lastX
- cursor.y = lastY
- for (let i = 0; i < lastLen; i++) {
- writeChar(" ", 1)
- }
- }
- // format b based on showMillis
- let bStr = showMillis ? (Math.floor(b * 1000) / 1000) : Math.floor(b)
- // update string
- c = bStr + " ~ [" + infinity(b).join() + "]"
- t = new Date()
- b = (t.getTime() - time) / 1000 + save
- // DRAW new text at the current cursor location
- cursor.x = x
- cursor.y = y
- for (let i = 0; i < c.length; i++) {
- writeChar(c[i], 1)
- }
- // REMEMBER where it was drawn this frame
- lastX = x
- lastY = y
- lastLen = c.length
- // RESTORE cursor to original location
- cursor.x = x
- cursor.y = y
- }
- d++
- requestAnimationFrame(update)
- }
- requestAnimationFrame(update)
- w.on("msg", (data) => {
- // save command
- if (data.msg.startsWith("save ") && data.nick == "CalculatorBot") {
- save = Number(data.msg.substring(5)) - b
- }
- // toggle milliseconds display
- if (data.msg === "toggleMillis" && data.nick == "CalculatorBot") {
- showMillis = !showMillis
- }
- })
Advertisement
Comments
-
- Update: Now it follows you
-
- Added a toggle that lets you show or hide the milliseconds
-
- btw, to stop the script run this in console:
- running = false;
- if (lastX !== null) {
- let currentX = cursor.x;
- let currentY = cursor.y;
- cursor.x = lastX;
- cursor.y = lastY;
- for (let i = 0; i < lastLen; i++) {
- writeChar(" ", 1);
- }
- cursor.x = currentX;
- cursor.y = currentY;
- }
Add Comment
Please, Sign In to add comment