Página 1 de 1

Lotto 6/49 Generator help

Publicado: 07 Sep 2013 17:00
por Aikospiral
Greetings!
I have this lotto app but i can't understand the part to check for lotto number in comparison?

Download link of lotto project:
http://www25.zippyshare.com/v/18513619/file.html
Lotto 6/49 project created by Dermot (AMS Forum member)

the code:

Código: Seleccionar todo

Paragraph.SetText("Paragraph1", "Generating numbers. . .");

LottoNum = ""
CurPlay = ""


NumPlays = Input.GetText("Plays") + 1

StatusDlg.SetMeterRange(0,(NumPlays - 1));
StatusDlg.Show(0, false);

W1 = Input.GetText("Winner1")
W2 = Input.GetText("Winner2")
W3 = Input.GetText("Winner3")
W4 = Input.GetText("Winner4")
W5 = Input.GetText("Winner5")
W6 = Input.GetText("Winner6")

Winners = {W1,W2,W3,W4,W5,W6}

if NumPlays > 2001 then
	result = Dialog.Message("Notice", "Must be less than 2000", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
else

PlaysInHistory = PlaysInHistory + (NumPlays - 1)

-- A while loop
y = 1
while (y < NumPlays) do
x = 1;
Nums = {"01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32","33","34","35","36","37","38","39","40","41","42","43","44","45","46","47","48","49"}
Score = 0

while (x < 7) do
	p = 1	
	z = Math.Random(1, Table.Count(Nums));
	result = Nums[z];
	--result2 = Dialog.Message("Notice", result.." - "..Table.Count(Nums), MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
		while (p < 7) do
			if result == Winners[p] then
				Score = Score + 1
			end
			p = p + 1
		end
		if (x == 6) then
			CurPlay = CurPlay..result.."\r\n"
			if Score == 4 then
				LottoNum = LottoNum..result.." - ("..Score.."//6)*\r\n"
				Win4 = Win4 + 1
				Wins4 = Wins4..CurPlay
			elseif Score == 5 then
				LottoNum = LottoNum..result.." - ("..Score.."//6)-\r\n"
				Win5 = Win5 + 1
				Wins5 = Wins5..CurPlay
			elseif Score == 6 then
				LottoNum = LottoNum..result.." - ("..Score.."//6)X\r\n"
				Win6 = Win6 + 1
				Wins6 = Wins6..CurPlay
			else
				LottoNum = LottoNum..result.." - ("..Score.."//6)\r\n"
			end

		else
			LottoNum = LottoNum..result.." | "
			CurPlay = CurPlay..result.." | "
		end
		
	--Paragraph.SetText("Paragraph1", LottoNum);
	
	x = x + 1
	--result2 = Dialog.Message("Notice", x, MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
	Table.Remove(Nums, z)
end

StatusDlg.SetTitle("Generating Number . . . "..y);
StatusDlg.SetMessage("Generating Lotto Numbers . . .");
StatusDlg.SetMeterPos(y);

CurPlay = ""
y = y + 1
--result = Dialog.Message("Notice", "Y = "..y, MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
end

--result = Dialog.Message("Notice", LottoNum, MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
Paragraph.SetText("Paragraph1", LottoNum);

NumHistory = NumHistory..LottoNum

StatusDlg.Hide();
end
I don't understand this part:

Código: Seleccionar todo

while (x < 7) do
	p = 1	
	z = Math.Random(1, Table.Count(Nums));
	result = Nums[z];
	--result2 = Dialog.Message("Notice", result.." - "..Table.Count(Nums), MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
		while (p < 7) do
			if result == Winners[p] then
				Score = Score + 1
			end
			p = p + 1
		end
		if (x == 6) then
			CurPlay = CurPlay..result.."\r\n"
			if Score == 4 then
				LottoNum = LottoNum..result.." - ("..Score.."//6)*\r\n"
				Win4 = Win4 + 1
				Wins4 = Wins4..CurPlay
			elseif Score == 5 then
				LottoNum = LottoNum..result.." - ("..Score.."//6)-\r\n"
				Win5 = Win5 + 1
				Wins5 = Wins5..CurPlay
			elseif Score == 6 then
				LottoNum = LottoNum..result.." - ("..Score.."//6)X\r\n"
				Win6 = Win6 + 1
				Wins6 = Wins6..CurPlay
			else
				LottoNum = LottoNum..result.." - ("..Score.."//6)\r\n"
			end

		else
			LottoNum = LottoNum..result.." | "
			CurPlay = CurPlay..result.." | "
		end
		
	--Paragraph.SetText("Paragraph1", LottoNum);
	
	x = x + 1
	--result2 = Dialog.Message("Notice", x, MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
	Table.Remove(Nums, z)
end
Can anyone help me in understanding how this part above work?

Thank you for reading my request!