Utilities

Hello, CraftOS

Prints to the screen, writes on a monitor and makes a sandboxed web request.

Likes
0
Views
0
In-game installs
0

Uses

  • monitor

Capabilities

  • Uses HTTP

Licence

MIT

startup.lua 1321 bytes Raw
1-- Welcome to the ccbin.dev Workbench!
2-- This is real CraftOS (CC: Tweaked) running in your browser.
3-- Edit this program and press Run, or open another one from Examples below.
4
5term.setTextColour(colours.yellow)
6print("Hello from ccbin.dev!")
7term.setTextColour(colours.white)
8print(os.version() .. " on " .. _HOST)
9
10local monitor = peripheral.find("monitor")
11if monitor then
12 monitor.setTextScale(0.5)
13 monitor.setBackgroundColour(colours.blue)
14 monitor.clear()
15 local w, h = monitor.getSize()
16 local text = "ccbin.dev"
17 monitor.setCursorPos(math.floor((w - #text) / 2) + 1, math.floor(h / 2))
18 monitor.setTextColour(colours.yellow)
19 monitor.write(text)
20 print(("Monitor attached: %dx%d characters"):format(w, h))
21end
22
23-- Networking is sandboxed: unless you turn on live network, nothing
24-- leaves your browser. Mocks, ccbin's code-host resolver (Pastebin, GitHub,
25-- ccbin) and placeholders answer instead. See the Network tab.
26print("Trying http.get(\"https://example.com/hello.txt\") ...")
27local response, err = http.get("https://example.com/hello.txt")
28if response then
29 term.setTextColour(colours.lime)
30 print("Sandbox answered: " .. response.readAll())
31 term.setTextColour(colours.white)
32 response.close()
33else
34 term.setTextColour(colours.red)
35 print(err)
36 term.setTextColour(colours.white)
37end

Install in your world

wget run https://ccbin.dev/i/BxDF2AdO
wget https://ccbin.dev/raw/BxDF2AdO startup.lua
Embed on your site
<iframe src="https://ccbin.dev/BxDF2AdO/embed" width="800" height="520" style="border:0" loading="lazy" allow="autoplay" title="Hello, CraftOS on ccbin.dev"></iframe>

Sites that understand oEmbed, such as Discord and many forums, make the embed from the program's link.

Prints to the screen, writes on a monitor and makes a sandboxed web request.

This is one of the examples in the Workbench. Run it here, or open it in the Workbench to change it.

Comments

No comments yet.

Sign in to comment.