Skip to content

Commit

Permalink
Support userdata in doTeleportThing
Browse files Browse the repository at this point in the history
  • Loading branch information
marksamman committed Jan 27, 2014
1 parent bd039fb commit a42c783
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions data/compat.lua
Original file line number Diff line number Diff line change
Expand Up @@ -675,15 +675,23 @@ end
function queryTileAddThing(thing, position, ...) local t = Tile(position) return t ~= nil and t:queryAdd(thing, ...) or false end

function doTeleportThing(uid, dest, pushMovement)
if uid >= 0x10000000 then
local creature = Creature(uid)
if creature ~= nil then
return creature:teleportTo(dest, pushMovement or false)
if type(uid) == "userdata" then
if uid:isCreature() then
return uid:teleportTo(dest, pushMovement or false)
else
return uid:moveTo(dest)
end
else
local item = Item(uid)
if item ~= nil then
return item:moveTo(dest)
if uid >= 0x10000000 then
local creature = Creature(uid)
if creature ~= nil then
return creature:teleportTo(dest, pushMovement or false)
end
else
local item = Item(uid)
if item ~= nil then
return item:moveTo(dest)
end
end
end
return false
Expand Down

0 comments on commit a42c783

Please sign in to comment.