ScriptName _00E_DothulgradPuzzle2Script Extends ObjectReference

MiscObject Property energyCrystal Auto
ObjectReference Property crystalObject Auto
ObjectReference Property light1 Auto
ObjectReference Property light2 Auto
ObjectReference Property lever Auto
ObjectReference Property altar Auto
Message Property lackTheItem Auto
Float count = 1.0
Bool doOnce = True


Event OnActivate(ObjectReference ref)
	if(ref == Game.GetPlayer())
		if(ref.GetItemCount(energyCrystal) !=0 && doOnce == True)
			ref.RemoveItem(energyCrystal)
			
			
			;enable lights
			light1.enable()
			light2.enable()
			;enable crystalobject
			crystalObject.enable()
	
			;activate trapdoor
			lever.activate(ref)
			
				
				;rotate altar
				;this is just a small test if this method works
				;must be reworked with proper iteration
				while count < 30
					Debug.Notification("i run " + count)
					altar.SetAngle(0.0, 0.0, count)
					count += 1
				EndWhile
			
			;make sure it only fires once
			doOnce = False
	
		;if player doesn't have an energycrystal
		ElseIf(doOnce == True)
			lackTheItem.show()
		EndIf
	EndIf
EndEvent