local propsrv = lgs.PropertySrv
local objsrv = lgs.ObjectSrv
local statement = 0
local RotateNeeded = 1

function Sim(msg)
	if msg.fStarting then
		if propsrv.Possessed(script.objid,'ScriptTiming') then
			RotateNeeded = propsrv.Get(script.objid,'ScriptTiming')
		end
	end
	return true
end

function TurnOn(msg)
	if propsrv.possessed(script.objid,'StTweqRotate') then
		propsrv.Set(script.objid,'StTweqRotate','AnimS',0x1)	
		statement = statement + 1
	end
	if propsrv.possessed(script.objid,'StTweqModels') and statement==RotateNeeded then
		propsrv.Set(script.objid,'StTweqModels','AnimS',0x1)		
	end
	return true
end

function TurnOff(msg)
	if propsrv.possessed(script.objid,'StTweqRotate') then
		propsrv.Set(script.objid,'StTweqRotate','AnimS',0x3)	
		statement = statement - 1
	end
	if propsrv.possessed(script.objid,'StTweqModels') and statement~=RotateNeeded then
		propsrv.Set(script.objid,'StTweqModels','AnimS',0x3)
	end
	return true
end

function TweqComplete(msg)
	propsrv.Set(script.objid,'StTweqRotate','AnimS',0x0)
	return true
end