Started skeleton Turtle class
parent
61b178535a
commit
eecb3c7646
|
@ -0,0 +1,37 @@
|
|||
-- Created by Jef Roosens
|
||||
|
||||
-- This base class handles fuel & inventory requirements, but not movement
|
||||
local Turtle = {
|
||||
pos = {x=0, y=0, z=0},
|
||||
dir = 0, -- N, E, S, W
|
||||
inventory = nil,
|
||||
logger = require("jlib.log").Logger:new{level = -1}
|
||||
}
|
||||
|
||||
|
||||
-- Init the turtle
|
||||
--
|
||||
-- @param o turtle object
|
||||
-- @return initialized turtle object
|
||||
function Turtle:new(o)
|
||||
-- Init object
|
||||
o = o or {}
|
||||
setmetatable(o, self)
|
||||
self.__index = self
|
||||
|
||||
-- Get fuel level if not provided
|
||||
o.fuel = o.fuel or turtle.getFuelLevel()
|
||||
|
||||
-- Index inventory if none is provided
|
||||
|
||||
return o
|
||||
end
|
||||
|
||||
|
||||
-- Move the turtle
|
||||
--
|
||||
-- @param dir direction to move to: u, d, f
|
||||
-- @param n amount of blocks to move; defaults to 1
|
||||
|
||||
|
||||
return {Turtle=Turtle}
|
|
@ -1,27 +0,0 @@
|
|||
-- Created by Jef Roosens
|
||||
|
||||
|
||||
local module = {}
|
||||
local Turtle = {
|
||||
pos = {x=0, y=0, z=0},
|
||||
dir = 'N'
|
||||
}
|
||||
|
||||
|
||||
-- Init the turtle
|
||||
--
|
||||
-- @param o turtle object
|
||||
-- @return initialized turtle object
|
||||
function Turtle:new(o)
|
||||
-- Init object
|
||||
o = o or {}
|
||||
setmetatable(o, self)
|
||||
self.__index = self
|
||||
|
||||
-- Get fuel level if not provided
|
||||
if o.fuel == nil then
|
||||
o.fuel = turtle.getFuelLevel()
|
||||
end
|
||||
|
||||
return o
|
||||
end
|
Loading…
Reference in New Issue