Back to Powder Tool V600Billion
SOURCE / PINNED RELEASE

Made of little things.

Powder Tool V600Billion

Release
142767edcab8…
Author-recorded commit
6d92971effd0…
License
LICENSE
Author’s source reference
nostr://npub1fllw8kw0thjj55wds0uugcnp5kej2nfxd36eruq39d56wwz8r44q5q78wj/wss%3A%2F%2Fgit.napplet.soy%2F/powder-toy

Archive hash verified: ed7d6a8ea7083197…. The source-to-build association is the author’s claim; it has not been independently rebuilt.

source/src/scenes/03-volcano.lua
-- title: Volcano
-- icon: 🌋
-- blurb: A volcano erupts in bursts; its lava runs down the mountain into the sea and sets the forest alight.
-- hint: Heat view shows the magma chamber. Pour water on the crater and see what the lava makes of it.
-- view: 4
-- thumb: 12
local ROCK, LAVA, WATR = E.DEFAULT_PT_ROCK, E.DEFAULT_PT_LAVA, E.DEFAULT_PT_WATR
walls(0, 372, 611, 383)

-- The mountain: a crater at the top, a vent down its middle, a magma chamber at its foot
local peak, cx = 150, 250
for y = peak, 371 do
  local half = math.floor((y - peak) * 0.95)
  local vent = y < 176 and math.floor(4 + (176 - y) * 0.8) or 4
  if y >= 320 and y <= 365 then vent = 46 end
  if half > vent then
    box(cx - half, y, cx - vent, y, ROCK)
    box(cx + vent, y, cx + half, y, ROCK)
  end
end
box(cx - 45, 320, cx + 45, 365, LAVA)
box(cx - 3, 176, cx + 3, 319, LAVA)
set(cx - 45, 176, cx + 45, 365, "temp", celsius(2800))
-- The rock around the magma is hot already
each(cx - 60, peak, cx + 60, 371, function(i)
  if sim.partProperty(i, "type") == ROCK then sim.partProperty(i, "temp", celsius(1300)) end
end)

-- Sea on the right, a forest on the left
box(440, 300, 611, 371, WATR)
for n = 0, 2 do
  local tx = 10 + n * 18
  box(tx, 352, tx + 2, 371, E.DEFAULT_PT_WOOD)
  disc(tx + 1, 346, 7, E.DEFAULT_PT_PLNT)
end

-- The eruption: lava thrown out of the crater in bursts, and smoke
local frame = 0
every(function()
  frame = frame + 1
  local burst = frame % 300 < 120
  for k = 1, burst and 6 or 1 do
    local i = sim.partCreate(-1, cx + math.random(-6, 6), 148 + math.random(0, 8), LAVA)
    if i >= 0 then
      sim.partProperty(i, "temp", celsius(2600))
      sim.partProperty(i, "vx", (math.random() - 0.5) * (burst and 5 or 2))
      sim.partProperty(i, "vy", -(2 + math.random() * (burst and 7 or 2)))
    end
  end
  if frame % 2 == 0 then sim.partCreate(-1, cx + math.random(-6, 6), 140, E.DEFAULT_PT_SMKE) end
end)