require( "scripts/style.lua" );


function QueueMakeDialog( t )
 f = function() MakeDialog(t) end; 
 QueueFunction(f);
end

function QueueDisplayDialog( t )
 f = function() DisplayDialog(t) end; 
 QueueFunction(f);
end 

--ITEMS:  0=generic grape    |    6=merlot    |    -2= leaf   |    -1=branch
sT = {};
                    sT[0]=-2;  sT[1]=0;  sT[2]=-2;  sT[3]=0;  sT[4]=0;  sT[5]=5;  sT[6]=-1;
          sT[7]=0;  sT[8]=5;  sT[9]=-1;  sT[10]=0; sT[11]=-1; sT[12]=-1; sT[13]=-1; sT[14]=5; sT[15]=-2;
sT[16]=-2; sT[17]=0; sT[18]=-1; sT[19]=-1; sT[20]=-1; sT[21]=-1; sT[22]=-1; sT[23]=0; sT[24]=-1; sT[25]=-2; sT[26]=-1;
sT[27]=-1; sT[28]=-1; sT[29]=-2; sT[30]=-2; sT[31]=-2; sT[32]=-1; sT[33]=-1; sT[34]=-2; sT[35]=-2; sT[36]=-1; sT[37]=-2;
sT[38]=-1; sT[39]=-2; sT[40]=-1; sT[41]=-1; sT[42]=-1; sT[43]=-2; sT[44]=-2; sT[45]=-1; sT[46]=-1; sT[47]=-2; sT[48]=-1;
sT[49]=-2; sT[50]=-1; sT[51]=-2; sT[52]=-2; sT[53]=-2; sT[54]=-1; sT[55]=-1; sT[56]=-1; sT[57]=-2; sT[58]=-1; sT[59]=-2;
sT[60]=-1; sT[61]=-2; sT[62]=-1; sT[63]=-1; sT[64]=-2; sT[65]=-2; sT[66]=-2; sT[67]=-1; sT[68]=-1; sT[69]=-1; sT[70]=-2;
sT[71]=-1; sT[72]=-2; sT[73]=-2; sT[74]=-2; sT[75]=-1; sT[76]=-1; sT[77]=-1; sT[78]=-1; sT[79]=-1; sT[80]=-1; sT[81]=-2;
          sT[82]=-2; sT[83]=-2; sT[84]=-1; sT[85]=-1; sT[86]=-2; sT[87]=-1; sT[88]=-1; sT[89]=-1; sT[90]=-1;
                    sT[91]=-2; sT[92]=-1; sT[93]=-2; sT[94]=-2; sT[95]=-2; sT[96]=-2; sT[97]=-2;

function Tutorial()
		
	-- INITIALIZATION
	SetSelectingState(12);
	InitTable();
	Yield();
	-- INITIALIZATION - END
	
	-- START POPUP
	QueueDisplayDialog({"scripts/tutorialmodalh.lua", body="tutorial_selecting_start"});
	minigame_start2();
	Yield();
	-- START POPUP - END
	
	-- INIT SPRITE CURSOR
	--SetMouseVisible(false);
	InitSpriteCursor(200,130);
	Yield();
	-- INIT SPRITE CURSOR - END
	
	-- TEXT = In this process, you will have to remove the garbage and let only the grapes to get a good quality for your wine. You can remove only one kind of garbage at a time.
	--CreateWindow("scripts/tutorial_minigames/selecting/window_a.lua");
	QueueDisplayDialog({"scripts/tutorial_minigames/selecting/window_a.lua"});
	Yield();
	-- TEXT END
	
	--WAIT
	--Sleep(100);
	--Sleep(50);
	--Yield();
	--WAIT - END
	
	-- TEXT = To remove garbage, ckick on  a garbage item and drag the cursor to select other garbages of the same type. You need to select at least 3 garbage itens in order to remove them from the sieve.
	--DestroyWindow();
	CreateWindow("scripts/tutorial_minigames/selecting/window_b.lua");
	QueueDisplayDialog({"scripts/tutorial_minigames/selecting/window_b_next.lua"});
	Yield();
	-- TEXT - END
	
	--SELECTING PATH LENGTH 3
	MoveMouseTo(4,2);
	Yield();
	SelectFirstItem(4,2);
	Yield();
	
	--Sleep(10);
	--Yield();
	
	MoveMouseTo(4,3);
	Yield();
	SelectItem(4,3);
	Yield();
	
	--Sleep(10);
	--Yield();
	
	MoveMouseTo(4,4);
	Yield();
	SelectItem(4,4);
	Yield();
	
	--Sleep(10)
	--Yield();
	
	FinishSelection();
	Yield();
	--SELECTING PATH LENGTH 3 - END
	
	-- TEXT = This number indicates how many garbage items you need to remove to complete a quality star.
	DestroyWindow();
	--CreateWindow("scripts/tutorial_minigames/selecting/window_c.lua");
	QueueDisplayDialog({"scripts/tutorial_minigames/selecting/window_c.lua"});
	Yield();
	-- TEXT - END
	
	--WAIT
	--Sleep(100);
	--Yield();
	--WAIT - END
	
	-- TEXT = This number indicates how many garbage items you need to remove to complete a quality star.
	--DestroyWindow();
	CreateWindow("scripts/tutorial_minigames/selecting/window_d.lua");
	Yield();
	-- TEXT - END
	
	--SELECTING PATH LENGTH 14
	MoveMouseTo(7,4);
	Yield();
	SelectFirstItem(7,4);
	Yield();
	
	MoveMouseTo(7,5);
	Yield();
	SelectItem(7,5);
	Yield();
	
	MoveMouseTo(7,6);
	Yield();
	SelectItem(7,6);
	Yield();
	
	MoveMouseTo(8,6);
	Yield();
	SelectItem(8,6);
	Yield();
	
	MoveMouseTo(8,7);
	Yield();
	SelectItem(8,7);
	Yield();
	
	MoveMouseTo(8,8);
	Yield();
	SelectItem(8,8);
	Yield();
	
	--[[MoveMouseTo(8,9);
	Yield();
	SelectItem(8,9);
	Yield();
	
	MoveMouseTo(7,9);
	Yield();
	SelectItem(7,9);
	Yield();
	
	MoveMouseTo(7,8);
	Yield();
	SelectItem(7,8);
	Yield();
	
	MoveMouseTo(7,7);
	Yield();
	SelectItem(7,7);
	Yield();
	
	MoveMouseTo(6,7);
	Yield();
	SelectItem(6,7);
	Yield();
	
	MoveMouseTo(6,8);
	Yield();
	SelectItem(6,8);
	Yield();
	
	MoveMouseTo(6,9);
	Yield();
	SelectItem(6,9);
	Yield();
	
	MoveMouseTo(5,9);
	Yield();
	SelectItem(5,9);
	Yield();]]--
	
	Sleep(10);
	Yield();
	
	FinishSelection();
	Yield();
	--SELECTING PATH LENGTH 14 - END
	
	-- TEXT = You can swap items to help you remove garbage.
	DestroyWindow();
	CreateWindow("scripts/tutorial_minigames/selecting/window_e.lua");
	Yield();
	-- TEXT - END
	
	--SWAP COMPLETE (890,645)
	MoveMouseToPosition(890,645);
	Yield();
	SwapButton();
	Yield();
	MoveMouseTo(1,8);
	Yield();
	SwapFirstItem(1,8);
	Yield();
	MoveMouseTo(1,7);
	Yield();
	SwapLastItem(1,7);
	Yield();
	--SWAP COMPLETE - END
	
	--SELECTING PATH LENGTH 3
	MoveMouseTo(0,8);
	Yield();
	SelectFirstItem(0,8);
	Yield();
	
	MoveMouseTo(1,8);
	Yield();
	SelectItem(1,8);
	Yield();
	
	MoveMouseTo(2,8);
	Yield();
	SelectItem(2,8);
	Yield();
	
	FinishSelection();
	Yield();
	--SELECTING PATH LENGTH 3 - END
		
	-- TEXT = If you do not have other options, you can click 'Remix' to mix all the items.
	DestroyWindow();
	CreateWindow("scripts/tutorial_minigames/selecting/window_f.lua");
	Yield();
	-- TEXT - END
	
	--REMIX POSITION (920,545)
	MoveMouseToPosition(920,545);
	Yield();
	RemixButton();
	Yield();
	--REMIX POSITION - END
	
	-- REMOVE SPRITE CURSOR
	--SetMouseVisible(true);
	EnableCursor(false);
	Yield();
	-- REMOVE SPRITE CURSOR - END
	
	-- FINISH POPUP
	DestroyWindow();
	QueueDisplayDialog({"scripts/tutorialmodalh.lua", body="tutorial_selecting_finish"});
	Yield();
	-- FINISH POPUP - END
	
	--FINALIZE SCRIPT
	EnableTutorial(false);
	--FINALIZE SCRIPT - END
end



return Tutorial;
