local a=[[
]]

a="--//   bot = getBot()world = getBot():getWorld()
inventory = getBot():getInventory()

function AnlikYer()
    Dunyadami = tostring(world.name)
    if Dunyadami ~= "" and Dunyadami ~= "EXIT" then
        localbot = world:getLocal()
        if localbot then
            Botx = math.floor(localbot.posx / 32) 
            Boty = math.floor(localbot.posy / 32)
        end
    end
end

function floats(idz)
    float = 0
    for i, obj in pairs(world:getObjects()) do
        if obj.id == idz then 
            float = float + obj.count
        end
    end
    return {ucanlar = float}
end

function join(a,b) 
    sleep(DELAY_JOIN)
    bot:warp(a,b)
    sleep(DELAY_JOIN)
    AnlikYer()
    Dunyadami = tostring(world.name)
    if Dunyadami ~= "" and Dunyadami ~= "EXIT" then
        if world:getTile(Botx,Boty).fg == 6 then
            join(a,b)
        end
    end
end

function takeP()
    for _, obj in pairs(world:getObjects()) do
      if obj.id == 98 then
        xp = math.floor(obj.x / 32)
        yp = math.floor(obj.y / 32)
        bot:findPath(xp,yp)
        sleep(1000)
        bot.auto_collect = true
        bot.collect_range = 1 
        sleep(500)
        bot.auto_collect = false
        if inventory:getItemCount(98) > 0 then
          break
        end
      end
    end
end

function dropPick()
    bot:sendPacket(2, "action|drop\n|itemID|" .. 98)
    bot:sendPacket(2, "action|dialog_return\ndialog_name|drop_item\nitemID|" .. 98 .. "|\ncount|" .. inventory:getItemCount(98) - 1)
    sleep(1000)
end

function cekpik()
    if Pick and inventory:getItemCount(98) > 1 then
        join(WORLD_PICKAXE,ID_WORLD_PICKAXE)
        dropPick()
        sleep(1000)
    end
end

function PickaxeControl()
    if USE_PICK and inventory:getItemCount(98) == 0 then
        join(WORLD_PICKAXE,ID_WORLD_PICKAXE)
        sleep(500)
        takeP()
        sleep(3000)
        if inventory:getItemCount(98) > 0 then
            bot:wear(98)
            sleep(2000)
            dropPick()
            sleep(1000)
            if inventory:getItemCount(98) > 1 then
                join(WORLD_PICKAXE,ID_WORLD_PICKAXE)
                dropPick()
                sleep(1000)
                cekpik()
            end
        else
            while inventory:getItemCount(98) == 0 do
                sleep(5000)
                join(WORLD_PICKAXE,ID_WORLD_PICKAXE)
                sleep(500)
                takeP()
                sleep(3000)
                if inventory:getItemCount(98) > 0 then
                    bot:wear(98)
                    sleep(2000)
                    dropPick()
                    sleep(1000)
                    if inventory:getItemCount(98) > 1 then
                        join(WORLD_PICKAXE,ID_WORLD_PICKAXE)
                        dropPick()
                        sleep(1000)
                        cekpik()
                    end
                end
            end
        end
    end
    if inventory:getItemCount(98) > 1 then
        join(WORLD_PICKAXE,ID_WORLD_PICKAXE)
        dropPick()
        sleep(1000)
    end
end
PickaxeControl()

function take() 
    ReconnectTakeBlock()
    for _,obj in pairs(world:getObjects()) do
      if obj.id == BLOCKID then 
            ReconnectTakeBlock()
            AnlikYer()
            if world:getTile(Botx,Boty).fg == 6 then
                join(WORLD_BLOCK,WORLD_BLOCKid)
            end
            local x = math.floor(obj.x / 32)
            local y = math.floor(obj.y / 32)
            bot:findPath(x,y)
            bot.auto_collect = true
            sleep(1000) 
        end
        if inventory:getItemCount(BLOCKID) > 1 then
            bot.auto_collect = false
            break
        end
    end
end
itemler = 0
function tarama()
    itemler = 0
    for _, obj in pairs(world:getObjects()) do
        if obj.id == BLOCKID then 
            itemler = itemler + obj.count
        end
    end
    return itemler
end

function TrashTheJunks()
    for i, trash in ipairs(TRASH_LIST) do
        if inventory:getItemCount(trash) > TRASH_COUNT then
          	bot:trash(trash, inventory:getItemCount(trash))
            sleep(1000)
        end
    end
end

function OnlineControl()
    if bot.status ~= 1 then
        while bot.status ~= 1 do
            bot:connect()
            sleep(10000)
        end
    end
end

function tilealfg(x,y)
    OnlineControl()
    AnlikYer()
    Dunyadami = tostring(world.name)
    if Dunyadami ~= "" and Dunyadami ~= "EXIT" then
        tilefgx = world:getTile(x,y).fg
        return {tilefg = tilefgx}
    end
end

function tilealbg(x,y)
    OnlineControl()
    AnlikYer()
    Dunyadami = tostring(world.name)
    if Dunyadami ~= "" and Dunyadami ~= "EXIT" then
        tilebgx = world:getTile(x,y).bg
        return {tilebg = tilebgx}
    end
end

function pnbatas()
    if MODE_PNB == "UP" or MODE_PNB == "MULTI" then
        if (tilealfg(Botx,Boty-2).tilefg ~= 0 or tilealbg(Botx,Boty-2).tilebg ~= 0) then
            Reconnect()
            AnlikYer()
            bot:hit(Botx,Boty-2) 
            sleep(DELAY_BREAK)
        elseif tilealfg(Botx,Boty-2).tilefg == 0 then
		    AnlikYer()
            bot:place(Botx,Boty-2,BLOCKID)
            sleep(DELAY_PUT)
        end
    end
end

function pnbbawah()
    if MODE_PNB == "DOWN" or MODE_PNB == "MULTI" then
        if (tilealfg(Botx,Boty+2).tilefg ~= 0 or tilealbg(Botx,Boty+2).tilebg ~= 0) then
            Reconnect()
            AnlikYer()
            bot:hit(Botx,Boty+2) 
            sleep(DELAY_BREAK)
        elseif tilealfg(Botx,Boty+2).tilefg == 0 then
		    AnlikYer()
            bot:place(Botx,Boty+2,BLOCKID)
            sleep(DELAY_PUT)
        end
    end
end

local originalPositions = {}

function GoToSpot()
    local offsetX = RANGE_BETWEEN_BOTS
    local botList = getBot():getWorld():getPlayers()
    local botName = getBot().name
    local botIndex = nil
    for index, bot in ipairs(botList) do
        if bot.name == botName then
            botIndex = index
            break
        end
    end
    if botIndex then
        checker()
        if getBot():isInWorld(string.upper(WORLD_BREAK)) then
            local storedPosition = originalPositions[botName]
            local destinationX, destinationY
            if storedPosition then
                destinationX = storedPosition.x
                destinationY = storedPosition.y
            else
                for _, tile in pairs(getBot():getWorld():getTiles()) do
                    if tile.fg == PATOKAN or tile.bg == PATOKAN then
                        destinationX = tile.x + offsetX * (botIndex - 1)
                        destinationY = tile.y
                        break
                    end
                end
                originalPositions[botName] = { x = destinationX, y = destinationY }
            end
            sleep(500)
            getBot():findPath(destinationX, destinationY)
            sleep(400)
        end
    end
end

function checker()
    for _, tile in pairs(getBot():getWorld():getTiles()) do
        if tile.bg == 6 or tile.fg == 6 then
            if getBot():isInTile(tile.x, tile.y) then
                sleep(1000)
                join(WORLD_BREAK,ID_WORLD_BREAK)
                sleep(2000)
                break
            end
        end
    end
end

function PNB()
    if not USE_GAUT then
        bot.auto_collect = true
        bot.collect_range = 5
    else
        bot.auto_collect = false
    end
    if world.name ~= WORLD_BREAK then
        join(WORLD_BREAK,ID_WORLD_BREAK)
    end
    if LEGIT_MODE then
        bot.legit_mode = true
    elseif not LEGIT_MODE then
        bot.legit_mode = false
    end
    AnlikYer()
    GoToSpot()
    if CHANGE_COLOR then
	    bot:setSkin(math.random(1, 6))
    end
    while inventory:getItemCount(BLOCKID) > 0 do
        Reconnect()
        if MODE_PNB == "UP" then 
            pnbatas()
        elseif MODE_PNB == "DOWN" then 
            pnbbawah()
        elseif MODE_PNB == "MULTI" then
            pnbatas()
            pnbbawah()
        end
    end
    Reconnect()
    if inventory:getItemCount(BLOCKID) == 0 and USE_GAUT and RETRIEVE_GAUT then 
        Reconnect()
        for _, titid in pairs(world:getTiles()) do
            if titid.fg == 6946 then
            Reconnect()
            bot:findPath(titid.x, titid.y - 1)
            sleep(1000)
        end
    end
    AnlikYer()
    bot:wrench(Botx,Boty+1)
    sleep(1000)
    bot:retrieve(Botx,Boty+1)
    sleep(4000)
    for _, kisik in pairs(world:getTiles()) do
        if kisik.fg == 6948 then
            Reconnect()
            bot:findPath(kisik.x, kisik.y - 1)
            sleep(500)
        end
    end
    AnlikYer()
    bot:wrench(Botx,Boty+1)
    sleep(1000)
    bot:retrieve(Botx,Boty+1)
    sleep(4000)
    end
end

function DropF()
    bot.auto_collect = false
    while not USE_GAUT and bot.gem_count > PRICE_PACK and BUY_PACK do
        Reconnectpkt()
        bot:sendPacket(2, "action|buy\nitem|"..NAME_PACK)
        sleep(3000) -- you can change delay
    end
    if inventory:getItemCount(SEEDID) > 0 then
        join(WORLD_SEED,ID_WORLD_SEED)
        Reconnect()
        while (inventory:getItemCount(SEEDID) > 0) do
            if world.name ~= WORLD_SEED then
                join(WORLD_SEED,ID_WORLD_SEED)
            end
            Reconnect()
            AnlikYer()
            for _, tile in pairs(world:getTiles()) do 
                if tile.fg == PATOKAN_SEED or tile.bg == PATOKAN_SEED and USE_PATOKAN_SEED then 
                    bot:findPath(tile.x-1, tile.y)
                    sleep(1000)
                    bot:setDirection(false)
                    sleep(100)
                    bot:drop(SEEDID,inventory:getItemCount(SEEDID))
                    sleep(500)
                    while (inventory:getItemCount(SEEDID) > 0) do
                        bot:moveRight()
                        sleep(500)
                        bot:drop(SEEDID,inventory:getItemCount(SeedID))
                        sleep(500)
                    end
                elseif not USE_PATOKAN_SEED then
                    while (inventory:getItemCount(SEEDID) > 0) do
                        bot:moveRight()
                        sleep(500)
                        bot:drop(SEEDID,inventory:getItemCount(SEEDID))
                        sleep(500)
                    end
                end
            end
        end  
    end
    for _, PACKID in pairs(ID_PACK) do
        if getBot():getInventory():getItemCount(PACKID) > DROP_COUNT then
            join(WORLD_PACK,ID_WORLD_PACK)
            Reconnect()
            while inventory:getItemCount(PACKID) > DROP_COUNT do
                 if world.name ~= WORLD_PACK then
                    join(WORLD_PACK,ID_WORLD_PACK)
                end
                Reconnect()
                AnlikYer()
                for _, tile in pairs(world:getTiles()) do 
                    if tile.fg == PATOKAN_PACK or tile.bg == PATOKAN_PACK and USE_PATOKAN_PACK then 
                        bot:findPath(tile.x-1, tile.y)
                        sleep(1000)
                        bot:setDirection(false)
                        sleep(100)
                        bot:drop(PACKID,inventory:getItemCount(PACKID))
                        sleep(500)
                        while (inventory:getItemCount(PACKID) > DROP_COUNT) do
                            bot:moveRight()
                            sleep(500)
                            bot:drop(PACKID,inventory:getItemCount(PACKID))
                            sleep(500)
                        end
                    elseif not USE_PATOKAN_PACK then
                        while (inventory:getItemCount(PACKID) > DROP_COUNT) do
                            bot:moveRight()
                            sleep(500)
                            bot:drop(PACKID,inventory:getItemCount(PACKID))
                            sleep(500)
                        end
                    end
                end
            end
        end
    end
end

function Reconnectpkt()
    if bot.status ~= 1 then       
        while bot.status ~= 1 do
            bot:connect()
            sleep(10000)
        end
        join(WORLD_BREAK,ID_WORLD_BREAK)
    end
end

function ReconnectTakeBlock()
    if bot.status ~= 1 then
        while bot.status ~= 1 do
            bot:connect()
            sleep(10000)
        end
        join(WORLD_BLOCK,ID_WORLD_BLOCK)
    end
    Dunyadami = tostring(world.name)
    if Dunyadami ~= "" and Dunyadami ~= "EXIT" then
        AnlikYer()
        if world:getTile(Botx,Boty).fg == 6 then
            join(WORLD_BLOCK,ID_WORLD_BLOCK)
        end
    end
end

function Reconnect()
    if bot.status ~= 1 then 
        while bot.status ~= 1 do
            bot:connect()
            sleep(10000)
        end
        join(WORLD_BREAK,ID_WORLD_BREAK)
    end
    Dunyadami = tostring(world.name)
    if Dunyadami ~= "" and Dunyadami ~= "EXIT" then
        AnlikYer()
        if world:getTile(Botx,Boty).fg == 6 then
            join(ID_WORLD_BREAK,ID_WORLD_BREAK)
        end
    end
end

isOwner = true

while isOwner == true do 
    Reconnect()
    DropF()
    for i, list in ipairs(WORLD_BLOCK) do
        list = string.upper(list)
        if inventory:getItemCount(BLOCKID) == 0 then
            join(list,ID_WORLD_BLOCK)
            take()
            tarama()
        elseif itemler < 1 and inventory:getItemCount(BLOCKID) == 0 then
            join(list,ID_WORLD_BLOCK)
            take()
            tarama()
        end
    end
    if inventory:getItemCount(BLOCKID) > 0 then
        join(WORLD_BREAK,ID_WORLD_BREAK)
        PNB()
    end
    DropF()
    TrashTheJunks()
end \n"..a;function Obfuscate(b)local c="function IllIlllIllIlllIlllIlllIll(IllIlllIllIllIll) if (IllIlllIllIllIll==(((((919 + 636)-636)*3147)/3147)+919)) then return not true end if (IllIlllIllIllIll==(((((968 + 670)-670)*3315)/3315)+968)) then return not false end end; "local d=c;local e=""local f={"IllIllIllIllI","IIlllIIlllIIlllIIlllII","IIllllIIllll"}local g=[[local IlIlIlIlIlIlIlIlII = {]]local h=[[local IllIIllIIllIII = loadstring]]local i=[[local IllIIIllIIIIllI = table.concat]]local j=[[local IIIIIIIIllllllllIIIIIIII = "''"]]local k="local "..f[math.random(1,#f)].." = (7*3-9/9+3*2/0+3*3);"local l="local "..f[math.random(1,#f)].." = (3*4-7/7+6*4/3+9*9);"local m="--// Obfuscated with LuaSeel 1.1 \n\n"for n=1,string.len(b)do e=e.."'\\"..string.byte(b,n).."',"end;local o="function IllIIIIllIIIIIl("..f[math.random(1,#f)]..")"local p="function "..f[math.random(1,#f)].."("..f[math.random(1,#f)]..")"local q="local "..f[math.random(1,#f)].." = (5*3-2/8+9*2/9+8*3)"local r="end"local s="IllIIIIllIIIIIl(900283)"local t="function IllIlllIllIlllIlllIlllIllIlllIIIlll("..f[math.random(1,#f)]..")"local q="function "..f[math.random(1,#f)].."("..f[math.random(1,#f)]..")"local u="local "..f[math.random(1,#f)].." = (9*0-7/5+3*1/3+8*2)"local v="end"local w="IllIlllIllIlllIlllIlllIllIlllIIIlll(9083)"local x=m..d..k..l..i..";"..o.." "..p.." "..q.." "..r.." "..r.." "..r..";"..s..";"..t.." "..q.." "..u.." "..v.." "..v..";"..w..";"..h..";"..g..e.."}".."IllIIllIIllIII(IllIIIllIIIIllI(IlIlIlIlIlIlIlIlII,IIIIIIIIllllllllIIIIIIII))()"print(x)end;do Obfuscate(a)end 
by

Lua online compiler

Write, Run & Share Lua code online using OneCompiler's Lua online compiler for free. It's one of the robust, feature-rich online compilers for Lua language, running the latest Lua version 5.4. Getting started with the OneCompiler's Lua editor is easy and fast. The editor shows sample boilerplate code when you choose language as Lua and start coding.

Taking inputs (stdin)

OneCompiler's Lua online editor supports stdin and users can give inputs to programs using the STDIN textbox under the I/O tab. Following is a sample Lua program which takes name as input and prints hello message with your name.

name = io.read("*a")
print ("Hello ", name)

About Lua

Lua is a light weight embeddable scripting language which is built on top of C. It is used in almost all kind of applications like games, web applications, mobile applications, image processing etc. It's a very powerful, fast, easy to learn, open-source scripting language.

Syntax help

Variables

  • By default all the variables declared are global variables
  • If the variables are explicitly mentioned as local then they are local variables.
  • Lua is a dynamically typed language and hence only the values will have types not the variables.

Examples

-- global variables
a = 10

-- local variables

local x = 30
Value TypeDescription
numberRepresents numbers
stringRepresents text
nilDifferentiates values whether it has data or not
booleanValue can be either true or false
functionRepresents a sub-routine
userdataRepresents arbitary C data
threadRepresents independent threads of execution.
tableCan hold any value except nil

Loops

1. While:

While is also used to iterate a set of statements based on a condition. Usually while is preferred when number of iterations are not known in advance.

while(condition)
do
--code
end

2. Repeat-Until:

Repeat-Until is also used to iterate a set of statements based on a condition. It is very similar to Do-While, it is mostly used when you need to execute the statements atleast once.

repeat
   --code
until( condition )

3. For:

For loop is used to iterate a set of statements based on a condition.

for init,max/min value, increment
do
   --code
end

Functions

Function is a sub-routine which contains set of statements. Usually functions are written when multiple calls are required to same set of statements which increase re-usuability and modularity.

optional_function_scope function function_name( argument1, argument2, argument3........, argumentn)
--code
return params with comma seperated
end