function OnSceneLoad(screen)
    LoadData(screen)
    
	DefaultOnSceneLoad('data/Scenes/17_Ballance.lua', 'quest', 'data/Scenes/17_Theatre_Entrance_Main.lua')
     
	LinkScene('area_exit', 'CursorDoorDown', 'data/Scenes/17_Theatre_Entrance_Main.lua', false)
      
    STATUE_MASS = 117;
    WEIGHT_AMOUNT = 6;
    
    MiniGameField = screen;
    skip_mini_game = false;
    
    RightMassa = 0.0;
    LeftMassa = 0.0;
    
    game_complited = false;
    statuette_used = false;
    wages_used = false;
    
    game_field_enabled = false;
    
    show_monolog = false;
    
    first_active = true;
    
    Koromislo = screen:GetObject('Woman');
    Round = screen:GetObject('Scale');
    
    AttachInPlace(MiniGameField:GetObject('area_left'), MiniGameField:GetObject('Woman'));
    AttachInPlace(MiniGameField:GetObject('area_right'), MiniGameField:GetObject('Woman'));
    
	AttachInPlace(MiniGameField:GetObject('Layer_chasha_R'), MiniGameField:GetObject('Chasha_R'));
	AttachInPlace(MiniGameField:GetObject('Layer_chasha_L'), MiniGameField:GetObject('Chasha_L'));
	
	AttachInPlace(MiniGameField:GetObject('Target_Right'), MiniGameField:GetObject('Layer_chasha_R'));
	AttachInPlace(MiniGameField:GetObject('Target_Left'), MiniGameField:GetObject('Layer_chasha_L'));
	
	TargetL = MiniGameField:GetObject('Target_Left');
	TargetR = MiniGameField:GetObject('Target_Right');
	
	AttachInPlace(MiniGameField:GetObject('Layer_Eyes'), MiniGameField:GetObject('Woman'));
	
	--play_field:IgnoreOnTestPoint('BG_Minigame');
	play_field:IgnoreOnTestPoint('area_left');
	play_field:IgnoreOnTestPoint('area_right');
	play_field:IgnoreOnTestPoint('Woman');
	play_field:IgnoreOnTestPoint('Chasha_R');
	play_field:IgnoreOnTestPoint('Chasha_L');
	play_field:IgnoreOnTestPoint('Layer_chasha_L');
	play_field:IgnoreOnTestPoint('Layer_chasha_R');
	play_field:IgnoreOnTestPoint('Target_Left');
	play_field:IgnoreOnTestPoint('Target_Right');
	play_field:IgnoreOnTestPoint('Layer_Eyes');
	
	play_field:IgnoreOnTestPoint('Arrow');
	play_field:IgnoreOnTestPoint('Scale');
	
	WeightMass = {60, 50, 40, 30, 17, 7}
	
	Places = {};
	Places[1] = {false, false, false};
	Places[2] = {false, false, false};
	
	Coord = {};
	Coord['X'] = {-30, 0, 30};
	Coord['Y'] = {100, 105, 100};
	
	Objects = {}
	
	InitObject(screen, "Chuvak", STATUE_MASS);
	Objects["Chuvak"].Object:SetVisible(false);
	Objects["Chuvak"].Index = 0;
	Objects["Chuvak"].Place = 0;
	Objects["Chuvak"].Chashka = 0;
	
	MiniGameField:GetObject('Layer_Eyes'):SetVisible(false);
	
	for i = 1,WEIGHT_AMOUNT do
		InitObject(screen, "G_"..i, WeightMass[i]);
		Objects["G_"..i].Place = 0;
		Objects["G_"..i].Index = i;
		Objects["G_"..i].Object:SetVisible(false);
		Objects["G_"..i].Chashka = 0;
	end
	
	WeigthOrig = Objects["G_1"].Object:GetAnimation():GetWidth();
	HeightOrig = Objects["G_1"].Object:GetAnimation():GetHeight();

	if not HasGameState('ToolFound', '16_statuette')  or not HasGameState('ToolFound', '02_wages') then
		ShowMonolog('06_MiniGame', 'C_17_MINI_GAME1')
		---[[
		RegisterActiveObject('area',
							 function()
								ShowMonolog('06_MiniGame', 'C_17_MINI_GAME1')
							 end,
							 nil,
							 true)
		--]

		RegisterMonologObject('area_hint_paper', 'C_17_MINI_GAME1')
	else
		if not HasGameState('ToolApplied', '16_statuette')  or not HasGameState('ToolApplied', '02_wages') then
			ShowMonolog('06_MiniGame', 'C_17_MINI_GAME2')
			---[[
			RegisterActiveObject('area',
								 function()
									ShowMonolog('06_MiniGame', 'C_17_MINI_GAME2')
								 end,
								 nil,
								 true)
			--]
		end

		RegisterMonologObject('area_hint_paper', 'C_17_MINI_GAME2')
	end

	LoadSave();
	
	----------------------------------------------------------------------------------------------------------------------
	local on_statuette_apply = function(tool_name, object_name)
		Objects["Chuvak"].Object:SetVisible(true);
		if(GetMousePos().x < 512) then
			attachToSlot(2, Objects['Chuvak'].Object, 1);
		else
			MiniGameField:GetObject('Layer_Eyes'):SetVisible(true);
			attachToSlot(5, Objects['Chuvak'].Object, 1);
		end
		statuette_used = true;
		game_field_enabled = false;
		game_state.custom_cursors['area'] = 'CursorGlass'
		game_state.ignore_on_highlight['area'] = true
		IsAllApplied()
		MakeSoundEntity('17_Lock_click_first_wage'):Play(false);
    end
    
    local on_load_when_statuette_applied = function(tool_name)
		Objects["Chuvak"].Object:SetVisible(true);
		game_field_enabled = true;
		statuette_used = true;
		game_state.ignore_on_highlight['area'] = true
		IsAllApplied()
    end
    
    RegisterToolApplyInfo('16_statuette', 'area', nil, nil, on_statuette_apply, on_load_when_statuette_applied)
	----------------------------------------------------------------------------------------------------------------------
	
	local on_wages_apply = function(tool_name, object_name)
		wages_used = true;
		for i = 1,WEIGHT_AMOUNT do
			Objects["G_"..i].Object:SetVisible(true);
		end
		IsAllApplied()
		game_state.custom_cursors['area'] = 'CursorGlass'
    end
    
    local on_load_when_wages_applied = function(tool_name)
		wages_used = true;
		for i = 1,WEIGHT_AMOUNT do
			Objects["G_"..i].Object:SetVisible(true);
		end
		IsAllApplied()
    end
    
    RegisterToolApplyInfo('02_wages', 'area', nil, nil, on_wages_apply, on_load_when_wages_applied)
	----------------------------------------------------------------------------------------------------------------------
		
	screen:SetLayer(ADDITIONAL_LAYER);
	
	--LoadSave();
	if(IsTrueStep()) then
		MiniGameField:GetObject('Layer_Eyes'):SetVisible(true);
	else
		MiniGameField:GetObject('Layer_Eyes'):SetVisible(false);
	end
		
	LoadSound("PuttingWage", "data/Sound/17_Theatre_Entrance/Putting_wage.ogg")
	LoadSound("17_scales_shift_1", "data/Sound/17_Theatre_Entrance/Scales_shift_1.ogg")
	LoadSound("17_scales_shift_2", "data/Sound/17_Theatre_Entrance/Scales_shift_2.ogg")
	LoadSound("17_scales_shift_3", "data/Sound/17_Theatre_Entrance/Scales_shift_3.ogg")
	LoadSound("Scales_door_open", "data/Sound/17_Theatre_Entrance/Scales_door_open.ogg")
	LoadSound('17_Lock_click_first_wage', 'data/Sound/17_Theatre_Entrance/Lock_click_first_wage.ogg');
end


function StartBallanceGame()
	MiniGameField:GetObject("Layer_Eyes"):SetVisible(true);
	ShowMonolog('06_MiniGame', 'C_17_MINI_GAME3')
end

function IsAllApplied()
	if(wages_used == true and statuette_used == true) then
		game_state.level_type = 'mini_game';
		play_field:GetLevelScreen():GetPanel():SetMode(PM_MINIGAME);
		Objects["Chuvak"].Object:SetVisible(true);
		MiniGameField:GetObject("area"):SetVisible(false);
	end
end

function LoadSave()
	for j = 1,6 do 
		if(HasGameState('Ballance_slot_0'..j, '0')) then
			attachToSlot(j, Objects["Chuvak"].Object);
		else
			for i = 1,WEIGHT_AMOUNT do
				if(HasGameState('Ballance_slot_0'..j, ""..i.."")) then
					attachToSlot(j, Objects["G_"..i].Object, 1);
				end
			end
		end
	end
	
	Koromislo:SetAngle((RightMassa - LeftMassa) / 1000);
	Round:SetAngle(Koromislo:GetAngle() * 7.5);
end

function attachToSlot(SlotIndex, Obj, flag)
	DragObject = Obj;
	if(SlotIndex < 4) then
		SetToLeft(SlotIndex, flag);
	else
		SetToRight(SlotIndex - 3, flag);
	end
	DragObject = nil;
end

function eyeEffector(Obj)
	local af = CreateAnimationEffector()--AnimationEffector()
    af:AttachTo(Obj)
    af:SetKey(_TRACK_O, 0.0, 0.0)
    af:SetKey(_TRACK_O, 1.0, 1.0)
    af:SetKey(_TRACK_O, 2.0, 0.0)
    af:SetKey(_TRACK_O, 3.0, 1.0)
    af:Play()
end

function StatueInit()
	DragObject = MiniGameField:GetObject("Chuvak");
	SetToRight();
	DragObject = nil;
	ShowMonolog('06_MiniGame', 'C_17_MINI_GAME3')
end

function InitObject(screen, ObjectName, mass)
	Objects[ObjectName] = {};
	Objects[ObjectName].Object = screen:GetObject(ObjectName);
	Objects[ObjectName].StartPos = Objects[ObjectName].Object:GetPosition();
	--| 0 - на тумбочке 
	--| 1 - на левой чашке
	--| 2 - на правой чашке
	Objects[ObjectName].State = 0;
	Objects[ObjectName].Mass = mass;
end

function ObjectShow(obj)
	local scaler = CreateAnimationEffector()
	scaler:AttachTo(obj)
	scaler:SetKey(_TRACK_S, 0., 1.)
	scaler:SetKey(_TRACK_S, 0.3, 1.2)
	scaler:SetKey(_TRACK_S, 0.6, 1.)
	scaler:SetKey(_TRACK_S, 0.9, 1.2)
	scaler:SetKey(_TRACK_S, 1.1, 1.)
	scaler:Play()
end

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

function StartDrag(object)
	DragObject = object;
	SetCursor('CursorTool')
	
	DragObject:SetZ(300);
	
	local Obj = Objects[DragObject:GetName()];
	
	AttachInPlace(MiniGameField:GetObject(object:GetName()), MiniGameField);
	
	if(Obj.State == 1) then
		LeftMassa = LeftMassa - Obj.Mass;
	end
	
	if(Obj.State == 2) then
		RightMassa = RightMassa - Obj.Mass;
	end
	
	if(Places[Obj.State] ~= nil and Places[Obj.State][Obj.Place] ~= nil) then
		Places[Obj.State][Obj.Place] = false;
		if HasGameState('Ballance_slot_0'..((Obj.State - 1) * 3 + Obj.Place), ""..Objects[DragObject:GetName()].Index.."") then
			RemoveGameState('Ballance_slot_0'..((Obj.State - 1) * 3 + Obj.Place), ""..Objects[DragObject:GetName()].Index.."");
		end
	end
	
	if(IsTrueStep()) then
		MiniGameField:GetObject('Layer_Eyes'):SetVisible(true);
	else
		MiniGameField:GetObject('Layer_Eyes'):SetVisible(false);
	end
end

function UpdateDrag()
	if(DragObject ~= nil) then
		DragObject:SetXY(GetMousePos().x, GetMousePos().y);
	end
end

function StopDrag(doAbort)
	if(DragObject ~= nil) then
		if (math.abs(TargetL:GetScrX() - DragObject:GetScrX()) < 50 and
            math.abs(TargetL:GetScrY() - DragObject:GetScrY()) < 100 and
            IsFreePlace(1)) and not doAbort
        then
			SetToLeft();
			MakeSoundEntity('PuttingWage'):Play(false);
		else
			if (math.abs(TargetR:GetScrX() - DragObject:GetScrX()) < 50 and
                math.abs(TargetR:GetScrY() - DragObject:GetScrY()) < 100 and
                IsFreePlace(2)) and not doAbort
            then
				SetToRight()
				MakeSoundEntity('PuttingWage'):Play(false);
				if(DragObject:GetName() == "Chuvak" and first_active == false) then
					MiniGameField:GetObject('Layer_Eyes'):SetVisible(true);
				end
			else
				if(DragObject:GetName() == 'Chuvak') then
					if(Objects[DragObject:GetName()].State == 1) then
						SetToLeft();
					else
						SetToRight();
					end
				else
					DragObject:Move(Objects[DragObject:GetName()].StartPos.x - DragObject:GetX(), Objects[DragObject:GetName()].StartPos.y - DragObject:GetY(), 0.1);
					Objects[DragObject:GetName()].State = 0;
					Objects[DragObject:GetName()].Object:SetZ(150);
				end
			end
		end
		
		SetCursor('CursorDefault');
		DragObject = nil;
		
		if(IsTrueStep()) then
			if HasGameState('BALLANCE_SHOW_MONOLOG', 'true') == false then
				ShowMonolog('06_MiniGame', 'C_17_MINI_GAME3')
				AddGameState('BALLANCE_SHOW_MONOLOG', 'true')
			end
		
			MiniGameField:GetObject('Layer_Eyes'):SetVisible(true);
		else
			MiniGameField:GetObject('Layer_Eyes'):SetVisible(false);
		end
	end
end

function IsFreePlace(Direction)
	for i = 1, 3 do
		if(Places[Direction][i] == false) then
			return true;
		end
	end
	
	return false;
end

function GetFreePlace(Direction)
	for i = 1, 3 do
		if(Places[Direction][i] == false) then
			return i;
		end
	end
	
	return -1;
end

function SetToLeft(Place, flag)
	if(Place == nil) then
		PlaceIndex = GetFreePlace(1);
	else
		PlaceIndex = Place;
	end
	
	if(PlaceIndex > 0) then
		local Obj = MiniGameField:GetObject('Chasha_L');
		local AnimObj = DragObject:GetAnimation();
		local X = Obj:GetScrX() + Coord['X'][PlaceIndex];
		local Y = Obj:GetScrY() + Coord['Y'][PlaceIndex];
		if(PlaceIndex == 1) then
			DragObject:SetZ(150);
			X = X + (AnimObj:GetWidth() - WeigthOrig) / 3;
		end
		if(PlaceIndex == 3) then
			DragObject:SetZ(151);
			X = X - (AnimObj:GetWidth() - WeigthOrig) / 3;
		end
		if(PlaceIndex == 2) then
			DragObject:SetZ(152);
		end
		
		Y = Y - (AnimObj:GetHeight() - HeightOrig) / 3;
		DragObject:SetScrXY(X, Y);		
		AttachInPlace(MiniGameField:GetObject(DragObject:GetName()), MiniGameField:GetObject('Chasha_L'));
		Objects[DragObject:GetName()].State = 1;
		LeftMassa = LeftMassa + Objects[DragObject:GetName()].Mass;
		
		Places[1][PlaceIndex] = true;
		Objects[DragObject:GetName()].Place = PlaceIndex;
		
		if not HasGameState('Ballance_slot_0'..PlaceIndex, ""..Objects[DragObject:GetName()].Index.."") then
			AddGameState('Ballance_slot_0'..PlaceIndex, ""..Objects[DragObject:GetName()].Index.."");
		end
		
		Objects[DragObject:GetName()].Chashka = 1;
		
	else
		DragObject:Move(Objects[DragObject:GetName()].StartPos.x - DragObject:GetX(), Objects[DragObject:GetName()].StartPos.y - DragObject:GetY(), 0.1);
	end
end

function SetToRight(Place, flag)	
	if(Place == nil) then
		PlaceIndex = GetFreePlace(2);
	else
		PlaceIndex = Place;
	end
	
	if(PlaceIndex > 0) then
		local Obj = MiniGameField:GetObject('Chasha_R');
		local AnimObj = DragObject:GetAnimation();
		local X = Obj:GetScrX() + Coord['X'][PlaceIndex];
		local Y = Obj:GetScrY() + Coord['Y'][PlaceIndex];
		if(PlaceIndex == 1) then
			DragObject:SetZ(150);
			X = X + (AnimObj:GetWidth() - WeigthOrig) / 3;
		end
		if(PlaceIndex == 3) then
			DragObject:SetZ(151);
			X = X - (AnimObj:GetWidth() - WeigthOrig) / 3;
		end
		if(PlaceIndex == 2) then
			DragObject:SetZ(152);
		end
		
		Y = Y - (AnimObj:GetHeight() - HeightOrig) / 3;
		DragObject:SetScrXY(X, Y);
		AttachInPlace(MiniGameField:GetObject(DragObject:GetName()), MiniGameField:GetObject('Chasha_R'));
		Objects[DragObject:GetName()].State = 2;
		RightMassa = RightMassa + Objects[DragObject:GetName()].Mass;
	
		Places[2][PlaceIndex] = true;
		Objects[DragObject:GetName()].Place = PlaceIndex;
		Objects[DragObject:GetName()].Chashka = 2;
		
		if not HasGameState('Ballance_slot_0'..(PlaceIndex + 3), ""..Objects[DragObject:GetName()].Index.."") then
			AddGameState('Ballance_slot_0'..(PlaceIndex + 3), ""..Objects[DragObject:GetName()].Index.."");
		end
		
	else
		DragObject:Move(Objects[DragObject:GetName()].StartPos.x - DragObject:GetX(), Objects[DragObject:GetName()].StartPos.y - DragObject:GetY(), 0.1);
	end
end

function OnUpdate(dt)
	 
	local moved = false;
	 
	if(game_complited == false) then
		UpdateDrag();
		
		local ballanse_koef = 0.003 * (dt * 40);
		
		if ((RightMassa - LeftMassa) / 1000 > Koromislo:GetAngle()) then
			if(Koromislo:GetAngle() + ballanse_koef > (RightMassa - LeftMassa) / 1000) then
				Koromislo:SetAngle((RightMassa - LeftMassa) / 1000);
			else
				Koromislo:SetAngle(Koromislo:GetAngle() + ballanse_koef);
			end
			
			if(Koromislo:GetAngle() > M_PI_OVER_4 / 4) then
				Koromislo:SetAngle(M_PI_OVER_4 / 4);
			end
			Round:SetAngle(Koromislo:GetAngle() * 7.5);
			moved = true;
		end
		if ((RightMassa - LeftMassa) / 1000 < Koromislo:GetAngle()) then
			if(Koromislo:GetAngle() - ballanse_koef < (RightMassa - LeftMassa) / 1000) then
				Koromislo:SetAngle((RightMassa - LeftMassa) / 1000);
			else
				Koromislo:SetAngle(Koromislo:GetAngle() - ballanse_koef);
			end
			
			if(Koromislo:GetAngle() < -M_PI_OVER_4 / 4) then
				Koromislo:SetAngle(-M_PI_OVER_4 / 4);
			end
			Round:SetAngle(Koromislo:GetAngle() * 7.5);
			moved = true;
		end
		
		MiniGameField:GetObject("Chasha_R"):SetScrXY(MiniGameField:GetObject("area_right"):GetScrX(),MiniGameField:GetObject("area_right"):GetScrY());
		MiniGameField:GetObject("Chasha_L"):SetScrXY(MiniGameField:GetObject("area_left"):GetScrX(),MiniGameField:GetObject("area_left"):GetScrY());
		 			
		if(moved == false) then
			if(IsCompleted()) then
				eyeEffector(MiniGameField:GetObject("Layer_Eyes"));
				FinishAnimation();
				MakeSoundEntity('Scales_door_open'):Play(false);
				TimerDoString("FinishGame()", 1.0, MiniGameField:GetTimer());
				game_complited = true;
			end
			if play_field.KoromisloMoveSound and play_field.KoromisloMoveSound:IsPlaying()
			then
			    play_field.KoromisloMoveSound:StopSound();
			end
		else
			--MiniGameField:GetObject('Layer_Eyes'):SetVisible(false);
			if not play_field.KoromisloMoveSound
			then
			    play_field.KoromisloMoveSound =
                    MakeSoundEntity(SelectRandom('17_scales_shift_1', '17_scales_shift_2', '17_scales_shift_1'))
            elseif not play_field.KoromisloMoveSound:IsPlaying()
            then
                play_field.KoromisloMoveSound:Destroy();
                play_field.KoromisloMoveSound = 
                    MakeSoundEntity(SelectRandom('17_scales_shift_1', '17_scales_shift_2', '17_scales_shift_1'));
			end
			
			if not play_field.KoromisloMoveSound:IsPlaying()
			then
			    play_field.KoromisloMoveSound:Play(false);
			end
		end
	end
	
	
	if(game_field_enabled == false and moved == false) then
		game_field_enabled = true;
	end
	
	if(first_active == true and game_field_enabled == true and moved == false and RightMassa == 12 and LeftMassa == 0) then
		StartBallanceGame();
		first_active = false;
	end
	
	if DragObject and not Input_GetKeyState(HGEK_LBUTTON) then
		StopDrag()
	end

	DefaultOnUpdate(dt)
end

function IsCompleted()
	if(RightMassa ~= LeftMassa or RightMassa <= 0 or Objects["Chuvak"].Chashka ~= 2 or (DragObject ~= nil and DragObject:GetName() == "Chuvak")) then
		return false;
	end
	
	return true;
end

function IsTrueStep()
	if(Objects["Chuvak"].Chashka ~= 2 or (DragObject ~= nil and DragObject:GetName() == "Chuvak")) then
		return false;
	end
	
	local counter = 0;
	for i = 1, 3 do
		if(Places[2][i] == false) then
			counter = counter + 1;
		end
	end
	
	if(counter ~= 2) then
		return false;
	end
	
	return true;
end

function AttachInPlace(object, parentObject)
	local scrX,scrY = object:GetScrX(), object:GetScrY();
	object:AttachTo(parentObject);
	object:SetScrXY(scrX, scrY);
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
    
    if(game_complited == false and Objects[obj_name] ~= nil and game_field_enabled == true) then	 
		StartDrag(object);

		if is_wrong_click then
			play_field:ShowWrongObjectEffect()
		end
    end
end

function OnObjectMouseUp(object)
    DefaultOnObjectMouseUp(object)		
	StopDrag();
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 SkipMiniGame()
	if(skip_mini_game == false) then		
 		skip_mini_game = true;
 		game_complited = true;
		TimerDoString("FinishGame()", 0.4, MiniGameField:GetTimer())
	end
end

function FinishGame()
	skip_mini_game = true;
	MiniGame = true;
	TimerDoString("StartLevel('data/Scenes/17_Theatre_Entrance_Main.lua');", 0.5, MiniGameField:GetTimer())
	if HasGameState('MiniGameCompleted', '17_Ballance') == false then
		AddGameState('MiniGameCompleted', '17_Ballance');
	end
end

function FinishAnimation()
	MiniGameField:GetObject("Ring"):Rotate(M_PI * 2, 4.0);
	--MiniGameField:GetObject("Ring_Small"):Rotate(-M_PI * 2, 4.0);
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/Minigames/ballance/BG_Minigame.jpg',0,0,1024,768,1,0)
	anim:SetHotSpot(512,384)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('BG_Minigame',anim,512,384,90,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/ballance/Arrow.PNG',0,0,79,196,1,0)
	anim:SetHotSpot(39,98)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Arrow',anim,516,561,101,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/ballance/Scale.PNG',0,0,205,200,1,0)
	anim:SetHotSpot(102,100)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Scale',anim,515,540,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/ballance/Chasha_L.PNG',0,0,142,195,1,0)
	anim:SetHotSpot(74,10)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Chasha_L',anim,355,263,101,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/ballance/G_1.PNG',0,0,44,72,1,0)
	anim:SetHotSpot(22,36)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('G_1',anim,324,487,150,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/ballance/G_2.PNG',0,0,41,67,1,0)
	anim:SetHotSpot(20,33)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('G_2',anim,705,494,150,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/ballance/G_3.PNG',0,0,36,58,1,0)
	anim:SetHotSpot(18,29)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('G_3',anim,648,496,150,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/ballance/G_4.PNG',0,0,31,48,1,0)
	anim:SetHotSpot(15,24)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('G_4',anim,365,485,150,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/ballance/G_5.PNG',0,0,22,38,1,0)
	anim:SetHotSpot(11,19)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('G_5',anim,389,501,150,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/ballance/G_6.PNG',0,0,20,32,1,0)
	anim:SetHotSpot(10,16)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('G_6',anim,674,493,150,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/ballance/Woman.PNG',0,0,355,272,1,0)
	anim:SetHotSpot(177,390)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Woman',anim,518,558,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/ballance/Chasha_R.PNG',0,0,142,196,1,0)
	anim:SetHotSpot(70,10)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Chasha_R',anim,677,260,101,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/ballance/Layer_chasha_L.PNG',0,0,142,81,1,0)
	anim:SetHotSpot(71,40)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Layer_chasha_L',anim,353,408,160,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/ballance/Layer_chasha_R.PNG',0,0,142,87,1,0)
	anim:SetHotSpot(74,11)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Layer_chasha_R',anim,680,369,160,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/ballance/Chuvak.PNG',0,0,73,135,1,0)
	anim:SetHotSpot(36,67)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Chuvak',anim,676,338,150,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_left',anim,355,263,100,0,3,3)
	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_right',anim,678,261,100,0,3,3)
	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('Target_Left',anim,353,352,200,0,15,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('Target_Right',anim,679,349,200,0,15,20)
	local anim = CreateAnimation('data/Texture/Minigames/ballance/Layer_Eyes.PNG',0,0,53,39,1,0)
	anim:SetHotSpot(26,19)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Layer_Eyes',anim,517,201,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/Common/area.png',0,0,8,8,1,0)
	anim:SetHotSpot(1,5)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('area',anim,306,376,500,0,70,50)
	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_exit',anim,508,708,400,0,100,15)
	local anim = CreateAnimation('data/Texture/Minigames/ballance/Behind.png',0,0,257,269,1,0)
	anim:SetHotSpot(128,134)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Behind',anim,516,542,95,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/ballance/Ring.png',0,0,413,411,1,0)
	anim:SetHotSpot(206,205)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Ring',anim,520,310,92,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/ballance/Shadow.png',0,0,437,447,1,0)
	anim:SetHotSpot(218,223)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Shadow',anim,514,298,94,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_hint_paper',anim,706,613,100,15,15,15)
end

function FreeData(screen)
end
-- CLEAR_ON_SAVE_END
