summaryrefslogtreecommitdiff
path: root/forward.lua
blob: 0242205f4ef10e734e83e86a6198a9b87b1b4a30 (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
28
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 ents = p.sense()
	local player
	for i,e in ipairs(p.sense()) do
		if e.key == "minecraft:player" and x.name == "ubq323" then
			player = x   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(pitch, yaw, 4)
	end
end

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