summaryrefslogtreecommitdiff
path: root/forward.lua
blob: 3d5b95d9a879590d328bafe4143bf23071a3aa37 (plain)
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
local p = peripheral.wrap"back"
for i,mod in ipairs{"kinetic","sensor","keyboard"} do
	assert(p.hasModule("plethora:"..mod), "need "..mod.."!")
end

local pitch, yaw = 0,0
local function detector() 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, "couldn't find player??")
	pitch, yaw = player.pitch, player.yaw
	os.sleep(0)
end end

local function launcher() while true do
	local _, key, isheld = os.pullEvent"key"
	if not isheld and key == 67 then -- six seve n
		p.launch(yaw, pitch, 4)
	end
end end

print"go"
parallel.waitForAny(detector, launcher)