-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask.lua
More file actions
40 lines (31 loc) · 843 Bytes
/
task.lua
File metadata and controls
40 lines (31 loc) · 843 Bytes
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
--[[ Task.lua ]]--
--
-- Sample task
function task(qtobj)
-- The new instance
local self = {
-- Public fields go here in the instance table
name = "My Task"
}
-- Private fields are implemented using locals
local qt = qtobj
-- Run some init code here
print(self.name)
-- Put some functions here
-- self.run() - the main task body
function self.run()
qt.init()
-- Face North
qt.face(qt.North())
-- Drop to ground level
qt.sink()
-- Get the block below the turtle
local succ, blk = turtle.inspectDown()
-- Move forward until we find something different
qt.forwardWhile(blk.name)
succ, blk = turtle.inspectDown()
print("Found "..blk.name)
end
-- Return the instance
return self
end