Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print ("**********************************")
- print ("* AVTOR PROGRAMMY *")
- print ("* VladWinner *")
- print ("**********************************")
- storona = 1
- rjad = 0
- laer = 0
- local params = "vladparams"
- local location = "vladlocation"
- local backup = 0
- x = 0
- xdom = 0
- xvoz = 0
- y = 0
- ydom = 0
- yvoz = 0
- z = 0
- zdom = 0
- zvoz = 0
- file = 0
- -- FUNCTIONS
- function dig()
- if turtle.detect() then
- while turtle.detect() do
- turtle.dig()
- sleep (0.5)
- end
- elseif isto4nik == 1 then
- turtle.select(16)
- while not turtle.place() do
- turtle.attack()
- end
- turtle.dig()
- end
- prov()
- end
- function comup(a)
- turtle.select(a)
- if turtle.compareUp() then
- return true
- else
- return nil
- end
- end
- function comdown(a)
- turtle.select(a)
- if turtle.compareDown() then
- return true
- else
- return nil
- end
- end
- function digup()
- if turtle.detectUp() then
- if iskl == 1 then
- if comup(14) == nil and comup(15) == nil then
- while turtle.detectUp() do
- turtle.digUp()
- sleep (0.5)
- end
- end
- else
- while turtle.detectUp() do
- turtle.digUp()
- sleep (0.5)
- end
- end
- elseif isto4nik == 1 then
- turtle.select(16)
- while not turtle.placeUp() do
- turtle.attackUp()
- end
- turtle.digUp()
- end
- prov()
- end
- function digdown()
- if turtle.detectDown() then
- if iskl == 1 then
- if comdown(14) == nil and comdown(15) == nil then
- turtle.digDown()
- end
- else
- turtle.digDown()
- end
- elseif isto4nik == 1 then
- turtle.select(16)
- while not turtle.placeDown() do
- turtle.attackDown()
- end
- turtle.digDown()
- end
- prov()
- end
- function down()
- if turtle.detectDown() then
- turtle.digDown()
- end
- while not turtle.down() do
- turtle.attackDown()
- end
- end
- function up()
- if turtle.detectUp() then
- while turtle.digUp() do
- sleep (0.5)
- end
- end
- while not turtle.up() do
- turtle.attackUp()
- end
- end
- function forward()
- if turtle.detect() then
- while turtle.dig() do
- sleep (0.5)
- end
- end
- while not turtle.forward() do
- turtle.attack()
- turtle.dig()
- end
- end
- function prov()
- base = 2
- for i = 1, col do
- if turtle.getItemCount(i) == 0 then
- base = base - 1
- end
- end
- if cobble == 0 and isto4nik == 0 then
- if turtle.getItemCount(16) == 0 then
- base = base - 1
- end
- end
- if base > 1 then
- if cobble == 1 then
- turtle.select(16)
- for i = 1, col do
- if turtle.compareTo(i) == true then
- turtle.select(i)
- turtle.drop()
- base = base - 1
- turtle.select(16)
- end
- end
- if base < 1 then
- sortirovka = 0
- for i = 1, col do
- if turtle.getItemCount(i) > 0 then
- sortirovka = sortirovka + 1
- end
- end
- for i = col, sortirovka, -1 do
- if turtle.getItemCount(i) > 0 then
- turtle.select(i)
- sorti = 1
- while not turtle.transferTo(sorti) and sorti <= sortirovka do
- sorti = sorti + 1
- end
- end
- end
- turtle.select(16)
- end
- end
- if base > 0 then
- zdom = z
- ydom = y
- xdom = x
- zvoz = z
- yvoz = y
- xvoz = x
- savelocation()
- dom()
- vozvrat()
- end
- turtle.select(16)
- end
- end
- function saveparams()
- local a = io.open (params, "w")
- a:write ("xdl = ".. xdl.. "\n")
- a:write ("col = ".. col.. "\n")
- a:write ("file = ".. file.. "\n")
- a:write ("zdl = ".. zdl.. "\n")
- a:write ("iskl = ".. iskl.. "\n")
- a:write ("cobble = ".. cobble.. "\n")
- a:write ("isto4nik = ".. isto4nik.. "\n")
- a:close()
- end
- function savelocation()
- local a = io.open (location, "w")
- a:write ("yd = ".. yd.. "\n")
- a:write ("x = ".. x.. "\n")
- a:write ("y = ".. y.. "\n")
- a:write ("z = ".. z.. "\n")
- a:write ("xvoz = ".. xvoz.. "\n")
- a:write ("yvoz = ".. yvoz.. "\n")
- a:write ("zvoz = ".. zvoz.. "\n")
- a:write ("xdom = ".. xdom.. "\n")
- a:write ("ydom = ".. ydom.. "\n")
- a:write ("zdom = ".. zdom.. "\n")
- a:write ("xdla = ".. xdla.. "\n")
- a:write ("zdla = ".. zdla.. "\n")
- a:write ("ydla = ".. ydla.. "\n")
- a:write ("storona = ".. storona.. "\n")
- a:write ("rjad = ".. rjad.. "\n")
- a:write ("laer = ".. laer.. "\n")
- a:write ("ydl = ".. ydl.. "\n")
- a:close ()
- end
- function turn(a)
- if a - storona == 2 or a - storona == -2 then
- turtle.turnRight()
- turtle.turnRight()
- elseif a - storona == -1 or a - storona == 3 then
- turtle.turnLeft()
- elseif a - storona == 1 or a - storona == -3 then
- turtle.turnRight()
- elseif a - storona ~= 0 then
- print ("ERROR turn")
- return
- end
- storona = a
- savelocation()
- end
- function clearforward()
- while xdla > 1 do
- dig()
- if ydl > 1 then
- digup()
- if ydl > 2 then
- digdown()
- end
- end
- forward()
- xdla = xdla - 1
- if laer == 0 then
- if rjad == 0 then
- x = x + 1
- else
- x = x - 1
- end
- else
- if rjad == 0 then
- x = x - 1
- else
- x = x + 1
- end
- end
- savelocation()
- end
- if ydl > 1 then
- digup()
- if ydl > 2 then
- digdown()
- end
- end
- xdla = xdl
- end
- function clearlaer()
- if laer == 0 then
- while zdla > 1 do
- if rjad == 0 then
- turn(1)
- clearforward()
- turn(2)
- dig()
- turn(2)
- forward()
- rjad = 1
- zdla = zdla - 1
- z = z + 1
- savelocation()
- turn(3)
- else
- turn(3)
- clearforward()
- turn(2)
- dig()
- turn(2)
- forward()
- rjad = 0
- zdla = zdla - 1
- z = z + 1
- savelocation()
- turn(1)
- end
- end
- clearforward()
- if rjad == 0 then
- turn(3)
- else
- turn(1)
- end
- else
- while zdla > 1 do
- if rjad == 0 then
- turn(3)
- clearforward()
- turn(4)
- dig()
- turn(4)
- forward()
- rjad = 1
- zdla = zdla - 1
- z = z - 1
- savelocation()
- turn(1)
- else
- turn(1)
- clearforward()
- turn(4)
- dig()
- turn(4)
- forward()
- rjad = 0
- zdla = zdla - 1
- z = z - 1
- savelocation()
- turn(3)
- end
- end
- clearforward()
- if rjad == 0 then
- turn(1)
- else
- turn(3)
- end
- end
- end
- function dom()
- if laer == 1 then
- for i = 1, 3 do
- down()
- ydom = ydom + 1
- savelocation()
- end
- end
- turn(4)
- while zdom > 0 do
- forward()
- zdom = zdom - 1
- savelocation()
- end
- turn(3)
- while xdom > 0 do
- forward()
- xdom = xdom - 1
- savelocation()
- end
- if ydom > 0 then
- while ydom > 0 do
- up()
- ydom = ydom - 1
- savelocation()
- end
- elseif ydom < 0 then
- while ydom < 0 do
- down()
- ydom = ydom + 1
- savelocation()
- end
- end
- for i = 1, col do
- turtle.select(i)
- turtle.drop()
- end
- turtle.select(16)
- end
- function vozvrat()
- if yvoz > 0 then
- while yvoz > 0 do
- down()
- yvoz = yvoz - 1
- savelocation()
- end
- elseif yvoz < 0 then
- while yvoz < 0 do
- up()
- yvoz = yvoz + 1
- savelocation()
- end
- end
- if laer == 1 then
- while yvoz > -3 do
- down()
- yvoz = yvoz - 1
- savelocation()
- end
- end
- turn(1)
- while xvoz > 0 do
- forward()
- xvoz = xvoz - 1
- savelocation()
- end
- turn(2)
- while zvoz > 0 do
- forward()
- zvoz = zvoz - 1
- savelocation()
- end
- if laer == 0 then
- if rjad == 0 then
- turn(1)
- else
- turn(3)
- end
- else
- while yvoz < 0 do
- up()
- yvoz = yvoz + 1
- savelocation()
- end
- if rjad == 0 then
- turn(3)
- else
- turn(1)
- end
- end
- end
- function provback()
- local a = io.open (params, "r")
- local b = io.open (location, "r")
- if (io.open (params, "r") ~= nil) and (io.open (location, "r") ~= nil) then
- dofile (params)
- a:close()
- b:close()
- end
- if file == 1 then
- return true
- else
- return false
- end
- end
- function clearfile()
- local a = io.open (params, "w")
- local b = io.open (location, "w")
- a:close()
- b:close()
- end
- -- POL'ZOVATEL' VVODIT DANNYE
- if provback() == true then
- print ("est' sohranenija raboty. zhelaete vosstanovit'?")
- print ("0 - net")
- print ("1 - da")
- backup = tonumber (read())
- if backup < 0 or backup > 1 then
- print ("Nuzhno vybrat' 0 ili 1")
- return
- elseif backup == 1 then
- dofile (params)
- dofile (location)
- end
- end
- if backup == 0 then
- clearfile()
- print ("Vvedite skol'ko kopat' vniz")
- yd = tonumber(read())
- print ("Vvedite vysotu kopanija")
- ydl = tonumber(read())
- ydla = ydl
- if ydl < 1 then
- print ("Ne mozhet byt' men'he 1")
- return
- end
- print ("Vvedite skol'ko kopat' vpered")
- xdl = tonumber(read())
- xdla = xdl
- if xdl < 2 then
- print ("Ne mozhet byt' men'he 2")
- return
- end
- print ("Vvedite skol'ko kopat' vpravo")
- zdl = tonumber(read())
- zdla = zdl
- if zdl < 2 then
- print ("Ne mozhet byt' men'he 2")
- return
- end
- print ("Hotite uni4tozhat' cobblestone?")
- print ("0 - net")
- print ("1 - da")
- cobble = tonumber(read())
- if cobble < 0 or cobble > 1 then
- print ("Nuzhno vybrat' 0 ili 1")
- return
- end
- print ("Ubirat' isto4niki lavy i vody?")
- print ("0 - net (bystree)")
- print ("1 - da (4ishe)")
- isto4nik = tonumber(read())
- if isto4nik < 0 or isto4nik > 1 then
- print ("Nuzhno vybrat' 0 ili 1")
- return
- end
- print("Hotite dobavit' 2 bloka isklju4enija?")
- print ("0 - net ")
- print ("1 - da ")
- iskl = tonumber(read())
- if iskl < 0 or iskl > 1 then
- print ("Nuzhno vybrat' 0 ili 1")
- return
- end
- if iskl == 1 then
- col = 13
- else
- col = 15
- end
- file = 1
- saveparams()
- end
- if iskl == 1 then
- while turtle.getItemCount(15) < 1 or turtle.getItemCount(14) < 1 do
- print ("Polozhite bloki isklju4enija v 14 i 15 sloty")
- sleep(10)
- end
- end
- if cobble == 1 or isto4nik == 1 then
- while turtle.getItemCount(16) < 1 do
- print ("Polozhite cobblestone v samuj poslednij slot")
- sleep(10)
- end
- end
- -- MAIN
- if xdom ~= 0 or ydom ~= 0 or zdom ~= 0 then
- dom()
- end
- if xvoz ~= 0 or yvoz ~= 0 or zvoz ~= 0 then
- vozvrat()
- end
- while ydl > 0 do
- if ydl > 2 then
- if yd > y + 1 then
- while y < yd - 1 do
- down()
- y = y + 1
- savelocation()
- end
- end
- if yd < y + 1 then
- while y > yd - 1 do
- up()
- y = y - 1
- savelocation()
- end
- end
- else
- if yd > y + 1 then
- while y < yd do
- down()
- y = y + 1
- savelocation()
- end
- end
- if yd < y + 1 then
- while y > yd do
- up()
- y = y - 1
- savelocation()
- end
- end
- end
- clearlaer()
- zdla = zdl
- if ydl > 2 then
- ydl = ydl - 3
- yd = yd - 3
- else
- ydl = 0
- yd = 0
- end
- if ydl > 0 then
- if laer == 0 then
- laer = 1
- else
- laer = 0
- end
- end
- savelocation()
- end
- zdom = z
- ydom = y
- xdom = x
- savelocation()
- dom()
- clearfile()
- print ("*************************************")
- print ("* finish! *")
- print ("* nash kanal na youtube: *")
- print ("* www.youtube.com/user/ *")
- print ("* VladWinnerGamePortal *")
- print ("*************************************")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement