Put a balloon basket down and it fills up. Climb in, hold Burner to rise and let go to sink slowly, and steer as you walk. It climbs and turns gently and never tips. Bop it once it's landed to pack it back into a basket. Make the basket at a workbench.
| 1 | --!strict |
| 2 | -- The balloon's client half. This file runs on each player's own game, not |
| 3 | -- on the world's host: main.luau says when you climb in and when you're |
| 4 | -- out again (with net.send), and while you're aboard this shows how high |
| 5 | -- you are and what's below, five times a second, from this game's own copy |
| 6 | -- of the world (net 0.2), with nothing sent while it runs. |
| 7 | |
| 8 | local net = require("@potluck/net@0.2") |
| 9 | local ui = require("@potluck/ui@0.1") |
| 10 | local world = require("@potluck/world@0.12") |
| 11 | |
| 12 | local gauge: number? = nil -- the timer that keeps the height up to date |
| 13 | local last: number? = nil -- the height a moment ago, to tell rising from sinking |
| 14 | |
| 15 | local function stop() |
| 16 | if gauge then |
| 17 | world.cancel(gauge) |
| 18 | gauge = nil |
| 19 | end |
| 20 | last = nil |
| 21 | ui.hide(nil, "height") |
| 22 | end |
| 23 | |
| 24 | local function show() |
| 25 | local me = net.me() |
| 26 | local x, z = me.position.x, me.position.z |
| 27 | local ground = world.top(x, z) |
| 28 | local up = math.max(0, me.position.y - (ground + 1)) |
| 29 | local below = world.block(vector.create(x, ground, z)) |
| 30 | local line = string.format("%d m up", math.floor(up + 0.5)) |
| 31 | if last and up > last + 0.05 then |
| 32 | line ..= ", rising" |
| 33 | elseif last and up < last - 0.05 then |
| 34 | line ..= ", sinking" |
| 35 | end |
| 36 | if up > 1 then |
| 37 | line ..= " · over " .. string.lower(below) |
| 38 | end |
| 39 | last = up |
| 40 | ui.show(nil, "height", line, { at = "right" }) |
| 41 | end |
| 42 | |
| 43 | -- true when you climb in, false when you're out again |
| 44 | net.on("aboard", function(on: any) |
| 45 | stop() |
| 46 | if on then |
| 47 | show() |
| 48 | gauge = world.every(0.2, show) |
| 49 | end |
| 50 | end) |
| 51 | |
| 52 | -- started afresh (the creation's files changed): ask whether we're aboard |
| 53 | net.send("hello") |