function OnSceneLoad(screen)
    LoadData(screen)
    DefaultOnSceneLoad('data/Scenes/32_Lift_Main.lua', 'quest')

	LinkScene('area_30', 'CursorDoorDown','data/Scenes/30_Road_Fork_Main.lua')
	LinkScene('area_ho', 'CursorGlass','data/Scenes/32_Lift_HO.lua', true)
	
	LoadSound('32_Acid_on_chains', 'data/Sound/32_Lift/Acid_on_chains.ogg')
	LoadSound('32_Torch_burning', 'data/Sound/32_Lift/Torch_burning.ogg')
	
	play_field.torchBurningSound = MakeSoundEntity('32_Torch_burning');
	play_field.torchBurningSound:Play(true);

	RegisterQuestObjects('Z_Layer_Chain_L', 'Z_Layer_Chain_R')

	play_field:GetObject('acid_smoke1'):Hide()
	play_field:GetObject('acid_smoke1'):GetAnimation():Stop()
	play_field:GetObject('acid_smoke1'):GetAnimation():SetMode(HGEANIM_FWD + HGEANIM_NOLOOP)
	play_field:GetObject('acid_smoke2'):Hide()
	play_field:GetObject('acid_smoke2'):GetAnimation():Stop()
	play_field:GetObject('acid_smoke2'):GetAnimation():SetMode(HGEANIM_FWD + HGEANIM_NOLOOP)
	
	zone_lift = nil;

	if HasGameState('MiniGameCompleted', '32_Lift') == false then
		zone_lift = CreateZoomZone('area_lift',
								   'CloseZoneLift',
								   'BG_Zoom_Lift', true,
								   'Z_Layer_Chain_L', true,
								   'Z_Layer_Chain_R', true,
								   'Z_Layer_Chain_L1', false,
								   'Z_Layer_Chain_R1', false,
								   'area_mg', false)
	else
		play_field:GetObject('BG_Zoom_Lift'):SetVisible(false);
		play_field:GetObject('Z_Layer_Chain_L'):SetVisible(false);
		play_field:GetObject('Z_Layer_Chain_R'):SetVisible(false);
		play_field:GetObject('Z_Layer_Chain_L1'):SetVisible(false);
		play_field:GetObject('Z_Layer_Chain_R1'):SetVisible(false);
		LinkScene('area_lift', 'CursorGlass','data/Scenes/33_Scene_Luk.lua')
	end

	play_field:GetObject('area_mg'):SetMaxOpacity(0.01)
	play_field:GetObject('Layer_Chain_Broken_L'):SetOpacity(0.)
	play_field:GetObject('Layer_Chain_Broken_R'):SetOpacity(0.)

	RegisterMonologObject('BG_Zoom_Lift', 'C_32_LIFT')
	RegisterMonologObject('Z_Layer_Chain_L', 'C_32_CHAIN')
	RegisterMonologObject('Z_Layer_Chain_R', 'C_32_CHAIN')
	RegisterMonologObject('area_c_doll', 'C_32_DOLL', true)
	
	local play_acid_sound = function()
	    if not play_field.acidSound
        then
            play_field.acidSound = MakeSoundEntity('32_Acid_on_chains');
        end
        play_field.acidSound:StopSound();
        play_field.acidSound:Play(false);
	end

	local on_bulb_apply = function(tool_name, object_name)
        if object_name == 'Z_Layer_Chain_L' then
			TimerDoString('DestroyChainL()', 0.5, play_field:GetTimer())

			play_field:GetObject('acid_smoke1'):Show()
			play_field:GetObject('acid_smoke1'):GetAnimation():Play()
			play_field:GetObject('acid_smoke1'):SetXY(GetMousePos().x, GetMousePos().y)
			
			play_acid_sound();
        end
        if object_name == 'Z_Layer_Chain_R' then
			TimerDoString('DestroyChainR()', 0.5, play_field:GetTimer())

			play_field:GetObject('acid_smoke2'):Show()
			play_field:GetObject('acid_smoke2'):GetAnimation():Play()
			play_field:GetObject('acid_smoke2'):SetXY(GetMousePos().x, GetMousePos().y)
			
			play_acid_sound();
		end
		if not object_name then
			zone_lift.SetObjectVisible('area_mg', true)
			play_field:GetObject('area_mg'):SetVisible(true)
			play_field:GetObject('area_mg'):SetOpacity(0.01)
			game_state.custom_cursors['area_mg'] = 'CursorGlass'
			UnregisterActiveObject('BG_Zoom_Lift')
			AddGameState('ToolInfoShown', '31_bulb_half')
			FindTool('31_bulb_half')
			LinkScene('area_mg', 'CursorGlass','data/Scenes/32_Lift_MG.lua')

			--TimerDoString("zone_lift.SetVisible(false)", 0.6, play_field:GetTimer())
			--zone_lift.close_button:Stop()
			--zone_lift.Disable()
		end
    end
    local on_load_when_bulb_applied = function(tool_name, object_name)
        if not object_name or object_name == 'Z_Layer_Chain_L' then
			play_field:GetObject('Layer_Chain_L'):SetOpacity(0.)
			play_field:GetObject('Layer_Chain_Broken_L'):SetOpacity(1.)
			if HasGameState('MiniGameCompleted', '32_Lift') == false
			then
			    zone_lift.SetObjectVisible('Z_Layer_Chain_L', false)
			    zone_lift.SetObjectVisible('Z_Layer_Chain_L1', true)
			end
        end
        if not object_name or object_name == 'Z_Layer_Chain_R' then
			play_field:GetObject('Layer_Chain_R'):SetOpacity(0.)
			play_field:GetObject('Layer_Chain_Broken_R'):SetOpacity(1.)
			if HasGameState('MiniGameCompleted', '32_Lift') == false
			then
			    zone_lift.SetObjectVisible('Z_Layer_Chain_R', false)
			    zone_lift.SetObjectVisible('Z_Layer_Chain_R1', true)
            end
        end
        if not object_name then
            if HasGameState('MiniGameCompleted', '32_Lift') == false
            then
                zone_lift.SetObjectVisible('area_mg', true)
                game_state.custom_cursors['area_mg'] = 'CursorGlass'
                UnregisterActiveObject('BG_Zoom_Lift')
                LinkScene('area_mg', 'CursorGlass','data/Scenes/32_Lift_MG.lua')
            end
			--zone_lift.Disable()
        end
    end
    
	--if HasGameState('MiniGameCompleted', '32_Lift') == false then
		RegisterToolApplyInfo('31_bulb_full', {'Z_Layer_Chain_L', 'Z_Layer_Chain_R'}, nil, nil, on_bulb_apply, on_load_when_bulb_applied)
	--end
	
	for i=1,2
    do
	    local eff = MegoLightEffector();

	    eff:AttachTo(play_field:GetObject('FireRadialGlow'..i));
	    eff:PlayAt(math.random());
	end
end

function DestroyChainL()
    zone_lift.SetObjectVisible('Z_Layer_Chain_L', false)
	zone_lift.SetObjectVisible('Z_Layer_Chain_L1', true)
    play_field:GetObject('Z_Layer_Chain_L'):ChangeOpacity(1., 0., 0.3)
    play_field:GetObject('Z_Layer_Chain_L1'):ChangeOpacity(0., 1., 0.3)
	play_field:GetObject('Layer_Chain_L'):SetOpacity(0.)
	play_field:GetObject('Layer_Chain_Broken_L'):SetOpacity(1.)
end

function DestroyChainR()
    zone_lift.SetObjectVisible('Z_Layer_Chain_R', false)
	zone_lift.SetObjectVisible('Z_Layer_Chain_R1', true)
    play_field:GetObject('Z_Layer_Chain_R'):ChangeOpacity(1., 0., 0.3)
	play_field:GetObject('Z_Layer_Chain_R1'):ChangeOpacity(0., 1., 0.3)
	play_field:GetObject('Layer_Chain_R'):SetOpacity(0.)
	play_field:GetObject('Layer_Chain_Broken_R'):SetOpacity(1.)
end

function OnSceneFree(screen)
    DefaultOnSceneFree()
    FreeData(screen)
end

function OnUpdate(dt)
    DefaultOnUpdate(dt)
end

function OnAllItemsFound()
    DefaultOnAllItemsFound()
end

function OnLose()
    DefaultOnLose()
end

function OnExit()
    DefaultOnExit()
end

function OnClose()
    DefaultOnClose()
end

function OnObjectMouseEnter(object)
    DefaultOnObjectMouseEnter(object)
end

function OnObjectMouseLeave(object)
    DefaultOnObjectMouseLeave(object)
end

function OnObjectMouseDown(object)
    local is_wrong_click = not DefaultOnObjectMouseDown(object)
    local obj_name = object:GetName()
    local pf = play_field
end

function OnObjectMouseUp(object)
    DefaultOnObjectMouseUp(object)
end

function OnObjectFound(object)
    DefaultOnObjectFound(object)
end

function OnToolFound(tool)
    DefaultOnToolFound(tool)
end

function OnToolApply(tool, object)
    DefaultOnToolApply(tool, object)
end

function OnObjectReachPanel(object)
    DefaultOnObjectReachPanel(object)
end

function OnButtonPress(title)
    DefaultOnButtonPress(title)
end

function OnMouseMove(previous_pos, current_pos)
    DefaultOnMouseMove(previous_pos, current_pos)
end

function OnSetTool(tool)
    DefaultOnSetTool(tool)
end

function LevelLoaded(level)
end

function OnSceneDestroy(playfield)
    DefaultOnSceneDestroy(playfield)
end

--------------------------------------------------------------------------------
-- CLEAR_ON_SAVE_BEGIN
-- Do not edit code listed below (generated by the editor on each save)
function LoadData(screen)
	local anim = CreateAnimation('data/Texture/Scenes/32_Lift/Zone_Main/Layers/BG_Lift.JPG',0,0,1024,768,1,0)
	anim:SetHotSpot(512,384)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('BG_Lift',anim,512,384,40,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/32_Lift/Zone_Main/Zoom_Lift/BG_Zoom_Lift.jpg',0,0,640,480,1,0)
	anim:SetHotSpot(320,240)
	anim:SetBlendMode(2)
	anim:SetColor('0x00FFFFFF')
	screen:CreateObject('BG_Zoom_Lift',anim,512,384,150,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/32_Lift/Zone_Main/Zoom_Lift/Layer_Chain_L.PNG',0,0,221,422,1,0)
	anim:SetHotSpot(78,152)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Z_Layer_Chain_L',anim,258,339,155,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/32_Lift/Zone_Main/Zoom_Lift/Layer_Chain_R.PNG',0,0,329,402,1,0)
	anim:SetHotSpot(137,156)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Z_Layer_Chain_R',anim,568,388,155,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/Common/area.png',0,0,8,8,1,0)
	anim:SetHotSpot(4,1)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('area_lift',anim,636,419,120,0,30,20)
	local anim = CreateAnimation('data/Texture/Scenes/Common/area.png',0,0,8,8,1,0)
	anim:SetHotSpot(4,4)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('area_ho',anim,250,520,110,150,16,40)
	local anim = CreateAnimation('data/Texture/Scenes/Common/area.png',0,0,8,8,1,0)
	anim:SetHotSpot(4,4)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('area_30',anim,513,750,100,0,130,27)
	local anim = CreateAnimation('data/Texture/Scenes/32_Lift/Zone_Main/Layers/Layer_Chain_L.PNG',0,0,87,182,1,0)
	anim:SetHotSpot(43,91)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Layer_Chain_L',anim,592,489,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/32_Lift/Zone_Main/Layers/Layer_Chain_R.PNG',0,0,53,182,1,0)
	anim:SetHotSpot(26,91)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Layer_Chain_R',anim,672,487,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/32_Lift/Zone_Main/Layers/Layer_Chain_Broken_L.png',0,0,116,88,1,0)
	anim:SetHotSpot(58,44)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Layer_Chain_Broken_L',anim,548,533,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/32_Lift/Zone_Main/Layers/Layer_Chain_Broken_R.png',0,0,92,88,1,0)
	anim:SetHotSpot(46,44)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Layer_Chain_Broken_R',anim,711,534,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/Common/area.png',0,0,8,8,1,0)
	anim:SetHotSpot(4,4)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('area_mg',anim,486,218,155,0,18,18)
	local anim = CreateAnimation('data/Texture/Scenes/Common/fire1.png',0,0,86,128,31,12)
	anim:SetHotSpot(43,64)
	anim:SetBlendMode(0)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('fire1',anim,956,252,45,0,1,1.35)
	local anim = CreateAnimation('data/Texture/Scenes/Common/fire1.png',0,0,86,128,31,12)
	anim:SetHotSpot(43,64)
	anim:SetBlendMode(0)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('fire2',anim,288,114,45,5,0.85,1.04)
	local anim = CreateAnimation('data/Texture/Scenes/Common/radialGlow.png',0,0,97,99,1,0)
	anim:SetHotSpot(48,49)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFBB00')
	screen:CreateObject('FireRadialGlow1',anim,291,113,55,0,3.5,3.5)
	local anim = CreateAnimation('data/Texture/Scenes/Common/radialGlow.png',0,0,97,99,1,0)
	anim:SetHotSpot(48,49)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFCC00')
	screen:CreateObject('FireRadialGlow2',anim,958,290,55,0,3.5,3.5)
	local anim = CreateAnimation('data/Texture/Scenes/32_Lift/Zone_Main/Layers/Layer_Fakel_L.PNG',0,0,71,58,1,0)
	anim:SetHotSpot(35,29)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Layer_Fakel_L',anim,287,149,50,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/32_Lift/Zone_Main/Layers/Layer_Fakel_R.PNG',0,0,92,67,1,0)
	anim:SetHotSpot(46,33)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Layer_Fakel_R',anim,959,300,50,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/32_Lift/Zone_Main/Zoom_Lift/Layer_Chain_L1.png',0,0,208,111,1,0)
	anim:SetHotSpot(104,55)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Z_Layer_Chain_L1',anim,292,570,155,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/32_Lift/Zone_Main/Zoom_Lift/Layer_Chain_R1.png',0,0,192,129,1,0)
	anim:SetHotSpot(96,64)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Z_Layer_Chain_R1',anim,647,559,155,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/Common/area.png',0,0,8,8,1,0)
	anim:SetHotSpot(4,4)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('area_c_doll',anim,112,160,80,0,14,28)
	local anim = CreateAnimation('data/Texture/Scenes/31_Draw_Well/Zone_Main/Animations/dim.png',0,0,37,207,12,12)
	anim:SetHotSpot(16,207)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('acid_smoke1',anim,337,560,200,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/31_Draw_Well/Zone_Main/Animations/dim.png',0,0,37,207,12,12)
	anim:SetHotSpot(16,207)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('acid_smoke2',anim,337,560,200,0,1,1)
end

function FreeData(screen)
end
-- CLEAR_ON_SAVE_END
