diff options
| author | rebecca <ubq323@ubq323.website> | 2026-02-28 23:40:13 +0000 |
|---|---|---|
| committer | rebecca <ubq323@ubq323.website> | 2026-02-28 23:40:13 +0000 |
| commit | 87edf3dc0f8b36285a53fe5656485e510a84f2e9 (patch) | |
| tree | 7f10a7d230243c00195495b39f926ae36b7481f7 | |
| parent | 839308d2e8d646d85485bc95db877903bf5674b3 (diff) | |
motion
| -rw-r--r-- | motion.lua | 38 |
1 files changed, 19 insertions, 19 deletions
@@ -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 |
