forgot files
This commit is contained in:
parent
8b9914f3b6
commit
1370236958
3
.idea/.gitignore
vendored
Normal file
3
.idea/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
9
.idea/Computercraft.iml
Normal file
9
.idea/Computercraft.iml
Normal file
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
6
.idea/misc.xml
Normal file
6
.idea/misc.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_22" default="true" project-jdk-name="22" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
8
.idea/modules.xml
Normal file
8
.idea/modules.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/Computercraft.iml" filepath="$PROJECT_DIR$/.idea/Computercraft.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
6
.idea/vcs.xml
Normal file
6
.idea/vcs.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
13
src/main/files/sync-filelist.txt
Executable file
13
src/main/files/sync-filelist.txt
Executable file
@ -0,0 +1,13 @@
|
||||
{
|
||||
[0] = "startup.lua",
|
||||
[1] = "bos/system-lock.lua",
|
||||
[2] = "bos/lib/networking.lua",
|
||||
[3] = "bos/lib/basic-functions.lua",
|
||||
[4] = "bos/turtle-farmer.lua",
|
||||
[5] = "bos/turtle-miner.lua",
|
||||
[6] = "bos/turtle-miner-enderchest.lua",
|
||||
[7] = "bos/turtle-miner-enderchest2.lua",
|
||||
[8] = "bos/turtle-wood.lua",
|
||||
[9] = "bos/turtle-build.lua",
|
||||
[10] = "bos/stairs.lua",
|
||||
}
|
7
src/main/files/sync-targets.txt
Executable file
7
src/main/files/sync-targets.txt
Executable file
@ -0,0 +1,7 @@
|
||||
{
|
||||
[ 0 ] = "Turtle Dish",
|
||||
[ 1 ] = "Wood Dish",
|
||||
[ 2 ] = "Nether Dish",
|
||||
[ 3 ] = "Farmer Dish",
|
||||
[ 4 ] = "Door Panel",
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
os.loadAPI("bos/lib/aes.lua")
|
||||
--aes = require("lib.aes")
|
||||
|
||||
|
||||
local encMessage = aes.encrypt("MyKey", "My Message")
|
||||
|
||||
print("encMessage: " .. encMessage)
|
||||
sleep(2)
|
||||
|
||||
local decMessage = aes.decrypt("MyKey", encMessage)
|
||||
print("decMessage: " .. decMessage)
|
||||
sleep(2)
|
||||
|
||||
|
||||
|
@ -1,20 +0,0 @@
|
||||
os.loadAPI("brammeros/programs/cryptography/hash.lua")
|
||||
|
||||
|
||||
while true do
|
||||
write("Eingabe: ")
|
||||
message = read()
|
||||
|
||||
hashedMessage = hash.digestStr(message)
|
||||
print("")
|
||||
print("Hashed Stuff: " .. hashedMessage)
|
||||
print("")
|
||||
print("")
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
298
src/main/programs/turtle-miner.lua
Executable file
298
src/main/programs/turtle-miner.lua
Executable file
@ -0,0 +1,298 @@
|
||||
basic_functions = require("lib.basic-functions")
|
||||
|
||||
ore_list = {
|
||||
[0] = "minecraft:gold_ore",
|
||||
[1] = "minecraft:deepslate_gold_ore",
|
||||
[2] = "minecraft:iron_ore",
|
||||
[3] = "minecraft:deepslate_iron_ore",
|
||||
[4] = "minecraft:coal_ore",
|
||||
[5] = "minecraft:deepslate_coal_ore",
|
||||
[6] = "minecraft:lapis_ore",
|
||||
[7] = "minecraft:deepslate_lapis_ore",
|
||||
[8] = "minecraft:diamond_ore",
|
||||
[9] = "minecraft:deepslate_diamond_ore",
|
||||
[10] = "minecraft:redstone_ore",
|
||||
[11] = "minecraft:deepslate_redstone_ore",
|
||||
[12] = "minecraft:emerald_ore",
|
||||
[13] = "minecraft:deepslate_emerald_ore",
|
||||
[14] = "minecraft:quartz_ore",
|
||||
[15] = "minecraft:deepslate_quartz_ore",
|
||||
[16] = "minecraft:copper_ore",
|
||||
[17] = "minecraft:deepslate_copper_ore",
|
||||
[18] = "minecraft:ancient_debris",
|
||||
}
|
||||
|
||||
throw_away_list = {
|
||||
[0] = "minecraft:cobblestone",
|
||||
[1] = "minecraft:dirt",
|
||||
[2] = "minecraft:gravel",
|
||||
[3] = "minecraft:andesite",
|
||||
[4] = "minecraft:cobbled_deepslate",
|
||||
[5] = "minecraft:diorite",
|
||||
[6] = "minecraft:tuff",
|
||||
[7] = "minecraft:netherrack",
|
||||
}
|
||||
|
||||
local function get_fuel_level()
|
||||
fuel_level = turtle.getFuelLevel()
|
||||
return fuel_level
|
||||
end
|
||||
|
||||
|
||||
|
||||
local function save_state()
|
||||
basic_functions.write_to_file("bos/files/turtle-state.txt", textutils.serialize(state))
|
||||
end
|
||||
|
||||
|
||||
|
||||
local function get_state()
|
||||
if not fs.exists "bos/files/turtle-state.txt" then
|
||||
turtle_state = {}
|
||||
turtle_state["script"] = "bos/turtle-miner.lua"
|
||||
turtle_state["info"] = ""
|
||||
turtle_state["fuel_level"] = get_fuel_level()
|
||||
turtle_state["data_goal_rows"] = 0
|
||||
turtle_state["data_goal_path_progress"] = 0
|
||||
turtle_state["data_current_row"] = 0
|
||||
turtle_state["data_current_path_progress"] = 0
|
||||
basic_functions.write_to_file("bos/files/turtle-state.txt", textutils.serialize(turtle_state))
|
||||
else
|
||||
turtle_state = basic_functions.read_file_all("bos/files/turtle-state.txt")
|
||||
turtle_state = textutils.unserialize(turtle_state)
|
||||
end
|
||||
return turtle_state
|
||||
end
|
||||
|
||||
local function clear_inventory()
|
||||
for i=1, 16 do
|
||||
turtle.select(i)
|
||||
item_datail = turtle.getItemDetail()
|
||||
|
||||
for j=0, #throw_away_list do
|
||||
item_detail = turtle.getItemDetail()
|
||||
if item_detail ~= nil then
|
||||
if item_detail.name == throw_away_list[j] then
|
||||
turtle.dropDown()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
turtle.select(1)
|
||||
end
|
||||
|
||||
local function store_items()
|
||||
--check inv for chest and place it
|
||||
chest_available = false
|
||||
for i=1, 16 do
|
||||
turtle.select(i)
|
||||
item_detail = turtle.getItemDetail()
|
||||
if item_detail ~= nil then
|
||||
if item_detail.name == "minecraft:chest" then
|
||||
turtle.placeDown()
|
||||
--TODO save in list, where chest is placed
|
||||
chest_available = true
|
||||
break
|
||||
elseif i == 16 then
|
||||
--TODO save in state that no chests are available
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--drop items in chest
|
||||
if chest_available then
|
||||
for i=1, 16 do
|
||||
turtle.select(i)
|
||||
item_detail = turtle.getItemDetail()
|
||||
if item_detail ~= nil then
|
||||
if item_detail.name ~= "minecraft:torch" and item_detail.name ~= "minecraft:chest" then
|
||||
turtle.dropDown()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
local function check_inventory()
|
||||
for i=1, 16 do
|
||||
turtle.select(i)
|
||||
item_count = turtle.getItemCount()
|
||||
if item_count == 0 then
|
||||
turtle.select(1)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
store_items()
|
||||
turtle.select(1)
|
||||
end
|
||||
|
||||
|
||||
|
||||
local function is_ore(block_data)
|
||||
for i=0, #ore_list do
|
||||
if block_data["name"] == ore_list[i] then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local function check_for_ore()
|
||||
for i=0, 3 do
|
||||
turtle.turnLeft()
|
||||
block_found, block_data = turtle.inspect()
|
||||
if is_ore(block_data) then
|
||||
turtle.dig()
|
||||
turtle.forward()
|
||||
check_for_ore()
|
||||
turtle.back()
|
||||
end
|
||||
end
|
||||
|
||||
block_found, block_data = turtle.inspectUp()
|
||||
if is_ore(block_data) then
|
||||
turtle.digUp()
|
||||
turtle.up()
|
||||
check_for_ore()
|
||||
turtle.down()
|
||||
end
|
||||
|
||||
block_found, block_data = turtle.inspectDown()
|
||||
if is_ore(block_data) then
|
||||
turtle.digDown()
|
||||
turtle.down()
|
||||
check_for_ore()
|
||||
turtle.up()
|
||||
end
|
||||
end
|
||||
|
||||
local function place_torch()
|
||||
for i=1, 16 do
|
||||
turtle.select(i)
|
||||
item_detail = turtle.getItemDetail()
|
||||
|
||||
if item_detail ~= nil then
|
||||
if item_detail.name == "minecraft:torch" then
|
||||
turtle.placeDown()
|
||||
end
|
||||
end
|
||||
|
||||
--pcall_success, item_detail_name = pcall(place_torch_zwei)
|
||||
|
||||
--if pcall_success and item_detail_name == "minecraft:torch" then
|
||||
-- turtle.placeDown()
|
||||
-- return true
|
||||
--end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
function mine_forward(distance)
|
||||
--mine a 3 Block high Tunnel for <distance> Blocks
|
||||
for i=state["data_current_path_progress"], distance-2 do
|
||||
|
||||
print("row: " .. state["data_current_row"]+1 .. "/" .. state["data_goal_rows"] .. ", path_progress: " .. state["data_current_path_progress"]+1 .. "/" .. state["data_goal_path_progress"])
|
||||
|
||||
turtle.dig()
|
||||
turtle.forward()
|
||||
turtle.digUp()
|
||||
turtle.digDown()
|
||||
|
||||
--check current mining step for ore
|
||||
turtle.up()
|
||||
check_for_ore()
|
||||
turtle.down()
|
||||
check_for_ore()
|
||||
turtle.down()
|
||||
check_for_ore()
|
||||
turtle.up()
|
||||
|
||||
if i%8 == 0 then
|
||||
place_torch()
|
||||
end
|
||||
|
||||
check_inventory()
|
||||
clear_inventory()
|
||||
|
||||
--save path progress
|
||||
state["data_current_path_progress"] = i+1
|
||||
state["fuel_level"] = get_fuel_level()
|
||||
save_state(state)
|
||||
end
|
||||
print("row: " .. state["data_current_row"]+1 .. "/" .. state["data_goal_rows"] .. ", path_progress: " .. state["data_current_path_progress"]+1 .. "/" .. state["data_goal_path_progress"])
|
||||
end
|
||||
|
||||
function strip_mine(rows, path_progress)
|
||||
print(">starting strip mining")
|
||||
sleep(5)
|
||||
|
||||
state = get_state()
|
||||
|
||||
--save rows and path_length as state goal
|
||||
state["data_goal_rows"] = rows
|
||||
state["data_goal_path_progress"] = path_progress
|
||||
save_state()
|
||||
|
||||
if state["fuel_level"] == 0 then
|
||||
print("OUT OF FUEL")
|
||||
else
|
||||
--main for loop
|
||||
for i=state["data_current_row"], rows-1 do
|
||||
mine_forward(path_progress)
|
||||
turtle.turnLeft()
|
||||
turtle.turnLeft()
|
||||
|
||||
while not turtle.detect() do
|
||||
turtle.forward()
|
||||
end
|
||||
|
||||
turtle.turnLeft()
|
||||
|
||||
for j=0, 2 do
|
||||
turtle.dig()
|
||||
turtle.forward()
|
||||
turtle.digUp()
|
||||
turtle.digDown()
|
||||
end
|
||||
|
||||
turtle.turnLeft()
|
||||
turtle.dig()
|
||||
turtle.forward()
|
||||
|
||||
state["data_current_row"] = i+1
|
||||
state["data_current_path_progress"] = 0
|
||||
save_state(state)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
function mine_stairs_down(length)
|
||||
for i=0, length do
|
||||
turtle.dig()
|
||||
turtle.forward()
|
||||
turtle.digUp()
|
||||
turtle.digDown()
|
||||
turtle.down()
|
||||
turtle.digDown()
|
||||
end
|
||||
end
|
||||
|
||||
state = get_state()
|
||||
--print(textutils.serialize(state))
|
||||
|
||||
--store_items()
|
||||
--strip_mine(50, 200)
|
||||
|
||||
--check_for_ore()
|
||||
--mine_forward(50)
|
||||
--mine_forward_fast(20)
|
||||
--mine_stairs_down(50)
|
||||
--stairs_up(60)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user