Created
January 7, 2022 21:25
-
-
Save cassiel/faf67eaad0d6d946c3360706909dab14 to your computer and use it in GitHub Desktop.
Script for norns using shado in its default location
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
-- 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