require overhaul part 2
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
_G.requireInjector()
|
||||
|
||||
local Base64 = require('base64')
|
||||
|
||||
local http = _G.http
|
||||
@@ -9,13 +7,13 @@ local shell = _ENV.shell
|
||||
local args = { ... }
|
||||
|
||||
if not args[2] then
|
||||
error('Syntax: base64dl <file name> <url>')
|
||||
error('Syntax: base64dl <file name> <url>')
|
||||
end
|
||||
|
||||
local c = http.get(args[2])
|
||||
|
||||
if not c then
|
||||
error('unable to open url')
|
||||
error('unable to open url')
|
||||
end
|
||||
|
||||
local data = c.readAll()
|
||||
@@ -27,13 +25,13 @@ print('decoded: ' .. #decoded)
|
||||
|
||||
local file = io.open(shell.resolve(args[1]), "wb")
|
||||
if not file then
|
||||
error('Unable to open ' .. args[1], 2)
|
||||
error('Unable to open ' .. args[1], 2)
|
||||
end
|
||||
for k,b in ipairs(decoded) do
|
||||
if (k % 1000) == 0 then
|
||||
os.sleep(0)
|
||||
end
|
||||
file:write(b)
|
||||
if (k % 1000) == 0 then
|
||||
os.sleep(0)
|
||||
end
|
||||
file:write(b)
|
||||
end
|
||||
|
||||
file:close()
|
||||
|
||||
@@ -2,8 +2,6 @@ if not _G.turtle and not _G.commands then
|
||||
error('Must be run on a turtle or a command computer')
|
||||
end
|
||||
|
||||
_G.requireInjector()
|
||||
|
||||
local Adapter = require('inventoryAdapter')
|
||||
local Event = require('event')
|
||||
local GPS = require('gps')
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
_G.requireInjector()
|
||||
|
||||
local Event = require('event')
|
||||
local Logger = require('logger')
|
||||
local MEProvider = require('meProvider')
|
||||
@@ -30,7 +28,7 @@ if Util.getVersion() == 1.8 then
|
||||
end
|
||||
|
||||
if not device.wireless_modem then
|
||||
error('No wireless modem detected')
|
||||
error('No wireless modem detected')
|
||||
end
|
||||
|
||||
Logger.filter('modem_send', 'event', 'ui')
|
||||
@@ -230,36 +228,36 @@ function Builder:finish()
|
||||
end
|
||||
|
||||
function Builder:gotoBuilder()
|
||||
if Builder.lastPoint then
|
||||
if Builder.lastPoint then
|
||||
turtle.setStatus('tracking')
|
||||
while true do
|
||||
local pt = Point.copy(Builder.lastPoint)
|
||||
pt.y = pt.y + 3
|
||||
if turtle.point.y ~= pt.y then
|
||||
turtle.gotoY(pt.y)
|
||||
else
|
||||
local distance = Point.turtleDistance(turtle.point, pt)
|
||||
if distance <= 3 then
|
||||
Builder:log('Synchronized')
|
||||
break
|
||||
end
|
||||
while true do
|
||||
local pt = Point.copy(Builder.lastPoint)
|
||||
pt.y = pt.y + 3
|
||||
if turtle.point.y ~= pt.y then
|
||||
turtle.gotoY(pt.y)
|
||||
else
|
||||
local distance = Point.turtleDistance(turtle.point, pt)
|
||||
if distance <= 3 then
|
||||
Builder:log('Synchronized')
|
||||
break
|
||||
end
|
||||
|
||||
if turtle.point.heading % 2 == 0 then
|
||||
if turtle.point.x == pt.x then
|
||||
turtle.headTowardsZ(pt.z)
|
||||
moveTowardsZ(pt.z)
|
||||
else
|
||||
moveTowardsX(pt.x)
|
||||
end
|
||||
elseif turtle.point.z ~= pt.z then
|
||||
moveTowardsZ(pt.z)
|
||||
else
|
||||
turtle.headTowardsX(pt.x)
|
||||
moveTowardsX(pt.x)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if turtle.point.heading % 2 == 0 then
|
||||
if turtle.point.x == pt.x then
|
||||
turtle.headTowardsZ(pt.z)
|
||||
moveTowardsZ(pt.z)
|
||||
else
|
||||
moveTowardsX(pt.x)
|
||||
end
|
||||
elseif turtle.point.z ~= pt.z then
|
||||
moveTowardsZ(pt.z)
|
||||
else
|
||||
turtle.headTowardsX(pt.x)
|
||||
moveTowardsX(pt.x)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Message.addHandler('builder',
|
||||
@@ -385,8 +383,8 @@ Event.on('turtle_abort',
|
||||
|
||||
local function onTheWay() -- parallel routine
|
||||
while true do
|
||||
local _, _, _, id, msg, _ = os.pullEvent('modem_message')
|
||||
if Builder.ready then
|
||||
local _, _, _, id, msg, _ = os.pullEvent('modem_message')
|
||||
if Builder.ready then
|
||||
if id == __BUILDER_ID and msg and msg.type then
|
||||
if msg.type == 'needSupplies' then
|
||||
Message.send(__BUILDER_ID, 'gotSupplies', { supplies = true })
|
||||
|
||||
Reference in New Issue
Block a user