Announcement

Collapse
No announcement yet.

help with lotto app

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • help with lotto app

    Greetings to all forum members!

    I got a lotto app (created by Dermot), but i cant understand some of the parts?

    Code:
    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

    My problem is I don't know how this part means:
    Code:
    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
    Can any member help me , please?
    Thank you for reading my request!

  • #2
    Without fully looking at the apz it looks like this section loops 7 times to get or build up the numbers, I think it would be better if you explained what you would like to do with the example and also take some time understanding the help file, don't hope we will do it all for you, we help you learn not do your work

    But yes read the help file look up the functions he had used, but from what I can see its so kind of loop to generate the numbers.
    Plugins or Sources MokoX
    BunnyHop 2021 Here

    Comment


    • #3
      thank you kingzooly for the reply!

      I am trying to make a full lotto app, for all countries!
      I created by using help, the whole coding!
      All images and layout design are already done!
      i have already progress around 45% of project!

      My problem , i needed a lotto list generator, that's why i search and got the lotto app by dermot.
      I read the code, but i got confuse in the loop code and generating (mention in first post).

      So, now i think i will rather use my own coding and recreate a generator!

      anyway, if anyone want the lotto , i added in the attachment.

      Thank you!
      Attached Files

      Comment


      • #4
        I not sure what you mean by lotto list, you wanting to create some numbers I get that, do you mean because some places use different amount of numbers?

        Sorry I just trying to understand what your trying to do a little better I will look at this apz little later see what its doing.
        Plugins or Sources MokoX
        BunnyHop 2021 Here

        Comment


        • #5
          by lotto list, i mean:
          if you open that lotto apz, you will see it can generate any amount of lotto numbers!
          then me, i want to use the same way, but for different lotto system (that is one generator for each lotto (i got around 40 different lotto).

          the part that result the lotto is my problem. (i don't understand very well)

          note:
          i am a newbie in lua, so an advise is good for me! keep me moving forward!

          check my apps at http://iyouvirajnikesh.blogspot.com/

          Comment


          • #6
            Originally posted by Youviraj View Post
            by lotto list, i mean:
            if you open that lotto apz, you will see it can generate any amount of lotto numbers!
            then me, i want to use the same way, but for different lotto system (that is one generator for each lotto (i got around 40 different lotto).

            the part that result the lotto is my problem. (i don't understand very well)

            note:
            i am a newbie in lua, so an advise is good for me! keep me moving forward!

            check my apps at http://iyouvirajnikesh.blogspot.com/
            I would never use a app for lotto well I don't gamble so I don't really know lol but let me get this right.

            So you want to generate the lotto numbers and then list them but you want to do it more then once right? like 40 times.
            Plugins or Sources MokoX
            BunnyHop 2021 Here

            Comment


            • #7
              ok, thank you, i think, i will use my own coding!

              Comment


              • #8
                Originally posted by Youviraj View Post
                ok, thank you, i think, i will use my own coding!
                That's aways a good idea so you know what your doing and you know what you code is doing.

                Good luck with the project.
                Plugins or Sources MokoX
                BunnyHop 2021 Here

                Comment

                Working...
                X