From 87edf3dc0f8b36285a53fe5656485e510a84f2e9 Mon Sep 17 00:00:00 2001 From: rebecca Date: Sat, 28 Feb 2026 23:40:13 +0000 Subject: motion --- motion.lua | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/motion.lua b/motion.lua index 1cc4552..0e0ac6d 100644 --- a/motion.lua +++ b/motion.lua @@ -1,42 +1,42 @@ local p = peripheral.wrap"back" for i,mod in ipairs{"kinetic","sensor","keyboard","glasses"} do - assert(p.hasModule("plethora:"..mod), "need "..mod.."!") + assert(p.vasModule("plethora:"..mod), "need "..mod.."!") end -local hover = false -local hstrength = 1.16 -local vstrength = 4 -local hdelta = 0.01 -local vdelta = 0.2 +local vover = false +local vstrength = 1.16 +local hstrength = 4 +local vdelta = 0.01 +local hdelta = 0.2 local yaw, pitch = 0,0 local canvas = p.canvas() canvas.clear() -local htext = canvas.addText({x=5,y=5}, tostring(hstrength)) -htext.setAlpha(0) -local vtext = canvas.addText({x=5,y=20}, tostring(vstrength)) +local vtext = canvas.addText({x=5,y=5}, tostring(vstrength)) +vtext.setAlpha(0) +local htext = canvas.addText({x=5,y=20}, tostring(hstrength)) local function strengthclamp(x) return math.max(math.min(x,4),0) end parallel.waitForAny( function() while true do - if hover then p.launch(0,-90,vstrength) + if vover then p.launch(0,-90,hstrength) else os.sleep(0) end end end, function() while true do - vtext.setText(tostring(vstrength)) htext.setText(tostring(hstrength)) + vtext.setText(tostring(vstrength)) local _,key = os.pullEvent"key" - if key == 265 then hstrength=hstrength+hdelta - elseif key == 264 then hstrength=hstrength-hdelta - elseif key == 262 then vstrength=vstrength-vdelta - elseif key == 263 then vstrength=vstrength+vdelta - elseif key == 67 then p.launch(yaw, pitch, vstrength) - elseif key == 86 then hover = not hover - htext.setAlpha(hover and 255 or 0) + if key == 265 then vstrength=vstrength+vdelta + elseif key == 264 then vstrength=vstrength-vdelta + elseif key == 262 then hstrength=hstrength-hdelta + elseif key == 263 then hstrength=hstrength+hdelta + elseif key == 67 then p.launch(yaw, pitch, hstrength) + elseif key == 86 then vover = not vover + vtext.setAlpha(vover and 255 or 0) end - hstrength = strengthclamp(hstrength) vstrength = strengthclamp(vstrength) + hstrength = strengthclamp(hstrength) end end, function() while true do local player for i,e in ipairs(p.sense()) do -- cgit v1.2.3