1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
local p = peripheral.wrap"back"
for i,mod in ipairs{"kinetic","sensor","keyboard","glasses"} do
assert(p.hasModule("plethora:"..mod), "need "..mod.."!")
end
local hover = false
local hstrength = 1.16
local vstrength = 4
local hdelta = 0.01
local vdelta = 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 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)
else os.sleep(0) end
end end,
function() while true do
vtext.setText(tostring(vstrength))
htext.setText(tostring(hstrength))
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)
end
hstrength = strengthclamp(hstrength)
vstrength = strengthclamp(vstrength)
end end,
function() while true do
local player for i,e in ipairs(p.sense()) do
if e.key=="minecraft:player" and e.name=="ubq323" then player=e break
end end
assert(player, "couldnt find player??")
pitch,yaw = player.pitch, player.yaw
end end
)
|