mirror of
https://github.com/kepler155c/opus
synced 2025-10-16 00:07:39 +00:00
begin moving turtle specific code from opus into turtle package
This commit is contained in:
@@ -51,6 +51,9 @@ local function trim_traceback(target, marker)
|
||||
t_len = t_len - 1
|
||||
end
|
||||
|
||||
ttarget[#ttarget] = nil -- remove 2 calls added by the added xpcall
|
||||
ttarget[#ttarget] = nil
|
||||
|
||||
return ttarget
|
||||
end
|
||||
|
||||
@@ -83,14 +86,14 @@ return function (fn, ...)
|
||||
|
||||
-- If this traceback is more than 15 elements long, keep the first 9, last 5
|
||||
-- and put an ellipsis between the rest
|
||||
local max = 12
|
||||
local max = 10
|
||||
if trace_starts and #trace - trace_starts > max then
|
||||
local keep_starts = trace_starts + 9
|
||||
local keep_starts = trace_starts + 7
|
||||
for i = #trace - trace_starts - max, 0, -1 do table.remove(trace, keep_starts + i) end
|
||||
table.insert(trace, keep_starts, " ...")
|
||||
end
|
||||
|
||||
return false, table.concat(trace, "\n")
|
||||
return false, table.remove(trace, 1), table.concat(trace, "\n")
|
||||
end
|
||||
|
||||
return table.unpack(res, 1, res.n)
|
||||
|
@@ -1,42 +0,0 @@
|
||||
local Config = require('config')
|
||||
local GPS = require('gps')
|
||||
|
||||
local turtle = _G.turtle
|
||||
|
||||
local Home = { }
|
||||
|
||||
function Home.go()
|
||||
local config = { }
|
||||
Config.load('gps', config)
|
||||
|
||||
if config.home then
|
||||
if turtle.enableGPS() then
|
||||
return turtle.pathfind(config.home)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function Home.set()
|
||||
local config = { }
|
||||
Config.load('gps', config)
|
||||
|
||||
local pt = GPS.getPoint()
|
||||
if pt then
|
||||
local originalHeading = turtle.point.heading
|
||||
local heading = GPS.getHeading()
|
||||
if heading then
|
||||
local turns = (turtle.point.heading - originalHeading) % 4
|
||||
pt.heading = (heading - turns) % 4
|
||||
config.home = pt
|
||||
Config.update('gps', config)
|
||||
|
||||
pt = GPS.getPoint()
|
||||
pt.heading = heading
|
||||
turtle.setPoint(pt, true)
|
||||
turtle._goto(config.home)
|
||||
return config.home
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return Home
|
Reference in New Issue
Block a user