• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua specific clean

zabuzo

Well-Known Member
Joined
Jun 10, 2016
Messages
238
Reaction score
54
There is a way to make a specifics clean?

1- For items id?

For example:
- Clean all the map but only clean items:
gold coin, worm, flasks, livro tutorial, leather, jacket, parcel, label

2- For X and Y
- Clean all items but only Island Of Peace
For example:
between X- 1000 Y-1000 to X-1500 Y- 1500
 
There is a way to make a specifics clean?

1- For items id?

For example:
- Clean all the map but only clean items:
gold coin, worm, flasks, livro tutorial, leather, jacket, parcel, label

2- For X and Y
- Clean all items but only Island Of Peace
For example:
between X- 1000 Y-1000 to X-1500 Y- 1500
I believe so, I think you can do this by querying the database.
 
My bad this can't be done through a query, you would have to create a function to iterate through the from (x,y,z) to the to (x,y,z) and check for x items.

It would have to be something like
Code:
function cleanArea(from, to)
    for x = from.x, to.x do
        for y = from.y, to.y do
            for z = from.z, to.z do
                print(x, y, z)
            end
        end
    end
end
Code:
cleanArea({x = 1, y = 1, z = 1}, {x = 2, y = 2, z = 2})
Code:
1    1    1
1    1    2
1    2    1
1    2    2
2    1    1
2    1    2
2    2    1
2    2    2
 
My bad this can't be done through a query, you would have to create a function to iterate through the from (x,y,z) to the to (x,y,z) and check for x items.

It would have to be something like
Code:
function cleanArea(from, to)
    for x = from.x, to.x do
        for y = from.y, to.y do
            for z = from.z, to.z do
                print(x, y, z)
            end
        end
    end
end
Code:
cleanArea({x = 1, y = 1, z = 1}, {x = 2, y = 2, z = 2})
Code:
1    1    1
1    1    2
1    2    1
1    2    2
2    1    1
2    1    2
2    2    1
2    2    2


I think this loop and prints will work, but what is the function to delete all items there?
Exemple
Code:
CleanItemsArea()
 
Oh ty, and im sorry to didnt see

Im editing right?
Code:
<globalevent name="specificClean" interval="7200000" event="script" value="specific_clean.lua"/>

Code:
function executeSpecificClean()
   cleanArea(491,727,7, 514,739,7) -- island of peace
   cleanArea(484,721,8, 515,746,8) -- island of peace (underground)
   -- clean all worms,gold coins...
   doBroadcastMessage("Game map cleaned, next clean in 2 hours.")
   return true
end

function onThink(interval)
   doBroadcastMessage("Island of Peace will clean AND All trashs too (GOLDs, WORMS...) in 30 seconds...")
   addEvent(executeSpecificClean, 30000)
   return true
end

function cleanArea(from, to)
  for x = from.x, to.x do
  for y = from.y, to.y do
  for z = from.z, to.z do
  print(x, y, z)
  end
  end
  end
end

And how to clean all trashes of map?
 
i bet compiled c++ program each loop will be handled about 10ms, i don't know about lua.
much much much faster.

Imagine a loop
PosX 0
PosY 0
to
PosX 2550
PosY 2550

And in all Z (1,2...15)...

I think is better wait to global save to restart and clean all ;)
As long as you wont want verify each loop or print it to console I don't think it will be problem.

Although I would reconsider handling this matter differently.
 
Back
Top