Created
August 14, 2018 13:30
-
-
Save adamisntdead/0728fde13ec57135265addf71b08856b to your computer and use it in GitHub Desktop.
Game
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const blessed = require("blessed"); | |
| const earth = | |
| " _____\r\n ,-:` \\;',`'-, \r\n .'-;_,; ':-;_,'.\r\n /; '/ , _`.-\\\r\n | '`. (` /` ` \\`|"; | |
| // Create a screen object. | |
| var screen = blessed.screen({ | |
| smartCSR: true, | |
| dockBorders: true | |
| }); | |
| screen.title = "Offline"; | |
| const state = { | |
| server: { online: true, load: 3 } | |
| }; | |
| const statusText = `Server Status: ${ | |
| state.server.online | |
| ? "{green-fg}{bold}ONLINE{/bold}{/green-fg}" | |
| : "{red-fg}{bold}OFFLINE{/bold}{/red-fg}" | |
| }`; | |
| const loadText = `Server Load: ${ | |
| state.server.load > 90 | |
| ? `{red-fg}{bold}${state.server.load}%{/bold}{/red-fg}` | |
| : `{green-fg}{bold}${state.server.load}%{/bold}{/green-fg}` | |
| }`; | |
| var box = blessed.box({ | |
| top: "left", | |
| left: "top", | |
| width: "0%+25", | |
| height: "0%+4", | |
| content: [statusText, loadText].join("\n"), | |
| tags: true, | |
| border: { | |
| type: "line" | |
| }, | |
| style: { | |
| fg: "white", | |
| border: { | |
| fg: "#f0f0f0" | |
| } | |
| } | |
| }); | |
| var underBox = blessed.box({ | |
| top: "left+4", | |
| left: "top", | |
| width: "0%+25", | |
| height: "100%-4", | |
| content: `${earth}`, | |
| valign: "bottom", | |
| tags: true, | |
| border: { | |
| type: "line" | |
| }, | |
| style: { | |
| fg: "white", | |
| border: { | |
| fg: "#f0f0f0" | |
| } | |
| } | |
| }); | |
| var mainbox = blessed.box({ | |
| top: "left", | |
| left: "0%+25", | |
| width: "100%-25", | |
| height: "100%", | |
| content: "", | |
| tags: true, | |
| border: { | |
| type: "line" | |
| }, | |
| style: { | |
| fg: "white", | |
| border: { | |
| fg: "#f0f0f0" | |
| } | |
| } | |
| }); | |
| console.log(mainbox); | |
| // Append our box to the screen. | |
| screen.append(box); | |
| screen.append(mainbox); | |
| screen.append(underBox); | |
| // Quit on Escape, q, or Control-C. | |
| screen.key(["escape", "q", "C-c"], function(ch, key) { | |
| return process.exit(0); | |
| }); | |
| // Focus our element. | |
| box.focus(); | |
| // Render the screen. | |
| screen.render(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment