function init()	

	--Find handles to the light switch and and lamp
	switch = FindShape("switch")
	lamp = FindLight("lamp")
	drum = FindShape("post")
	motor = FindJoint("motor")

	--The light should start turned off
	on = false
	SetLightEnabled(lamp, false)
	SetJointMotor(motor, 20, false)
	SetTag(switch, "interact", "Blend")

	--Load sounds from the game asset folder (data/snd)
	onSound = LoadSound("LEVEL/sound/blender.ogg")
	offSound = LoadSound("screen-off.ogg")
end


function tick()
	--Check if player interacts with light switch and presses interact button
	if GetPlayerInteractShape() == switch and InputPressed("interact") then

		--Turn light on or off, depending on the current state
		if on then
			on = false
			PlaySound(offSound)
			SetLightEnabled(lamp, false)
	                SetJointMotor(motor, 20, false)
			SetTag(switch, "interact", "Blend")
		else
			on = true
			PlaySound(onSound)
			SetLightEnabled(lamp, true)
	                SetJointMotor(motor, 20)
			SetTag(switch, "interact", "Turn off")
		end
		
	end
end

