46 lines
902 B
Lua
46 lines
902 B
Lua
|
local side = "right"
|
||
|
|
||
|
local interval = 0.05
|
||
|
|
||
|
local trigger = function(previous, current)
|
||
|
return current > 0
|
||
|
end
|
||
|
|
||
|
local mon = peripheral.find("monitor")
|
||
|
|
||
|
local values = {}
|
||
|
local previous = rs.getAnalogInput(side)
|
||
|
local curr = nil
|
||
|
while true do
|
||
|
os.pullEvent("redstone")
|
||
|
curr = rs.getAnalogInput(side)
|
||
|
if trigger(previous, curr) then break end
|
||
|
previous = curr
|
||
|
end
|
||
|
|
||
|
values[1] = curr
|
||
|
|
||
|
mon.setTextScale(0.5)
|
||
|
local monX, monY = mon.getSize()
|
||
|
|
||
|
print("Triggered!")
|
||
|
for i = 2,monX do
|
||
|
sleep(interval)
|
||
|
values[i] = rs.getAnalogInput(side)
|
||
|
end
|
||
|
|
||
|
mon.setBackgroundColor(colors.black)
|
||
|
mon.setCursorBlink(false)
|
||
|
mon.clear()
|
||
|
|
||
|
local prevX = 1
|
||
|
local prevY = values[1] * (monY-1)/15
|
||
|
for x, y in pairs(values) do
|
||
|
y = y * (monY-1)/15
|
||
|
term.redirect(mon)
|
||
|
paintutils.drawLine(prevX, monY-prevY, x, monY-y, colors.green)
|
||
|
term.redirect(term.native())
|
||
|
prevX = x
|
||
|
prevY = y
|
||
|
end
|