CCCPaste

melonbot2

term.clear()
term.setCursorPos(1,1)
ykok,xkok,y,x = nil,nil,1,1
print("*Murinaa* Olen Meloninkeraysbot v1.01!")
print("Sijainti: pellon vasen alanurkka.\n")

--while ykok == nil do
	--write("Syota pellon y-akseli: ")
	--ykok = tonumber(read())
--end
ykok = 18

--while xkok == nil do
--	write("Syota pellon x-akseli: ")
--	xkok = tonumber(read())
--end
xkok = 2

--mene eteenpain
function eteen()
	while turtle.forward() == false do end
end

-- eteenpain yksi column
function mene()
	for i=0, ykok do

		if turtle.detect() then
			turtle.dig()
		end
		eteen()
		turtle.turnLeft()
		if turtle.detect() then
			turtle.dig()
		end
		turtle.turnRight()
	end
end

-- timestamp-funktio
function stamp()
	return "["..os.day()..": "..os.time().."] "
end




-- main init
term.clear()
term.setCursorPos(1,1)

--refuel
turtle.select(1) 
a = turtle.refuel()
if a == false then
	print(stamp().."ei fuelia")
	os.sleep(5)
	os.shutdown()
end

turtle.turnRight()


-- main
while true do

	print(stamp().."Ajellaan... pellon koko: "..ykok.."x"..xkok..".")

	--alku
	eteen()
	eteen()
	turtle.turnRight()

	mene()

    --kaanto paadyssa
	turtle.turnRight()
	eteen()
	eteen()
	eteen()
	eteen()
	turtle.turnRight()

	mene()

    --kaanto
	turtle.turnRight()
	eteen()
	eteen()
	
	--dump
	for i=1, 16 do
		turtle.select(i)
		turtle.dropDown()
	end

	--wait
	for i=0, 4 do
		print(stamp().."Sleeppia jaljella "..tostring(120-i*30).." sekuntia..")
		os.sleep(30)
	end

	eteen()
	eteen()
	turtle.turnLeft()

end