Added CC/OC scripts for laser tree farm
This commit is contained in:
parent
6ea640f071
commit
ce55086e87
5 changed files with 340 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
|||
package cr0s.warpdrive.block.collection;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
|
@ -88,6 +89,7 @@ public class TileEntityLaserTreeFarm extends TileEntityAbstractMiner {
|
|||
"tapTrees"
|
||||
});
|
||||
laserMediumMaxCount = WarpDriveConfig.TREE_FARM_MAX_MEDIUMS_COUNT;
|
||||
CC_scripts = Arrays.asList("farm", "stop");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,113 @@
|
|||
if not term.isColor() then
|
||||
print("Advanced computer required")
|
||||
exit()
|
||||
end
|
||||
|
||||
sides = peripheral.getNames()
|
||||
treefarms = {}
|
||||
for key,side in pairs(sides) do
|
||||
if peripheral.getType(side) == "warpdriveLaserTreefarm" then
|
||||
print("Wrapping " .. side)
|
||||
table.insert(treefarms, peripheral.wrap(side))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
noExit = true
|
||||
breakLeaves = true
|
||||
tapTrees = true
|
||||
silktouch = false
|
||||
args = {...}
|
||||
if #args > 0 then
|
||||
if args[1] == "help" or args[1] == "?" then
|
||||
print("Usage: farm <breakLeaves> <tapTrees> <silktouch>")
|
||||
print()
|
||||
print("Farmer always farm above it.")
|
||||
print("Use 'true' or '1' to enable an option.")
|
||||
print("Use 'false' or '0' to disable an option.")
|
||||
print("Default is to break leaves and tap rubber trees.")
|
||||
print("Sapplings will be automatically replanted.")
|
||||
print("Farming automatically stops when inventory is full.")
|
||||
print()
|
||||
noExit = false
|
||||
else
|
||||
if args[1] == "false" or args[1] == "0" then
|
||||
breakLeaves = false
|
||||
end
|
||||
end
|
||||
|
||||
if #args > 1 then
|
||||
if args[2] == "false" or args[2] == "0" then
|
||||
tapTrees = false
|
||||
end
|
||||
end
|
||||
|
||||
if #args > 2 then
|
||||
if args[3] == "true" or args[3] == "1" then
|
||||
silktouch = true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if #treefarms == 0 then
|
||||
term.setBackgroundColor(colors.red)
|
||||
term.setTextColor(colors.white)
|
||||
term.write("No laser tree farm detected")
|
||||
|
||||
noExit = false
|
||||
end
|
||||
if noExit then
|
||||
for key,treefarm in pairs(treefarms) do
|
||||
statusString, isActive = treefarm.state()
|
||||
if not isActive then
|
||||
treefarm.breakLeaves(breakLeaves)
|
||||
treefarm.tapTrees(tapTrees)
|
||||
treefarm.silktouch(silktouch)
|
||||
|
||||
treefarm.start()
|
||||
end
|
||||
end
|
||||
sleep(1)
|
||||
end
|
||||
|
||||
label = os.getComputerLabel()
|
||||
if label then
|
||||
else
|
||||
label = "" .. os.getComputerID()
|
||||
end
|
||||
|
||||
term.setTextColor(colors.blue)
|
||||
if noExit then
|
||||
repeat
|
||||
isActive = false
|
||||
for key,treefarm in pairs(treefarms) do
|
||||
status, isActive, energy, totalHarvested, currentValuable, totalValuables = treefarm.state()
|
||||
|
||||
term.setBackgroundColor(colors.black)
|
||||
term.clear()
|
||||
term.setBackgroundColor(colors.lime)
|
||||
term.setCursorPos(1, 1)
|
||||
term.write(label .. " - Laser tree farm " .. key .. " of " .. #treefarms)
|
||||
term.setBackgroundColor(colors.black)
|
||||
term.setCursorPos(1, 3)
|
||||
term.write("Status: " .. status .. " ")
|
||||
term.setBackgroundColor(colors.black)
|
||||
term.setCursorPos(1, 5)
|
||||
term.write("Energy level is " .. energy .. " EU")
|
||||
term.setCursorPos(1, 7)
|
||||
term.write("Farmed " .. currentValuable .. " out of " .. totalValuables .. " blocks in current cycle ")
|
||||
term.setCursorPos(1, 9)
|
||||
term.write("Harvested " .. totalHarvested .. " items and counting... ")
|
||||
|
||||
if isActive then
|
||||
sleep(1)
|
||||
else
|
||||
sleep(0.1)
|
||||
end
|
||||
end
|
||||
until not isActive
|
||||
end
|
||||
|
||||
term.setBackgroundColor(colors.black)
|
||||
term.setTextColor(colors.white)
|
||||
print()
|
|
@ -0,0 +1,49 @@
|
|||
if not term.isColor() then
|
||||
print("Advanced computer required")
|
||||
exit()
|
||||
end
|
||||
|
||||
sides = peripheral.getNames()
|
||||
treefarms = {}
|
||||
for key,side in pairs(sides) do
|
||||
if peripheral.getType(side) == "warpdriveLaserTreefarm" then
|
||||
print("Wrapping " .. side)
|
||||
table.insert(treefarms, peripheral.wrap(side))
|
||||
end
|
||||
end
|
||||
|
||||
label = os.getComputerLabel()
|
||||
if label then
|
||||
else
|
||||
label = "" .. os.getComputerID()
|
||||
end
|
||||
term.setBackgroundColor(colors.black)
|
||||
term.clear()
|
||||
term.setBackgroundColor(colors.lime)
|
||||
term.setCursorPos(1, 1)
|
||||
term.write(label)
|
||||
|
||||
if #treefarms == 0 then
|
||||
term.setBackgroundColor(colors.red)
|
||||
term.setTextColor(colors.white)
|
||||
term.write("No laser tree farm detected")
|
||||
else
|
||||
for key,treefarm in pairs(treefarms) do
|
||||
term.setCursorPos(1, 2 + key)
|
||||
statusString, isActive = treefarm.state()
|
||||
if not isActive then
|
||||
term.setBackgroundColor(colors.red)
|
||||
term.setTextColor(colors.white)
|
||||
term.write("Laser tree farm " .. key .. " of " .. #treefarms .. " is already stopped")
|
||||
else
|
||||
treefarm.stop()
|
||||
term.setBackgroundColor(colors.lime)
|
||||
term.setTextColor(colors.blue)
|
||||
term.write("Laser tree farm " .. key .. " of " .. #treefarms .. " has been stopped")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
term.setBackgroundColor(colors.black)
|
||||
term.setTextColor(colors.white)
|
||||
print()
|
|
@ -0,0 +1,117 @@
|
|||
local component = require("component")
|
||||
local computer = require("computer")
|
||||
local term = require("term")
|
||||
|
||||
if not term.isAvailable() then
|
||||
computer.beep()
|
||||
return
|
||||
end
|
||||
|
||||
treefarms = {}
|
||||
for address,type in component.list("warpdriveLaserTreefarm", true) do
|
||||
print("Wrapping " .. address)
|
||||
table.insert(treefarms, component.proxy(address))
|
||||
end
|
||||
|
||||
function textOut(x, y, text, fg, bg)
|
||||
if term.isAvailable() then
|
||||
local w, h = component.gpu.getResolution()
|
||||
if w then
|
||||
component.gpu.setBackground(bg)
|
||||
component.gpu.setForeground(fg)
|
||||
component.gpu.set(x, y, text)
|
||||
component.gpu.setBackground(0x000000)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
noExit = true
|
||||
breakLeaves = true
|
||||
tapTrees = true
|
||||
silktouch = false
|
||||
args = {...}
|
||||
if #args > 0 then
|
||||
if args[1] == "help" or args[1] == "?" then
|
||||
print("Usage: farm <breakLeaves> <tapTrees> <silktouch>")
|
||||
print()
|
||||
print("Farmer always farm above it.")
|
||||
print("Use 'true' or '1' to enable an option.")
|
||||
print("Use 'false' or '0' to disable an option.")
|
||||
print("Default is to break leaves and tap rubber trees.")
|
||||
print("Sapplings will be automatically replanted.")
|
||||
print("Farming automatically stops when inventory is full.")
|
||||
print()
|
||||
noExit = false
|
||||
else
|
||||
if args[1] == "false" or args[1] == "0" then
|
||||
breakLeaves = false
|
||||
end
|
||||
end
|
||||
|
||||
if #args > 1 then
|
||||
if args[2] == "false" or args[2] == "0" then
|
||||
tapTrees = false
|
||||
end
|
||||
end
|
||||
|
||||
if #args > 2 then
|
||||
if args[3] == "true" or args[3] == "1" then
|
||||
silktouch = true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if #treefarms == 0 then
|
||||
computer.beep()
|
||||
textOut(1, 2, "No laser tree farm detected", 0xFFFFFF, 0xFF0000)
|
||||
noExit = false
|
||||
end
|
||||
if noExit then
|
||||
for key,treefarm in pairs(treefarms) do
|
||||
statusString, isActive = treefarm.state()
|
||||
if not isActive then
|
||||
treefarm.breakLeaves(breakLeaves)
|
||||
treefarm.tapTrees(tapTrees)
|
||||
treefarm.silktouch(silktouch)
|
||||
|
||||
treefarm.start()
|
||||
end
|
||||
end
|
||||
os.sleep(1)
|
||||
end
|
||||
|
||||
local file = io.open("/etc/hostname")
|
||||
if file then
|
||||
label = file:read("*l")
|
||||
file:close()
|
||||
else
|
||||
label = "" .. computer.address()
|
||||
end
|
||||
|
||||
if noExit then
|
||||
repeat
|
||||
isActive = false
|
||||
for key,treefarm in pairs(treefarms) do
|
||||
status, isActive, energy, totalHarvested, currentValuable, totalValuables = treefarm.state()
|
||||
|
||||
term.clear()
|
||||
textOut(1, 1, label .. " - Laser tree farm " .. key .. " of " .. #treefarms, 0x0000FF, 0x00FF00)
|
||||
textOut(1, 3, "Status: " .. status .. " ", 0x0000FF, 0x000000)
|
||||
textOut(1, 4, "Energy level is " .. energy .. " EU", 0x0000FF, 0x000000)
|
||||
textOut(1, 7, "Farmed " .. currentValuable .. " out of " .. totalValuables .. " blocks ", 0xFFFFFF, 0x000000)
|
||||
textOut(1, 9, "Harvested " .. totalHarvested .. " items and counting... ", 0xFFFFFF, 0x000000)
|
||||
|
||||
if isActive then
|
||||
os.sleep(1)
|
||||
else
|
||||
os.sleep(0.1)
|
||||
end
|
||||
end
|
||||
until not isActive
|
||||
end
|
||||
|
||||
textOut(1, 1, "", 0xFFFFFF, 0x000000)
|
||||
|
||||
print("")
|
||||
print("")
|
|
@ -0,0 +1,59 @@
|
|||
local component = require("component")
|
||||
local computer = require("computer")
|
||||
local term = require("term")
|
||||
|
||||
if not term.isAvailable() then
|
||||
computer.beep()
|
||||
return
|
||||
end
|
||||
|
||||
treefarms = {}
|
||||
for address,type in component.list("warpdriveLaserTreefarm", true) do
|
||||
table.insert(treefarms, component.proxy(address))
|
||||
end
|
||||
|
||||
local file = io.open("/etc/hostname")
|
||||
if file then
|
||||
label = file:read("*l")
|
||||
file:close()
|
||||
else
|
||||
label = "" .. computer.address()
|
||||
end
|
||||
|
||||
term.clear()
|
||||
|
||||
function textOut(x, y, text, fg, bg)
|
||||
if term.isAvailable() then
|
||||
local w, h = component.gpu.getResolution()
|
||||
if w then
|
||||
component.gpu.setBackground(bg)
|
||||
component.gpu.setForeground(fg)
|
||||
component.gpu.set(x, y, text)
|
||||
component.gpu.setBackground(0x000000)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
textOut(1, 1, label, 0x00FF00, 0x000000)
|
||||
print("")
|
||||
|
||||
if #treefarms == 0 then
|
||||
computer.beep()
|
||||
textOut(1, 2, "No laser tree farm detected", 0xFF0000, 0x000000)
|
||||
else
|
||||
for key,treefarm in pairs(treefarms) do
|
||||
statusString, isActive = treefarm.state()
|
||||
if not isActive then
|
||||
textOut(1, 2 + key, "Mining laser " .. key .. " of " .. #treefarms .. " is already stopped", 0xFFFFFF, 0xFF0000)
|
||||
else
|
||||
treefarm.stop()
|
||||
textOut(1, 2 + key, "Mining laser " .. key .. " of " .. #treefarms .. " has been stopped", 0x0000FF, 0x00FF00)
|
||||
end
|
||||
print("")
|
||||
end
|
||||
end
|
||||
textOut(1, 1, "", 0xFFFFFF, 0x000000)
|
||||
|
||||
print("")
|
||||
print("")
|
Loading…
Reference in a new issue