Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function turn_around()
- turtle.turnRight()
- turtle.turnRight()
- end
- local function wait_command()
- local senderID, command = O, {}
- senderID, command = rednet.receive()
- return senderID, command
- end
- local function go_to_chest()
- local bool = true
- local info = {}
- turtle.turnRight()
- bool, info = turtle.inspectDown()
- while info.state.color~="purple" do
- turtle.forward()
- bool, info = turtle.inspectDown()
- end
- end
- local function sort_inv()
- local base_item = {}
- local compared_item = {}
- local i = 1
- turtle.select(1)
- base_item = turtle.getItemDetail()
- while i <= 16 do
- compared_item = turtle.getItemDetail(i)
- if compared_item and compared_item.name == base_item.name then
- turtle.transferTo(i)
- end
- i = i + 1
- end
- end
- local function test_chest()
- local base_count
- local final_count
- local bool
- local i = 0
- local number
- turtle.turnLeft()
- turtle.select(1)
- base_count = turtle.getItemCount()
- while turtle.suck() do end
- turtle.select(16)
- if turtle.getItemCount()~=0 then
- sort_inv()
- i = 16
- while i>1 do
- turtle.select(i)
- turtle.drop()
- i = i - 1
- end
- else
- i = 15
- while i>0 do
- turtle.select(i)
- turtle.drop()
- i = i - 1
- end
- end
- turtle.select(1)
- final_count = turtle.getItemCount()
- if final_count~=base_count then
- bool = true
- else
- bool = false
- end
- number = base_count - final_count
- return bool, number
- end
- local function put_in_place()
- local x, y, z = 1, 0, 1
- go_home()
- end
- local function get_in_place()
- end
- local function go_home()
- local bool = true
- local info = {}
- turn_around()
- bool, info = turtle.inspectDown()
- while info.state.color~="lime" do
- turtle.forward()
- bool, info = turtle.inspectDown()
- end
- turtle.turnRight()
- end
- local function seek()
- local res_table = {}
- go_to_chest()
- if turtle.suck() then
- write(OMG)
- put_in_place()
- get_in_place()
- seek()
- else
- go_home()
- end
- end
- local function interpret(senderID, command)
- if command[1]=="seek" then
- seek()
- else if command[1]=="find" then
- write("WIP\n")
- rednet.send(senderID, "Error: Not yet implemented")
- else
- write(senderID.." sent something unknown !\n")
- rednet.send(senderID, "Error: Command not found")
- end
- end
- end
- local function main()
- local command
- local senderID
- while true do
- senderID, command = wait_command()
- interpret(senderID, command)
- end
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement