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 })
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
_G.requireInjector()
|
||||
|
||||
local Ansi = require('ansi')
|
||||
local SHA1 = require('sha1')
|
||||
local UI = require('ui')
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
_G.requireInjector()
|
||||
|
||||
local Event = require('event')
|
||||
local UI = require('ui')
|
||||
local Util = require('util')
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
_G.requireInjector()
|
||||
|
||||
local Event = require('event')
|
||||
local UI = require('ui')
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
_G.requireInjector()
|
||||
|
||||
local Config = require('config')
|
||||
local Event = require('event')
|
||||
local Socket = require('socket')
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
_G.requireInjector()
|
||||
|
||||
local Config = require('config')
|
||||
local Event = require('event')
|
||||
local itemDB = require('itemDB')
|
||||
|
||||
@@ -14,8 +14,6 @@ local version = "Version 1.1.6"
|
||||
-- Original code by Bomb Bloke
|
||||
-- Modified to integrate with opus os
|
||||
|
||||
_G.requireInjector()
|
||||
|
||||
local Util = require('util')
|
||||
|
||||
local multishell = _ENV.multishell
|
||||
@@ -151,7 +149,7 @@ end
|
||||
local tabId = multishell.getCurrent()
|
||||
|
||||
_G.device.keyboard.addHotkey('control-p', function()
|
||||
os.queueEvent('recorder_stop')
|
||||
os.queueEvent('recorder_stop')
|
||||
end)
|
||||
|
||||
local tabs = multishell.getTabs()
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
_G.requireInjector()
|
||||
|
||||
local GPS = require('gps')
|
||||
local Socket = require('socket')
|
||||
local UI = require('ui')
|
||||
|
||||
35
farms/help/superTreefarm
Normal file
35
farms/help/superTreefarm
Normal file
@@ -0,0 +1,35 @@
|
||||
An advanced tree farming program for use when you have gathered enough resources to fulfill the requirements (see the treefarm program for a day 1 tree farming program).
|
||||
|
||||
The turtle will refuel itself from charcoal that it will make from the logs gathered (no fuel is required initially).
|
||||
|
||||
Requirements
|
||||
============
|
||||
* Advanced Turtle
|
||||
* Diamond Pickaxe
|
||||
* Standard Modem
|
||||
* Block Scanner
|
||||
* Entity Sensor
|
||||
* Crafting Table
|
||||
* Vanilla Chest
|
||||
* GPS
|
||||
|
||||
Setup
|
||||
=====
|
||||
> pastebin run uzghlbnc
|
||||
> package install farms
|
||||
> reboot
|
||||
|
||||
The tree farm fits exactly in one chunk. It's best to have a mostly level ground around the center of the farming area as the turtle will only collect saplings that have fallen to the same level as the turtle.
|
||||
|
||||
To align the turtle perfectly in one chunk, position the turtle 8 blocks diagonally from the bottom left corner.
|
||||
|
||||
Place a sapling directly in front of the turtle and place all the required items into the inventory.
|
||||
|
||||
To start the program, run:
|
||||
|
||||
> superTreefarm
|
||||
A startup file is created automatically the first time the program is run (usr/autorun/superTreefarm.lua).
|
||||
|
||||
Tips
|
||||
====
|
||||
At any time, you can add additional saplings into the turtle's inventory. The modem is only needed for GPS. Wireless network can be disabled via System->Networking.
|
||||
@@ -1,5 +1,3 @@
|
||||
_G.requireInjector()
|
||||
|
||||
local Pathing = require('turtle.pathfind')
|
||||
local Point = require('point')
|
||||
local Util = require('util')
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
_G.requireInjector()
|
||||
|
||||
local Terminal = require('terminal')
|
||||
local Util = require('util')
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
_G.requireInjector()
|
||||
|
||||
local Event = require('event')
|
||||
local Logger = require('logger')
|
||||
local Socket = require('socket')
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
_G.requireInjector()
|
||||
|
||||
local Event = require('event')
|
||||
local Logger = require('logger')
|
||||
local Socket = require('socket')
|
||||
|
||||
@@ -19,9 +19,14 @@
|
||||
category = "Neural",
|
||||
run = "neuralRemote.lua",
|
||||
},
|
||||
[ "Entities" ] = {
|
||||
title = "Entities",
|
||||
[ "Sensor" ] = {
|
||||
title = "Sensor",
|
||||
category = "Neural",
|
||||
run = "Entities.lua",
|
||||
},
|
||||
[ "Scanner" ] = {
|
||||
title = "Scanner",
|
||||
category = "Neural",
|
||||
run = "Scanner.lua",
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
_G.requireInjector()
|
||||
|
||||
local Angle = require('neural.angle')
|
||||
local GPS = require('gps')
|
||||
local Mobs = require('neural.mobs')
|
||||
@@ -16,20 +14,20 @@ local uid = ni.getID and ni.getID() or error('Introspection module is required')
|
||||
local pos = { x = 0, y = 0, z = 0 }
|
||||
|
||||
local function findTargets()
|
||||
local l = ni.sense()
|
||||
table.sort(l, function(e1, e2)
|
||||
return Point.distance(e1, pos) < Point.distance(e2, pos)
|
||||
end)
|
||||
local l = ni.sense()
|
||||
table.sort(l, function(e1, e2)
|
||||
return Point.distance(e1, pos) < Point.distance(e2, pos)
|
||||
end)
|
||||
|
||||
local targets = { }
|
||||
for _,v in ipairs(l) do
|
||||
if v.id ~= uid and Mobs.getNames()[v.name] then
|
||||
if math.abs(v.y) < 2 and Point.distance(v, pos) < 16 then -- pitch is broken
|
||||
table.insert(targets, v)
|
||||
end
|
||||
end
|
||||
end
|
||||
return #targets > 0 and targets
|
||||
local targets = { }
|
||||
for _,v in ipairs(l) do
|
||||
if v.id ~= uid and Mobs.getNames()[v.name] then
|
||||
if math.abs(v.y) < 2 and Point.distance(v, pos) < 16 then -- pitch is broken
|
||||
table.insert(targets, v)
|
||||
end
|
||||
end
|
||||
end
|
||||
return #targets > 0 and targets
|
||||
end
|
||||
|
||||
local function shootAt(targets)
|
||||
@@ -69,11 +67,11 @@ while true do
|
||||
print('walking to starting point')
|
||||
local s, m = ni.goTo(pt.x, pt.y, pt.z)
|
||||
Util.print({ s, m })
|
||||
os.sleep(.05)
|
||||
while ni.isWalking() do
|
||||
os.sleep(0)
|
||||
end
|
||||
Util.print('done walking')
|
||||
os.sleep(.05)
|
||||
while ni.isWalking() do
|
||||
os.sleep(0)
|
||||
end
|
||||
Util.print('done walking')
|
||||
end
|
||||
os.sleep(1)
|
||||
else
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
_G.requireInjector()
|
||||
|
||||
local Angle = require('neural.angle')
|
||||
local ni = require('neural.interface')
|
||||
local Util = require('util')
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
_G.requireInjector()
|
||||
|
||||
local Event = require('event')
|
||||
local ChestAdapter = require('chestAdapter18')
|
||||
local Point = require('point')
|
||||
|
||||
@@ -24,8 +24,6 @@
|
||||
MMMMMM
|
||||
]]--
|
||||
|
||||
_G.requireInjector()
|
||||
|
||||
local InventoryAdapter = require('inventoryAdapter')
|
||||
local Config = require('config')
|
||||
local Event = require('event')
|
||||
|
||||
@@ -80,8 +80,6 @@
|
||||
name/monitor_1 - specify the exact name of the peripheral
|
||||
]]--
|
||||
|
||||
_G.requireInjector()
|
||||
|
||||
local Ansi = require('ansi')
|
||||
local Config = require('config')
|
||||
local Craft = require('turtle.craft')
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
_G.requireInjector()
|
||||
|
||||
local InventoryAdapter = require('inventoryAdapter')
|
||||
local Config = require('config')
|
||||
local Event = require('event')
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
_G.requireInjector()
|
||||
|
||||
local InventoryAdapter = require('inventoryAdapter')
|
||||
local Event = require('event')
|
||||
local UI = require('ui')
|
||||
|
||||
Reference in New Issue
Block a user