function main(self)
	if self.State == 0 then
		self.Flags.AlwaysActive = true
		self.HitTypeFlags, self.HitRect = 2, {-10,-24,10,24}
		self.HitDelay = 0
		self.FrameTimer = 0
		self.State = 7
	end

	if self.State == 5 then -- stay down
        if self.I ~= 3 then
		    self:SetFrame(3)
        end
	end
	if self.State == 6 then -- go up
		if GetTime() > self.FrameTimer then self.State = 7 end
	end
	if self.State == 7 then -- stay up
        if self.I ~= 1 then
		    self:SetFrame(1)
        end
	end
	if self.State == 8 then -- go down
		if GetTime() > self.FrameTimer then self.State = 5 end
	end

    if self.State == 108 then
        CreatePalette():Set()
        GetPlane(1).Flags.NoDraw = true
        GetClaw().X = 936
        GetClaw().Y = GetClaw().Y-50
        LoadBaseLevDefaults(14)
        SetDeathType(1)
        SwapSound("CUSTOM_SPIKES", "LEVEL_DEATHTILE")
        SwapSound("CUSTOM_PEGSLIDE", "LEVEL_PEGSLIDE")
        self.palDelay = GetTime()
        self.State = 109
    end

    if self.State == 109 and GetTime() > self.palDelay + 150 then
        GetFirstPalette():Set()
        LoadAverageCLT"AVERAGE.CLT"
        LoadLightCLT"LIGHT.CLT"
        SetRespawnPoint()
        self.State = 8
    end

end

function hit(self)
	if GetTime() > self.HitDelay then
		self.HitDelay = GetTime() + 300
		self.FrameTimer = GetTime() + 80
		PlaySound("CUSTOM_LEVER")
		self:SetFrame(2)
		if self.State == 5 then
			self.State = 6
		elseif self.State == 7 then
			self.State = 108
		end
	end
end
