function OnSceneLoad(screen)
    LoadData(screen)
    DefaultOnSceneLoad('data/Scenes/18_Apartment_HO.lua', 'hidden_object', 'data/Scenes/18_Apartment_Main.lua')
    
    play_field:GetObject('Layer_shelf_open' ):SetOpacity(0);
    play_field:GetObject('BG_Telescope'     ):SetOpacity(0);
    play_field:GetObject('Telescope'        ):SetOpacity(0);
    
    RegisterActiveObject('area_shelf',  function(obj_name)
                                            play_field:GetObject(obj_name):SetVisible(false);
                                            
                                            play_field:GetObject('Layer_shelf_open' ):ChangeOpacity(0, 1, OPEN_DOOR_TIME);
                                            play_field:GetObject('BG_Telescope'     ):ChangeOpacity(0, 1, OPEN_DOOR_TIME);
                                            play_field:GetObject('Telescope'        ):ChangeOpacity(0, 1, OPEN_DOOR_TIME);
                                            
                                            PlaySound('18_OpenShelfInHO');
                                        end,
                                        function(obj_name)
                                            play_field:GetObject(obj_name):SetVisible(false);
                                            
                                            play_field:GetObject('Layer_shelf_open' ):SetOpacity(1);
                                            play_field:GetObject('BG_Telescope'     ):SetOpacity(1);
                                            play_field:GetObject('Telescope'        ):SetOpacity(1);
                                        end);
    
    AddTask(CreateTask('BELL',     '',            'Bell'));
    AddTask(CreateTask('BAG',      'BAGS',        'Bag1', 'Bag2'));
    AddTask(CreateTask('PIPE',     'PIPES',       'Pipe1', 'Pipe2'));
    AddTask(CreateTask('SHELL',    'SHELLS',      'Shell1', 'Shell2'));
    AddTask(CreateTask('UMBRELLA', 'UMBRELLAS',   'Umbrella1', 'Umbrella2'));
    AddTask(CreateTask('TELESCOPE', '',           'Telescope'));
    
    AddRandomTasks( CreateTask('BINOCULAR',    '', 'Binocular'),
                    CreateTask('IRON',         '', 'Iron'),
                    CreateTask('PARAFFIN_LAMP','', 'Lamp'),
                    CreateTask('PEAR',         '', 'Pear'),
                    CreateTask('PISTOL',       '', 'Pistol'),
                    CreateTask('SWORD',        '', 'Sword'),
                    CreateTask('VIOLIN',       '', 'Violin'),
                    CreateTask('TOPHAT',       '', 'TopHat'),
                    CreateTask('BOOKS',        '', 'Books'),
                    CreateTask('CANNON',       '', 'Cannon'),
                    CreateTask('DAGGER',       '', 'Dagger'),
                    CreateTask('GARLAND',      '', 'Garland'),
                    CreateTask('HORSE',        '', 'Horse'),
                    CreateTask('INKPOT',       '', 'Inkpot'),
                    CreateTask('KNIGHT',       '', 'Knight'),
                    CreateTask('PORTRAIT',     '', 'Portrait'),
                    CreateTask('SNOWFLAKE',    '', 'Snowflake'));
    
    RegisterToolFindInfo('18_bell');
    
    game_state.disable_close_scene_on_complete = true;
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

    DefaultOnObjectMouseDownProcessed(is_wrong_click);
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/18_Apartment/Zone_HO/Layers/background.jpg',0,0,1024,768,1,0)
	anim:SetHotSpot(512,384)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('background',anim,512,384,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/18_Apartment/Zone_HO/Items/Bell.png',0,0,32,84,1,0)
	anim:SetHotSpot(16,42)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Bell',anim,593,511,101,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/18_Apartment/Zone_HO/Items/Binocular.png',0,0,95,45,1,0)
	anim:SetHotSpot(47,22)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Binocular',anim,362,644,101,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/18_Apartment/Zone_HO/Items/Iron.png',0,0,55,59,1,0)
	anim:SetHotSpot(27,29)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Iron',anim,994,611,101,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/18_Apartment/Zone_HO/Items/Lamp.png',0,0,49,73,1,0)
	anim:SetHotSpot(24,36)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Lamp',anim,134,596,101,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/18_Apartment/Zone_HO/Items/Pear.png',0,0,25,34,1,0)
	anim:SetHotSpot(12,17)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Pear',anim,290,426,101,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/18_Apartment/Zone_HO/Items/Pistol.png',0,0,102,88,1,0)
	anim:SetHotSpot(51,44)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Pistol',anim,926,645,102,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/18_Apartment/Zone_HO/Items/Sword.png',0,0,167,45,1,0)
	anim:SetHotSpot(83,22)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Sword',anim,580,283,101,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/18_Apartment/Zone_HO/Items/Violin.png',0,0,146,71,1,0)
	anim:SetHotSpot(73,35)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Violin',anim,657,207,101,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/18_Apartment/Zone_HO/Layers/BG_TopHat.png',0,0,95,96,1,0)
	anim:SetHotSpot(47,48)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('BG_TopHat',anim,540,317,102,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/18_Apartment/Zone_HO/Layers/BG_Violin.png',0,0,117,59,1,0)
	anim:SetHotSpot(58,29)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('BG_Violin',anim,625,228,102,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/18_Apartment/Zone_HO/Items/TopHat.png',0,0,61,84,1,0)
	anim:SetHotSpot(30,42)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('TopHat',anim,832,195,101,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/18_Apartment/Zone_HO/Items/Bag1.png',0,0,42,93,1,0)
	anim:SetHotSpot(21,46)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Bag1',anim,113,515,101,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/18_Apartment/Zone_HO/Items/Bag2.png',0,0,109,89,1,0)
	anim:SetHotSpot(54,44)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Bag2',anim,664,614,101,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/18_Apartment/Zone_HO/Items/Books.png',0,0,57,41,1,0)
	anim:SetHotSpot(28,20)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Books',anim,785,463,101,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/18_Apartment/Zone_HO/Items/Cannon.png',0,0,66,51,1,0)
	anim:SetHotSpot(33,25)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Cannon',anim,531,204,101,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/18_Apartment/Zone_HO/Items/Dagger.png',0,0,53,93,1,0)
	anim:SetHotSpot(26,46)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Dagger',anim,323,487,101,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/18_Apartment/Zone_HO/Items/Garland.png',0,0,64,67,1,0)
	anim:SetHotSpot(32,33)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Garland',anim,534,476,101,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/18_Apartment/Zone_HO/Items/Horse.png',0,0,64,90,1,0)
	anim:SetHotSpot(32,45)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Horse',anim,632,435,101,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/18_Apartment/Zone_HO/Items/Inkpot.png',0,0,53,83,1,0)
	anim:SetHotSpot(26,41)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Inkpot',anim,820,485,101,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/18_Apartment/Zone_HO/Items/Knight.png',0,0,57,123,1,0)
	anim:SetHotSpot(28,61)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Knight',anim,380,450,101,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/18_Apartment/Zone_HO/Items/Pipe1.png',0,0,60,37,1,0)
	anim:SetHotSpot(30,18)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Pipe1',anim,730,509,101,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/18_Apartment/Zone_HO/Items/Pipe2.png',0,0,63,34,1,0)
	anim:SetHotSpot(31,17)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Pipe2',anim,486,647,101,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/18_Apartment/Zone_HO/Items/Portrait.png',0,0,53,71,1,0)
	anim:SetHotSpot(26,35)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Portrait',anim,981,202,101,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/18_Apartment/Zone_HO/Items/Shell1.png',0,0,55,34,1,0)
	anim:SetHotSpot(27,17)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Shell1',anim,704,462,101,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/18_Apartment/Zone_HO/Items/Shell2.png',0,0,52,41,1,0)
	anim:SetHotSpot(26,20)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Shell2',anim,462,234,101,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/18_Apartment/Zone_HO/Items/Snowflake.png',0,0,47,54,1,0)
	anim:SetHotSpot(23,27)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Snowflake',anim,252,472,101,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/18_Apartment/Zone_HO/Items/Telescope.png',0,0,52,57,1,0)
	anim:SetHotSpot(26,28)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Telescope',anim,438,338,102,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/18_Apartment/Zone_HO/Items/Umbrella1.png',0,0,56,185,1,0)
	anim:SetHotSpot(28,92)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Umbrella1',anim,177,547,101,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/18_Apartment/Zone_HO/Items/Umbrella2.png',0,0,121,121,1,0)
	anim:SetHotSpot(60,60)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Umbrella2',anim,854,610,101,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/18_Apartment/Zone_HO/Layers/BG_Bag2.png',0,0,38,79,1,0)
	anim:SetHotSpot(19,39)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('BG_Bag2',anim,699,617,102,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/18_Apartment/Zone_HO/Layers/BG_Book.png',0,0,39,34,1,0)
	anim:SetHotSpot(19,17)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('BG_Book',anim,775,476,102,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/18_Apartment/Zone_HO/Layers/BG_Horse.png',0,0,27,44,1,0)
	anim:SetHotSpot(13,22)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('BG_Horse',anim,669,439,102,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/18_Apartment/Zone_HO/Layers/BG_Umbrella.png',0,0,29,102,1,0)
	anim:SetHotSpot(14,51)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('BG_Umbrella',anim,838,605,102,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_Gendarmery/Zone_wart/Animations/fly_anim.png',0,0,217,217,8,12)
	anim:SetHotSpot(108,108)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('fly_anim_1',anim,175,288,101,0,0.9,0.9)
	local anim = CreateAnimation('data/Texture/Scenes/05_Gendarmery/Zone_wart/Animations/fly_anim.png',0,0,217,217,8,10)
	anim:SetHotSpot(108,108)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('fly_anim_2',anim,324,319,101,0,0.9,0.9)
	local anim = CreateAnimation('data/Texture/Scenes/05_Gendarmery/Zone_wart/Animations/fly_anim.png',0,0,217,217,8,10)
	anim:SetHotSpot(108,108)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('fly_anim_3',anim,750,336,101,0,0.9,0.9)
	local anim = CreateAnimation('data/Texture/Scenes/Common/Animations/candle.png',0,0,20,40,25,18)
	anim:SetHotSpot(10,20)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('candle_flame2',anim,234,360,102,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/18_Apartment/Zone_HO/Animations/fireplace_anim.png',0,0,108,112,15,12)
	anim:SetHotSpot(270,168)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('fireplace_anim',anim,508,660,101,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/18_Apartment/Zone_HO/Layers/Layer_shelf_open.png',0,0,100,154,1,0)
	anim:SetHotSpot(50,77)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Layer_shelf_open',anim,426,332,101,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/18_Apartment/Zone_HO/Layers/BG_Telescope.png',0,0,10,30,1,0)
	anim:SetHotSpot(5,15)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('BG_Telescope',anim,459,328,103,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/Common/area_circle.png',0,0,128,128,1,0)
	anim:SetHotSpot(64,64)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('area_shelf',anim,430,316,105,0,1,1)
end

function FreeData(screen)
end
-- CLEAR_ON_SAVE_END
