-- LUA Script - precede every function and global member with lowercase name of script + '_main' local U = require "scriptbank\\utillib" local rad = math.rad local lower = string.lower local rotatablesList = {} function manipulate_entity_init_name( e, name ) local Ent = g_Entity[ e ] rotatablesList[ e ] = { obj = Ent.obj, name = lower( name ), pos = { x = Ent.x, y = Ent.y, z = Ent.z }, ang = Ent.angley } end local lookingAt = nil local rotateSpeed = 1 local moveSpeed = 0.5 local function incAng( re ) re.ang = re.ang + 1 if re.ang > 360 then re.ang = re.ang - 360 end end local function decAng( re, limit ) re.ang = re.ang - 1 if re.ang < 0 then re.ang = re.ang + 360 end end local function moveLeft( re ) local _, _, _, xa, ya, za = GetObjectPosAng( re.obj ) local xo, _, zo = U.Rotate3D( -moveSpeed, 0, 0, rad( xa ), rad( ya ), rad( za ) ) re.pos.x = re.pos.x + xo re.pos.z = re.pos.z + zo end local function moveRight( re ) local _, _, _, xa, ya, za = GetObjectPosAng( re.obj ) local xo, _, zo = U.Rotate3D( moveSpeed, 0, 0, rad( xa ), rad( ya ), rad( za ) ) re.pos.x = re.pos.x + xo re.pos.z = re.pos.z + zo end function manipulate_entity_main( e ) local re = rotatablesList[ e ] if re == nil then return end CollisionOff( e ) PositionObject( re.obj, re.pos.x, re.pos.y, re.pos.z ) RotateObject( re.obj, 0, re.ang, 0 ) CollisionOn( e ) if lookingAt ~= nil and lookingAt ~= e then return end if U.PlayerLookingAtObj( re.obj, 300 ) then lookingAt = e PromptLocal( e, re.name ) if g_KeyPressE == 1 then if re.name == 'rotate' then incAng( re ) else moveLeft( re ) end elseif g_KeyPressR == 1 then if re.name == 'rotate' then decAng( re ) else moveRight( re ) end end else lookingAt = nil end end