Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Script for norns using shado in its default location
-- Testing whether we can load shado from elsewhere:
local types = include("shado/lib/types")
local blocks = include("shado/lib/blocks")
local frames = include("shado/lib/frames")
local renderers = include("shado/lib/renderers")
local manager = include("shado/lib/manager")
function init()
local lamp_full = types.LampState.ON
local lamp_dull = types.LampState:new(0.3, 0)
local g = grid.connect()
local renderer = renderers.VariableBlockRenderer:new(16, 8, g)
local block = blocks.Block:new(2, 2):fill(lamp_dull)
local frame = frames.Frame:new():add(block, 1, 1)
function block:press(x, y, how)
if how == 1 then
self:setLamp(x, y, lamp_full)
local newX = math.random(1, 15)
local newY = math.random(1, 7)
frame:moveTo(block, newX, newY)
else
self:setLamp(x, y, lamp_dull)
end
renderer:render(frame)
end
local mgr = manager.PressManager:new(frame)
g.key = function (x, y, how)
mgr:press(x, y, how)
end
renderer:render(frame)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment