Professional Documents
Culture Documents
Auto DF
Auto DF
Auto DF
LogToConsole("Started")
maxPlayerCount = 3 -- if u set this to 1 this script will not run for 10 seconds if
theres more than 1 person in the world. it will continue if conditions are met.
function punch(x, y)
pkt = {}
pkt.px = x;
pkt.py = y;
pkt.type = 3;
pkt.value = 18;
pkt.x = GetLocal().posX;
pkt.y = GetLocal().posY;
SendPacketRaw(false, pkt);
Sleep(180);
end
function getPlayerCount()
count = 0
for _, player in pairs(GetPlayerList()) do
count = count+1
end
return count
end
function getItemAmount(itemid)
for _, item in pairs(GetInventory()) do
if item.id == itemid then
return item.amount
end
end
return 0
end
function isItemToDrop()
count = 0
for i, drop in ipairs(droplist) do
dropID = FindItemID(drop)
if drop == "Rock" then
dropID = 10
end
if drop == "Rock Seed" then
dropID = 11
end
function isItemToTrash(amount)
count = 0
for i, trash in ipairs(trashlist) do
trashID = FindItemID(trash)
if trash == "Rock" then
trashID = 10
end
if trash == "Rock Seed" then
trashID = 11
end
function drop()
for i, drop in ipairs(droplist) do
dropID = FindItemID(drop)
if drop == "Rock" then
dropID = 10
end
if drop == "Rock Seed" then
dropID = 11
end
trashID = FindItemID(trash)
if trash == "Rock" then
trashID = 10
end
if trash == "Rock Seed" then
trashID = 11
end
function PathFindToObjUnobst()
for _, obj in pairs(GetObjectList()) do
if GetTiles(math.floor((obj.posX+10)/32),
math.floor((obj.posY+10)/32)).flag == 0 or GetTiles(math.floor((obj.posX+10)/32),
math.floor((obj.posY+10)/32)).flag == 2 then
FindPath(math.floor((obj.posX+10)/32),
math.floor((obj.posY+10)/32))
return true
end
end
return false
end
function getFloatingItemAmount(objID)
count = 0
for _, obj in pairs(GetObjectList()) do
if obj.itemid == objID then -- and GetTiles(math.floor(obj.posX/32),
math.floor(obj.posY/32)).flag == 0
count = count + obj.amount
end
end
return count
end
function getFloatingObjAmountUnobst()
count = 0
for _, obj in pairs(GetObjectList()) do
if GetTiles(math.floor((obj.posX+10)/32),
math.floor((obj.posY+10)/32)).flag == 0 or GetTiles(math.floor((obj.posX+10)/32),
math.floor((obj.posY+10)/32)).flag == 2 then
count = count + 1
end
end
return count
end
function getPlacedAmount(id)
count = 0
for _, tile in pairs(GetTiles()) do
if tile.fg == id then -- and GetTiles(math.floor(obj.posX/32),
math.floor(obj.posY/32)).flag == 0
count = count + 1
end
end
return count
end
function plant(seedID)
for _, tile in pairs(GetTiles()) do
if tile.y >= 23 then
if tile.fg == 0 and GetTiles(tile.x, tile.y+1).flag == 1 or
tile.fg == 0 and GetTiles(tile.x, tile.y+1).flag == 2 then
--if math.abs(tile.x - math.floor(GetLocal().posX/32)) <= 2
and math.abs(tile.y - math.floor(GetLocal().posY/32)) <= 2 then
if math.floor(GetLocal().posX/32) == tile.x and
math.floor(GetLocal().posY/32) == tile.y then
--if(GetTiles(math.floor(GetLocal().posX/32),
math.floor(GetLocal().posY/32)).fg == 0) then
if(GetTiles(math.floor(GetLocal().posX/32)+1,
math.floor(GetLocal().posY/32)).fg == 0) then
place(tile.x+1, tile.y, seedID)
end
place(tile.x, tile.y, seedID)
--end
else
if(math.floor(GetLocal().posX/32) == tile.x-1 and
math.floor(GetLocal().posY/32) == tile.y) then
FindPath(tile.x, tile.y)
Sleep(50)
else
FindPath(tile.x, tile.y)
Sleep(100)
end
end
return true
end
end
end
return false
end
function harvest(seedID)
for _, tile in pairs(GetTiles()) do
if tile.y >= 23 then
if(tile.fg == seedID and tile.readyharvest == 1) then
--if math.abs(tile.x - math.floor(GetLocal().posX/32)) <= 2
and math.abs(tile.y - math.floor(GetLocal().posY/32)) <= 2 then
if math.floor(GetLocal().posX/32) == tile.x and
math.floor(GetLocal().posY/32) == tile.y then
if(GetTiles(math.floor(GetLocal().posX/32)+1,
math.floor(GetLocal().posY/32)).fg == seedID) then
punch(tile.x+1, tile.y)
end
punch(tile.x, tile.y)
--end
else
if(math.floor(GetLocal().posX/32) == tile.x-1 and
math.floor(GetLocal().posY/32) == tile.y) then
FindPath(tile.x, tile.y)
Sleep(50)
else
FindPath(tile.x, tile.y)
Sleep(100)
end
end
return true
end
end
end
return false
end
function hasHarvestableTrees(seedID)
for _, tile in pairs(GetTiles()) do
if (tile.fg == seedID and tile.readyharvest == 1) then
return true
end
end
return false
end
function canEndDirtRows()
for _, tile in pairs(GetTiles()) do
if (tile.x == 97 and tile.y == 22 and tile.fg ~= 0) then
return true
end
end
return false
end
----------------------------------------------------------------
function clearLeft()
for _, tile in pairs(GetTiles()) do
if(tile.x>=0 and tile.x<=1 and tile.y<54 and tile.flag == 1)then -- 2
columns to the left
return true
end
end
return false
end
----------------------------------------------------------------
function dirtFarm()
botname = "133pkmd10"
SendPacket(2, "action|input\n|text|/pull 133pkmd10") Sleep(200)
for _, tile in pairs(GetTiles()) do
if(tile.y<54 and tile.x>=2 and tile.x<=97 and tile.bg == 14 and
GetTiles(tile.x, tile.y+1).bg == 14) then
if math.abs(tile.x - math.floor(GetLocal().posX/32)) <= 2 and
math.abs((tile.y-1) - math.floor(GetLocal().posY/32)) <= 2 then
--if math.floor(GetLocal().posX/32) == tile.x and
math.floor(GetLocal().posY/32) == tile.y-1 then
punch(tile.x, tile.y+1) --punch cave
else
FindPath(tile.x, tile.y-1)
Sleep(50)
end
return true
end
end
return false
end
----------------------------------------------------------------
function breakLava()
for _, tile in pairs(GetTiles()) do
if(tile.fg == 4)then
if math.floor(GetLocal().posX/32) == tile.x+1 and
math.floor(GetLocal().posY/32) == tile.y-1 then
punch(tile.x, tile.y) --punch lava
else
FindPath(tile.x+1, tile.y-1)
Sleep(100)
end
return true
elseif tile.y>44 and tile.x>=1 and tile.x<=97 then
if (tile.flag == 1 and GetTiles(tile.x+1, tile.y).fg == 0) or
(tile.flag == 2 and GetTiles(tile.x+1, tile.y).fg == 0) then
if math.floor(GetLocal().posX/32) == tile.x+2 and
math.floor(GetLocal().posY/32) == tile.y-1 then
place(tile.x+1, tile.y, dirtID)
else
FindPath(tile.x+2, tile.y-1)
Sleep(100)
end
return true
end
end
end
return false
end
----------------------------------------------------------------
function placeDirtRows()
for _, tile in pairs(GetTiles()) do
if tile.x>=1 and tile.x<=97 then
if (tile.flag == 1 and GetTiles(tile.x+1, tile.y).fg == 0) or
(tile.flag == 2 and GetTiles(tile.x+1, tile.y).fg == 0) then
if math.floor(GetLocal().posX/32) == tile.x and
math.floor(GetLocal().posY/32) == tile.y-1 then
place(tile.x+2, tile.y, dirtID)--added this for
antibug kinda
place(tile.x+1, tile.y, dirtID)
Sleep(placeDirtRowsDelay)
else
FindPath(tile.x, tile.y-1)
Sleep(100)
end
return true
end
end
end
return false
end
----------------------------------------------------------------
--**************************************************************
--RUN HERE
function main()
LogToConsole("Clearing Left Side")
runClearLeft = true
while runClearLeft == true do
if getPlayerCount() <= maxPlayerCount then
if clearLeft() == false then
runClearLeft = false
end
else
SendPacket(2, "action|respawn")
Sleep(5000)
while getPlayerCount() > maxPlayerCount do
Sleep(10000)
end
end
end
LogToConsole("Cleared Left Side")
--**************************************************************
LogToConsole("Placing Platforms Left Side")
if getItemAmount(platformID) >= 26 then
runPlacePlatformsLeft = true
else
runPlacePlatformsLeft = false
end
while runPlacePlatformsLeft == true do
if getPlayerCount() <= maxPlayerCount then
if placePlatformsLeft() == false then
runPlacePlatformsLeft = false
end
else
SendPacket(2, "action|respawn")
Sleep(5000)
while getPlayerCount() > maxPlayerCount do
Sleep(10000)
end
end
end
LogToConsole("Placed Platforms Left Side")
--**************************************************************
LogToConsole("Clearing Right Side")
runClearRight = true
while runClearRight == true do
if getPlayerCount() <= maxPlayerCount then
if clearRight() == false then
runClearRight = false
end
else
SendPacket(2, "action|respawn")
Sleep(5000)
while getPlayerCount() > maxPlayerCount do
Sleep(10000)
end
end
end
LogToConsole("Cleared Right Side")
--**************************************************************
LogToConsole("Placing Platforms Right Side")
if getItemAmount(platformID) >= 26 then
runPlacePlatformsRight = true
else
runPlacePlatformsRight = false
end
while runPlacePlatformsRight == true do
if getPlayerCount() <= maxPlayerCount then
if placePlatformsRight() == false then
runPlacePlatformsRight = false
end
else
SendPacket(2, "action|respawn")
Sleep(5000)
while getPlayerCount() > maxPlayerCount do
Sleep(10000)
end
end
end
LogToConsole("Placed Platforms Right Side")
--**************************************************************
LogToConsole("Dirt Farm Start")
botname = "killertY"
SendPacket(2, "action|input\n|text|/pull "..botname)
runDirtFarm = true
while runDirtFarm == true do
if getPlayerCount() <= maxPlayerCount then
if dirtFarm() == false then
runDirtFarm = false
end
if isItemToDrop()>0 then
Sleep(500)
FindPath(97, math.floor(GetLocal().posY/32))
Sleep(2000)
drop()
Sleep(2000)
end
else
SendPacket(2, "action|respawn")
Sleep(5000)
while getPlayerCount() > maxPlayerCount do
Sleep(1000)
end
end
end
LogToConsole("Dirt Farm Done")
--**************************************************************
LogToConsole("Replacing Lava with Dirt")
runBreakLava = true
while runBreakLava == true do
if getPlayerCount() <= maxPlayerCount then
if breakLava() == false then
runBreakLava = false
end
if getItemAmount(FindItemID("Lava")) == 200 or
getItemAmount(FindItemID("Lava See")) == 200 then
FindPath(98, math.floor(GetLocal().posY/32))
Sleep(2000)
----------------------
SendPacket(2, "action|drop\n|itemID|"..FindItemID("Lava"))
Sleep(1000)
--SendPacket(2, "action|dialog_return\ndialog_name|
drop_item\nitemID|"..FindItemID(drop).."|\
ncount|"..getItemAmount(FindItemID(drop)))
Sleep(1000)
LogToConsole("Dropped Lava")
----------------------
SendPacket(2, "action|drop\n|itemID|"..FindItemID("Lava
Seed"))
Sleep(1000)
--SendPacket(2, "action|dialog_return\ndialog_name|
drop_item\nitemID|"..FindItemID(drop).."|\
ncount|"..getItemAmount(FindItemID(drop)))
Sleep(1000)
LogToConsole("Dropped Lava Seed")
----------------------
--Sleep(2000)
end
else
SendPacket(2, "action|respawn")
Sleep(5000)
while getPlayerCount() > maxPlayerCount do
Sleep(10000)
end
end
end
LogToConsole("Replacing Lava Ended")
--**************************************************************
if getPlacedAmount(platformID) >= 52 then
runBlocks = true
LogToConsole("Gather Blocks")
else
runBlocks = false
LogToConsole("Dont Have Plats Cant Run: Gather Blocks")
end
-------------------------
LogToConsole("Total Dirt: "..getFloatingItemAmount(dirtID) +
getItemAmount(dirtID))
Sleep(200)
if getFloatingItemAmount(dirtID) + getItemAmount(dirtID) <= 1056
and canEndDirtRows() == false then
PathFindToObj(dirtSeedID, 1)
Sleep(2000)
if getItemAmount(dirtSeedID) == 0 and
getFloatingItemAmount(dirtSeedID) > 0 then
LogToConsole("PathFinding to Dirt Seed")
while (getItemAmount(dirtSeedID) < 200 and
getFloatingItemAmount(dirtSeedID) > 0 ) and getPlayerCount() <= maxPlayerCount do
PathFindToObj(dirtSeedID, 1)
Sleep(1000)
end
end
else
runBlocks = false
end
-------------------------
else
SendPacket(2, "action|respawn")
Sleep(5000)
while getPlayerCount() > maxPlayerCount do
Sleep(10000)
end
end
end
LogToConsole("Gather Blocks Ended")
--**************************************************************
if getPlacedAmount(platformID) >= 52 then
runPlaceDirtRows = true
LogToConsole("Make Dirt Rows")
else
runPlaceDirtRows = false
LogToConsole("Dont Have Plats Cant Run: Make Dirt Rows")
end
else
SendPacket(2, "action|respawn")
Sleep(5000)
while getPlayerCount() > maxPlayerCount do
Sleep(10000)
end
end
end
LogToConsole("Make Dirt Rows Ended")
--**************************************************************
if getPlacedAmount(platformID) >= 52 then
runTrash = true
LogToConsole("Trash Blocks")
else
runTrash = false
LogToConsole("Dont Have Plats Cant Run: Trash Blocks")
end
PathFindToObjUnobst()
if isItemToTrash(200)>0 then
trash(200)
end
else
runTrash = false
end
else
SendPacket(2, "action|respawn")
Sleep(5000)
while getPlayerCount() > maxPlayerCount do
Sleep(10000)
end
end
end
--trash(1) --uncomment this if u dont want to trash all the trashable items
in the inventory
LogToConsole("Trash Blocks Ended")
SendPacket(2, "action|respawn")
Sleep(2000)
LogToConsole("Script Ended")
--[[
-- get index
for i, world in ipairs(worlds) do
if world == currentWorld then
currentindex = i
end
Sleep(200)
end
LogToConsole("CurrentWorldIndex: "..currentindex)
LogToConsole("CurrentWorldValue: "..worlds[currentindex])
-- get last element in worlds array
for i,v in pairs(worlds) do
lastWorldIndex = #worlds - 0
Sleep(200)
end
LogToConsole("Last Index In Array: "..lastWorldIndex)
LogToConsole("Last Index In Array: "..worlds[lastWorldIndex])