Hello.
I think this code will work.
This code will check if there's a monster "Rat" on Location_FROM X/Y/Z and try to move it to Location_TO X/Y/Z. If there's any item under the monster, it will try to move the items as well.
However, it will NOT check if it's possible to move to Location_TO X/Y/Z, for example, it will not check if there's a field or parcel that would make it impossible to move to.
local SETTINGS = {
Monster = 'Rat',
Location_FROM = { X = 32346, Y = 32217, Z = 7 },
Location_TO = { X = 32345, Y = 32217, Z = 7 },
}
SETTINGS.Monster = SETTINGS.Monster:lower()
local creatures = getcreatures('mfs')
for _, creature in ipairs(creatures) do
if creature.name:lower() == SETTINGS.Monster and creature.posx == SETTINGS.Location_FROM.X and creature.posy == SETTINGS.Location_FROM.Y and creature.posz == SETTINGS.Location_FROM.Z then
local monster = creature
while monster.posx == SETTINGS.Location_FROM.X and monster.posy == SETTINGS.Location_FROM.Y and monster.posz == SETTINGS.Location_FROM.Z do
local tile = gettile(SETTINGS.Location_FROM.X, SETTINGS.Location_FROM.Y, SETTINGS.Location_FROM.Z)
if tile.hascreature and tile.itemcount > 1 then
moveitems(tile.topitem.id, ground(SETTINGS.Location_TO.X, SETTINGS.Location_TO.Y, SETTINGS.Location_TO.Z), ground(SETTINGS.Location_FROM.X, SETTINGS.Location_FROM.Y, SETTINGS.Location_FROM.Z), 100)
wait(1000)
else
break
end
monster = getcreature(creature.id)
end
end
end
This script works pretty much like the above, but it will move any creature (monster/player) that's on the specific sqm.
local SETTINGS = {
Location_FROM = { X = 32346, Y = 32217, Z = 7 },
Location_TO = { X = 32345, Y = 32217, Z = 7 },
}
SETTINGS.Monster = SETTINGS.Monster:lower()
local creatures = getcreatures('pmfs')
for _, creature in ipairs(creatures) do
if creature.posx == SETTINGS.Location_FROM.X and creature.posy == SETTINGS.Location_FROM.Y and creature.posz == SETTINGS.Location_FROM.Z then
local monster = creature
while monster.posx == SETTINGS.Location_FROM.X and monster.posy == SETTINGS.Location_FROM.Y and monster.posz == SETTINGS.Location_FROM.Z do
local tile = gettile(SETTINGS.Location_FROM.X, SETTINGS.Location_FROM.Y, SETTINGS.Location_FROM.Z)
if tile.hascreature and tile.itemcount > 1 then
moveitems(tile.topitem.id, ground(SETTINGS.Location_TO.X, SETTINGS.Location_TO.Y, SETTINGS.Location_TO.Z), ground(SETTINGS.Location_FROM.X, SETTINGS.Location_FROM.Y, SETTINGS.Location_FROM.Z), 100)
wait(1000)
else
break
end
monster = getcreature(creature.id)
end
end
end