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
50
|
local p = peripheral.wrap"back"
for i,mod in ipairs{"kinetic","sensor","keyboard","glasses"} do
assert(p.hasModule("plethora:"..mod), "need "..mod.."!")
end
local vover = false
local vstrength = 0.16
local hstrength = 2
local vdelta = 0.01
local hdelta = 0.1
local yaw, pitch = 0,0
local canvas = p.canvas()
canvas.clear()
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 vover then p.launch(0,-90,vstrength)
else os.sleep(0) end
end end,
function() while true do
htext.setText(tostring(hstrength))
vtext.setText(tostring(vstrength))
local _,key = os.pullEvent"key"
if key == 265 then vstrength=vstrength+vdelta
elseif key == 264 then vstrength=vstrength-vdelta
elseif key == 263 then hstrength=hstrength-hdelta
elseif key == 262 then hstrength=hstrength+hdelta
elseif key == 67 then p.launch(yaw, pitch, hstrength)
elseif key == 88 then p.launch(yaw, 0, hstrength)
elseif key == 86 then vover = not vover
vtext.setAlpha(vover and 255 or 0)
end
vstrength = strengthclamp(vstrength)
hstrength = strengthclamp(hstrength)
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
)
|