Yes, you can work with the id of an entity, I've tried it with success in the first competition.
All credits go to smallg, I just limited myself to change some things for suit my needs.
-- Allows the player to pick-up the item (teapot - 194), carry it and then drop - floor grate - 259
-- Note - entity with this script must have Physics > No & Static Mode > No
local i_state = {}
local itemdist = 100
local yangle = 0
local tCheckTime = {}
function carryteapot_init(e)
i_state[e] = "start"
end
function carryteapot_main(e)
if i_state[e] == "start" then
tCheckTime[e] = GetTimer(e)
i_state[e] = "initial"
end
--Prompt (g_Entity[220]['x'],g_Entity[220]['y'],g_Entity[220]['z'],g_Entity[e]['x'],g_Entity[e]['y'],g_Entity[e]['z'] )
PlayerDX = g_Entity[e]['x'] - g_PlayerPosX;
PlayerDY = g_Entity[e]['y'] - g_PlayerPosY;
PlayerDZ = g_Entity[e]['z'] - g_PlayerPosZ;
PlayerDist = math.sqrt(math.abs(PlayerDX^2)+math.abs(PlayerDY^2)+math.abs(PlayerDZ^2));
if PlayerDist < 100 then
if i_state[e] == "initial" and GetTimer(e) > tCheckTime[e] + 500 then
Prompt ("Press E To Pick Up teapot. You need to find a right side, to place this")
if g_KeyPressE == 1 then
GravityOff(e)
CollisionOff(e)
Show (e)
yangle=g_PlayerAngY
i_state[e] = "carried"
PlaySound(e,0)
ActivateIfUsed(e)
tCheckTime[e] = GetTimer(e)
end
end
end -- end if player dist
if i_state[e] == "carried" then
--calculate and then hold the item 'itemdist' in front of player
itemx=g_PlayerPosX
itemz=g_PlayerPosZ
itemy=g_PlayerPosY
itemx = itemx+math.sin(math.rad(g_PlayerAngY))*itemdist
itemz = itemz+math.cos(math.rad(g_PlayerAngY))*itemdist
itemy = itemy-math.sin(math.rad(g_PlayerAngX))*itemdist
-- hide if view angle drops underground or too high - adjust as needed
if g_PlayerAngX > -50 and g_PlayerAngX < 25 then
Show(e)
else
Hide(e)
end
SetPosition(e,itemx,itemy-15,itemz)
-- mirror precisely the player Y angle for the items rotation to player
yangle = g_PlayerAngY
if g_PlayerAngY >= 360 then
yangle = g_PlayerAngY - (360 * (math.floor(g_PlayerAngY / 360)))
elseif g_PlayerAngY < 0 and g_PlayerAngY > -360 then
yangle = g_PlayerAngY + 360
elseif g_PlayerAngY 360 then
FaceAngle = FaceAngle - 360
end
--adjust the '-20' to tilt the item further away/towards the player whilst being carried (set to 0 for flat)
SetRotation(e,(g_PlayerAngX-10 * -1),FaceAngle,0)
--SetRotation(e,0,FaceAngle,0)
--check if player wants to drop item and if so drop
Prompt ("Press E To Drop teapot, if does not, is because this is not the right side, to place it")
if g_KeyPressE == 1 and GetTimer(e) > tCheckTime[e] + 500 then
SetRotation(e,0,FaceAngle,0)
GravityOn(e)
CollisionOn(e)
floorgratex = g_Entity[199]['x']
floorgratey = g_Entity[199]['y']
floorgratez = g_Entity[199]['z']
if floorgratex
Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz
OS: Windows 8.1 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics