require overhaul part 2

This commit is contained in:
kepler155c@gmail.com
2018-12-23 17:32:38 -05:00
parent 29af471374
commit 83a9aa46ab
23 changed files with 99 additions and 101 deletions

View File

@@ -1,5 +1,3 @@
_G.requireInjector()
local Base64 = require('base64') local Base64 = require('base64')
local http = _G.http local http = _G.http
@@ -9,13 +7,13 @@ local shell = _ENV.shell
local args = { ... } local args = { ... }
if not args[2] then if not args[2] then
error('Syntax: base64dl <file name> <url>') error('Syntax: base64dl <file name> <url>')
end end
local c = http.get(args[2]) local c = http.get(args[2])
if not c then if not c then
error('unable to open url') error('unable to open url')
end end
local data = c.readAll() local data = c.readAll()
@@ -27,13 +25,13 @@ print('decoded: ' .. #decoded)
local file = io.open(shell.resolve(args[1]), "wb") local file = io.open(shell.resolve(args[1]), "wb")
if not file then if not file then
error('Unable to open ' .. args[1], 2) error('Unable to open ' .. args[1], 2)
end end
for k,b in ipairs(decoded) do for k,b in ipairs(decoded) do
if (k % 1000) == 0 then if (k % 1000) == 0 then
os.sleep(0) os.sleep(0)
end end
file:write(b) file:write(b)
end end
file:close() file:close()

View File

@@ -2,8 +2,6 @@ if not _G.turtle and not _G.commands then
error('Must be run on a turtle or a command computer') error('Must be run on a turtle or a command computer')
end end
_G.requireInjector()
local Adapter = require('inventoryAdapter') local Adapter = require('inventoryAdapter')
local Event = require('event') local Event = require('event')
local GPS = require('gps') local GPS = require('gps')

View File

@@ -1,5 +1,3 @@
_G.requireInjector()
local Event = require('event') local Event = require('event')
local Logger = require('logger') local Logger = require('logger')
local MEProvider = require('meProvider') local MEProvider = require('meProvider')
@@ -30,7 +28,7 @@ if Util.getVersion() == 1.8 then
end end
if not device.wireless_modem then if not device.wireless_modem then
error('No wireless modem detected') error('No wireless modem detected')
end end
Logger.filter('modem_send', 'event', 'ui') Logger.filter('modem_send', 'event', 'ui')
@@ -230,36 +228,36 @@ function Builder:finish()
end end
function Builder:gotoBuilder() function Builder:gotoBuilder()
if Builder.lastPoint then if Builder.lastPoint then
turtle.setStatus('tracking') turtle.setStatus('tracking')
while true do while true do
local pt = Point.copy(Builder.lastPoint) local pt = Point.copy(Builder.lastPoint)
pt.y = pt.y + 3 pt.y = pt.y + 3
if turtle.point.y ~= pt.y then if turtle.point.y ~= pt.y then
turtle.gotoY(pt.y) turtle.gotoY(pt.y)
else else
local distance = Point.turtleDistance(turtle.point, pt) local distance = Point.turtleDistance(turtle.point, pt)
if distance <= 3 then if distance <= 3 then
Builder:log('Synchronized') Builder:log('Synchronized')
break break
end end
if turtle.point.heading % 2 == 0 then if turtle.point.heading % 2 == 0 then
if turtle.point.x == pt.x then if turtle.point.x == pt.x then
turtle.headTowardsZ(pt.z) turtle.headTowardsZ(pt.z)
moveTowardsZ(pt.z) moveTowardsZ(pt.z)
else else
moveTowardsX(pt.x) moveTowardsX(pt.x)
end end
elseif turtle.point.z ~= pt.z then elseif turtle.point.z ~= pt.z then
moveTowardsZ(pt.z) moveTowardsZ(pt.z)
else else
turtle.headTowardsX(pt.x) turtle.headTowardsX(pt.x)
moveTowardsX(pt.x) moveTowardsX(pt.x)
end end
end end
end end
end end
end end
Message.addHandler('builder', Message.addHandler('builder',
@@ -385,8 +383,8 @@ Event.on('turtle_abort',
local function onTheWay() -- parallel routine local function onTheWay() -- parallel routine
while true do while true do
local _, _, _, id, msg, _ = os.pullEvent('modem_message') local _, _, _, id, msg, _ = os.pullEvent('modem_message')
if Builder.ready then if Builder.ready then
if id == __BUILDER_ID and msg and msg.type then if id == __BUILDER_ID and msg and msg.type then
if msg.type == 'needSupplies' then if msg.type == 'needSupplies' then
Message.send(__BUILDER_ID, 'gotSupplies', { supplies = true }) Message.send(__BUILDER_ID, 'gotSupplies', { supplies = true })

View File

@@ -1,5 +1,3 @@
_G.requireInjector()
local Ansi = require('ansi') local Ansi = require('ansi')
local SHA1 = require('sha1') local SHA1 = require('sha1')
local UI = require('ui') local UI = require('ui')

View File

@@ -1,5 +1,3 @@
_G.requireInjector()
local Event = require('event') local Event = require('event')
local UI = require('ui') local UI = require('ui')
local Util = require('util') local Util = require('util')

View File

@@ -1,5 +1,3 @@
_G.requireInjector()
local Event = require('event') local Event = require('event')
local UI = require('ui') local UI = require('ui')

View File

@@ -1,5 +1,3 @@
_G.requireInjector()
local Config = require('config') local Config = require('config')
local Event = require('event') local Event = require('event')
local Socket = require('socket') local Socket = require('socket')

View File

@@ -1,5 +1,3 @@
_G.requireInjector()
local Config = require('config') local Config = require('config')
local Event = require('event') local Event = require('event')
local itemDB = require('itemDB') local itemDB = require('itemDB')

View File

@@ -14,8 +14,6 @@ local version = "Version 1.1.6"
-- Original code by Bomb Bloke -- Original code by Bomb Bloke
-- Modified to integrate with opus os -- Modified to integrate with opus os
_G.requireInjector()
local Util = require('util') local Util = require('util')
local multishell = _ENV.multishell local multishell = _ENV.multishell
@@ -151,7 +149,7 @@ end
local tabId = multishell.getCurrent() local tabId = multishell.getCurrent()
_G.device.keyboard.addHotkey('control-p', function() _G.device.keyboard.addHotkey('control-p', function()
os.queueEvent('recorder_stop') os.queueEvent('recorder_stop')
end) end)
local tabs = multishell.getTabs() local tabs = multishell.getTabs()

View File

@@ -1,5 +1,3 @@
_G.requireInjector()
local GPS = require('gps') local GPS = require('gps')
local Socket = require('socket') local Socket = require('socket')
local UI = require('ui') local UI = require('ui')

35
farms/help/superTreefarm Normal file
View 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.

View File

@@ -1,5 +1,3 @@
_G.requireInjector()
local Pathing = require('turtle.pathfind') local Pathing = require('turtle.pathfind')
local Point = require('point') local Point = require('point')
local Util = require('util') local Util = require('util')

View File

@@ -1,5 +1,3 @@
_G.requireInjector()
local Terminal = require('terminal') local Terminal = require('terminal')
local Util = require('util') local Util = require('util')

View File

@@ -1,5 +1,3 @@
_G.requireInjector()
local Event = require('event') local Event = require('event')
local Logger = require('logger') local Logger = require('logger')
local Socket = require('socket') local Socket = require('socket')

View File

@@ -1,5 +1,3 @@
_G.requireInjector()
local Event = require('event') local Event = require('event')
local Logger = require('logger') local Logger = require('logger')
local Socket = require('socket') local Socket = require('socket')

View File

@@ -19,9 +19,14 @@
category = "Neural", category = "Neural",
run = "neuralRemote.lua", run = "neuralRemote.lua",
}, },
[ "Entities" ] = { [ "Sensor" ] = {
title = "Entities", title = "Sensor",
category = "Neural", category = "Neural",
run = "Entities.lua", run = "Entities.lua",
}, },
[ "Scanner" ] = {
title = "Scanner",
category = "Neural",
run = "Scanner.lua",
},
} }

View File

@@ -1,5 +1,3 @@
_G.requireInjector()
local Angle = require('neural.angle') local Angle = require('neural.angle')
local GPS = require('gps') local GPS = require('gps')
local Mobs = require('neural.mobs') 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 pos = { x = 0, y = 0, z = 0 }
local function findTargets() local function findTargets()
local l = ni.sense() local l = ni.sense()
table.sort(l, function(e1, e2) table.sort(l, function(e1, e2)
return Point.distance(e1, pos) < Point.distance(e2, pos) return Point.distance(e1, pos) < Point.distance(e2, pos)
end) end)
local targets = { } local targets = { }
for _,v in ipairs(l) do for _,v in ipairs(l) do
if v.id ~= uid and Mobs.getNames()[v.name] then 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 if math.abs(v.y) < 2 and Point.distance(v, pos) < 16 then -- pitch is broken
table.insert(targets, v) table.insert(targets, v)
end end
end end
end end
return #targets > 0 and targets return #targets > 0 and targets
end end
local function shootAt(targets) local function shootAt(targets)
@@ -69,11 +67,11 @@ while true do
print('walking to starting point') print('walking to starting point')
local s, m = ni.goTo(pt.x, pt.y, pt.z) local s, m = ni.goTo(pt.x, pt.y, pt.z)
Util.print({ s, m }) Util.print({ s, m })
os.sleep(.05) os.sleep(.05)
while ni.isWalking() do while ni.isWalking() do
os.sleep(0) os.sleep(0)
end end
Util.print('done walking') Util.print('done walking')
end end
os.sleep(1) os.sleep(1)
else else

View File

@@ -1,5 +1,3 @@
_G.requireInjector()
local Angle = require('neural.angle') local Angle = require('neural.angle')
local ni = require('neural.interface') local ni = require('neural.interface')
local Util = require('util') local Util = require('util')

View File

@@ -1,5 +1,3 @@
_G.requireInjector()
local Event = require('event') local Event = require('event')
local ChestAdapter = require('chestAdapter18') local ChestAdapter = require('chestAdapter18')
local Point = require('point') local Point = require('point')

View File

@@ -24,8 +24,6 @@
MMMMMM MMMMMM
]]-- ]]--
_G.requireInjector()
local InventoryAdapter = require('inventoryAdapter') local InventoryAdapter = require('inventoryAdapter')
local Config = require('config') local Config = require('config')
local Event = require('event') local Event = require('event')

View File

@@ -80,8 +80,6 @@
name/monitor_1 - specify the exact name of the peripheral name/monitor_1 - specify the exact name of the peripheral
]]-- ]]--
_G.requireInjector()
local Ansi = require('ansi') local Ansi = require('ansi')
local Config = require('config') local Config = require('config')
local Craft = require('turtle.craft') local Craft = require('turtle.craft')

View File

@@ -1,5 +1,3 @@
_G.requireInjector()
local InventoryAdapter = require('inventoryAdapter') local InventoryAdapter = require('inventoryAdapter')
local Config = require('config') local Config = require('config')
local Event = require('event') local Event = require('event')

View File

@@ -1,5 +1,3 @@
_G.requireInjector()
local InventoryAdapter = require('inventoryAdapter') local InventoryAdapter = require('inventoryAdapter')
local Event = require('event') local Event = require('event')
local UI = require('ui') local UI = require('ui')