MZ An in-game lottery system... and a sad story

Fast-learning noob here. I'm contributing this because of 1) the amount of work it took, and 2) because of the amount of invaluable help this forum has been to my development. I started learning RMMZ a little over two weeks ago, and have learned a staggering amount from lurking here.

As part of a game I'm making for my kids, I designed a very simple five-number lottery system. Buy a ticket, pick five numbers, and win big or lose a little. Winnings are scaled depending on how many correct numbers are picked.

Minor complications I overcame included:
1. Not being able to pick the same number twice
2. Not being able to pick zero
3. The sheer amount of work that went into writing it (probably five or six hours)
4. The fact I'm still learning

The lottery script relies on the following variables, in exactly these locations:
Spoiler: Variable names and locations
lotto variables.png

The event code can be copy-pasted below. It's not rocket surgery level stuff, but I'm proud of it.

Spoiler: TheDadGamer's lotto code
Code:
◆Control Variables:#0010 HowManyWinningNumbers = 0
◆Control Variables:#0016 draw1 = 0
◆Control Variables:#0017 draw2 = 0
◆Control Variables:#0018 draw3 = 0
◆Control Variables:#0019 draw4 = 0
◆Control Variables:#0020 draw5 = 0
◆Text:Joe, SF_Actor3(6), Dim, Bottom
:    :Welcome to Lucky Lotto. Tickets are $15.
:    :Would you like to buy a ticket?
◆Show Choices:Yes, No (Window, Right, #1, #2)
:When Yes
  ◆If:Gold < 15
    ◆Text:Joe, SF_Actor3(6), Dim, Bottom
    :    :I'm sorry, you don't have enough
    :    :dollarydoos.
    ◆Jump to Label:ENDLOTTO
    ◆
  :Else
    ◆Change Gold:- 15
    ◆Text:Joe, SF_Actor3(6), Dim, Bottom
    :    :Excellent. Please pick five numbers.
    :    :The lottery is about to start.
    ◆Comment:This is where the numbers are picked
    ◆Label:Number 1
    ◆Input Number:1, 1 digit
    ◆If:1 = 0
      ◆Text:Joe, SF_Actor3(6), Dim, Bottom
      :    :I'm sorry, the dev sucks and we don't have
      :    :balls that are numbered zero.
      ◆Jump to Label:Number 1
      ◆
    :End
    ◆Label:Number 2
    ◆Input Number:2, 1 digit
    ◆If:2 = 0
      ◆Text:Joe, SF_Actor3(6), Dim, Bottom
      :    :I'm sorry, the dev sucks and we don't have
      :    :balls that are numbered zero.
      ◆Jump to Label:Number 2
      ◆
    :End
    ◆If:2 = 1
      ◆Text:Joe, SF_Actor3(6), Dim, Bottom
      :    :You've already picked that number
      ◆Jump to Label:Number 2
      ◆
    :End
    ◆Label:Number 3
    ◆Input Number:3, 1 digit
    ◆If:3 = 0
      ◆Text:Joe, SF_Actor3(6), Dim, Bottom
      :    :I'm sorry, the dev sucks and we don't have
      :    :balls that are numbered zero.
      ◆Jump to Label:Number 3
      ◆
    :End
    ◆If:3 = 1
      ◆Text:Joe, SF_Actor3(6), Dim, Bottom
      :    :You've already picked that number
      ◆Jump to Label:Number 3
      ◆
    :End
    ◆If:3 = 2
      ◆Text:Joe, SF_Actor3(6), Dim, Bottom
      :    :You've already picked that number
      ◆Jump to Label:Number 3
      ◆
    :End
    ◆Label:Number 4
    ◆Input Number:4, 1 digit
    ◆If:4 = 0
      ◆Text:Joe, SF_Actor3(6), Dim, Bottom
      :    :I'm sorry, the dev sucks and we don't have
      :    :balls that are numbered zero.
      ◆Jump to Label:Number 4
      ◆
    :End
    ◆If:4 = 1
      ◆Text:Joe, SF_Actor3(6), Dim, Bottom
      :    :You've already picked that number
      ◆Jump to Label:Number 4
      ◆
    :End
    ◆If:4 = 2
      ◆Text:Joe, SF_Actor3(6), Dim, Bottom
      :    :You've already picked that number
      ◆Jump to Label:Number 4
      ◆
    :End
    ◆If:4 = 3
      ◆Text:Joe, SF_Actor3(6), Dim, Bottom
      :    :You've already picked that number
      ◆Jump to Label:Number 4
      ◆
    :End
    ◆Label:Number 5
    ◆Input Number:5, 1 digit
    ◆If:5 = 0
      ◆Text:Joe, SF_Actor3(6), Dim, Bottom
      :    :I'm sorry, the dev sucks and we don't have
      :    :balls that are numbered zero.
      ◆Jump to Label:Number 5
      ◆
    :End
    ◆If:5 = 1
      ◆Text:Joe, SF_Actor3(6), Dim, Bottom
      :    :You've already picked that number
      ◆Jump to Label:Number 5
      ◆
    :End
    ◆If:5 = 2
      ◆Text:Joe, SF_Actor3(6), Dim, Bottom
      :    :You've already picked that number
      ◆Jump to Label:Number 5
      ◆
    :End
    ◆If:5 = 3
      ◆Text:Joe, SF_Actor3(6), Dim, Bottom
      :    :You've already picked that number
      ◆Jump to Label:Number 5
      ◆
    :End
    ◆If:5 = 4
      ◆Text:Joe, SF_Actor3(6), Dim, Bottom
      :    :You've already picked that number
      ◆Jump to Label:Number 5
      ◆
    :End
    ◆Text:Joe, SF_Actor3(6), Dim, Bottom
    :    :Thank you. The lotto is being drawn now!
    ◆Wait:60 frames
    ◆Comment:this is where the numbers are drawn:
    ◆Label:BALL 1
    ◆Control Variables:#0016 draw1 = Math.randomInt(8) + 1
    ◆Label:BALL 2
    ◆Control Variables:#0017 draw2 = Math.randomInt(8) + 1
    ◆If:draw2 = draw1
      ◆Jump to Label:BALL 2
      ◆
    :End
    ◆Label:BALL 3
    ◆Control Variables:#0018 draw3 = Math.randomInt(8) + 1
    ◆If:draw3 = draw1
      ◆Jump to Label:BALL 3
      ◆
    :End
    ◆If:draw3 = draw2
      ◆Jump to Label:BALL 3
      ◆
    :End
    ◆Label:BALL 4
    ◆Control Variables:#0019 draw4 = Math.randomInt(8) + 1
    ◆If:draw4 = draw1
      ◆Jump to Label:BALL 4
      ◆
    :End
    ◆If:draw4 = draw2
      ◆Jump to Label:BALL 4
      ◆
    :End
    ◆If:draw4 = draw3
      ◆Jump to Label:BALL 4
      ◆
    :End
    ◆Label:BALL 5
    ◆Control Variables:#0020 draw5 = Math.randomInt(8) + 1
    ◆If:draw5 = draw1
      ◆Jump to Label:BALL 5
      ◆
    :End
    ◆If:draw5 = draw2
      ◆Jump to Label:BALL 5
      ◆
    :End
    ◆If:draw5 = draw3
      ◆Jump to Label:BALL 5
      ◆
    :End
    ◆If:draw5 = draw4
      ◆Jump to Label:BALL 5
      ◆
    :End
    ◆
  :End
  ◆Comment:This is where the winning numbers are announced
  ◆Text:Joe, SF_Actor3(6), Dim, Bottom
  :    :And here are the winning numbers...
  ◆Text:Joe, SF_Actor3(6), Dim, Bottom
  :    :\v[0016]  \v[0017]  \v[0018]  \v[0019]  \v[0020]
  ◆Comment:This is where the balls are matched against the lotto ticket
  ◆If:1 = draw1
    ◆Control Variables:#0010 HowManyWinningNumbers += 1
    ◆
  :End
  ◆If:1 = draw2
    ◆Control Variables:#0010 HowManyWinningNumbers += 1
    ◆
  :End
  ◆If:1 = draw3
    ◆Control Variables:#0010 HowManyWinningNumbers += 1
    ◆
  :End
  ◆If:1 = draw4
    ◆Control Variables:#0010 HowManyWinningNumbers += 1
    ◆
  :End
  ◆If:1 = draw5
    ◆Control Variables:#0010 HowManyWinningNumbers += 1
    ◆
  :End
  ◆If:2 = draw1
    ◆Control Variables:#0010 HowManyWinningNumbers += 1
    ◆
  :End
  ◆If:2 = draw2
    ◆Control Variables:#0010 HowManyWinningNumbers += 1
    ◆
  :End
  ◆If:2 = draw3
    ◆Control Variables:#0010 HowManyWinningNumbers += 1
    ◆
  :End
  ◆If:2 = draw4
    ◆Control Variables:#0010 HowManyWinningNumbers += 1
    ◆
  :End
  ◆If:2 = draw5
    ◆Control Variables:#0010 HowManyWinningNumbers += 1
    ◆
  :End
  ◆If:3 = draw1
    ◆Control Variables:#0010 HowManyWinningNumbers += 1
    ◆
  :End
  ◆If:3 = draw2
    ◆Control Variables:#0010 HowManyWinningNumbers += 1
    ◆
  :End
  ◆If:3 = draw3
    ◆Control Variables:#0010 HowManyWinningNumbers += 1
    ◆
  :End
  ◆If:3 = draw4
    ◆Control Variables:#0010 HowManyWinningNumbers += 1
    ◆
  :End
  ◆If:3 = draw5
    ◆Control Variables:#0010 HowManyWinningNumbers += 1
    ◆
  :End
  ◆If:4 = draw1
    ◆Control Variables:#0010 HowManyWinningNumbers += 1
    ◆
  :End
  ◆If:4 = draw2
    ◆Control Variables:#0010 HowManyWinningNumbers += 1
    ◆
  :End
  ◆If:4 = draw3
    ◆Control Variables:#0010 HowManyWinningNumbers += 1
    ◆
  :End
  ◆If:4 = draw4
    ◆Control Variables:#0010 HowManyWinningNumbers += 1
    ◆
  :End
  ◆If:4 = draw5
    ◆Control Variables:#0010 HowManyWinningNumbers += 1
    ◆
  :End
  ◆If:5 = draw1
    ◆Control Variables:#0010 HowManyWinningNumbers += 1
    ◆
  :End
  ◆If:5 = draw2
    ◆Control Variables:#0010 HowManyWinningNumbers += 1
    ◆
  :End
  ◆If:5 = draw3
    ◆Control Variables:#0010 HowManyWinningNumbers += 1
    ◆
  :End
  ◆If:5 = draw4
    ◆Control Variables:#0010 HowManyWinningNumbers += 1
    ◆
  :End
  ◆If:5 = draw5
    ◆Control Variables:#0010 HowManyWinningNumbers += 1
    ◆
  :End
  ◆Comment:This is where winnings are calculated
  ◆If:HowManyWinningNumbers = 1
    ◆Text:Joe, SF_Actor3(6), Dim, Bottom
    :    :Unlucky! You only got a single winning number.
    :    :Better luck next time.
    ◆
  :End
  ◆If:HowManyWinningNumbers = 2
    ◆Text:Joe, SF_Actor3(6), Dim, Bottom
    :    :Sorry kid, you only picked 2 winning numbers.
    :    :You need at least three. Better luck next time.
    ◆
  :End
  ◆If:HowManyWinningNumbers = 3
    ◆Text:Joe, SF_Actor3(6), Dim, Bottom
    :    :Not bad. You got \v[0010] winning numbers.
    :    :You won 20 dollarydoos.
    ◆Change Gold:+ 20
    ◆
  :End
  ◆If:HowManyWinningNumbers = 4
    ◆Text:Joe, SF_Actor3(6), Dim, Bottom
    :    :Whoa! You picked \v[0010] winning numbers.
    :    :Here's your winnings - 100 dollarydoos!
    ◆Change Gold:+ 100
    ◆
  :End
  ◆If:HowManyWinningNumbers = 5
    ◆Text:Joe, SF_Actor3(6), Dim, Bottom
    :    :Jackpot! You picked \v[0010] winning numbers!
    :    :You won 1000 dollarydoos!
    ◆Change Gold:+ 1000
    ◆
  :End
  ◆
:When No
  ◆Text:Joe, SF_Actor3(6), Dim, Bottom
  :    :Well thanks for wasting my time...
  ◆
:End
◆Label:ENDLOTTO

As I am Australian, I figured the most appropriate currency to use would be our national dollarydoos. If you wish to change it, you'll have to do it manually. Sorry, when I wrote the code I never thought I'd be posting it.

Advice is welcomed, particularly if there were easier ways to go about this.

The sad story...

About two weeks ago I began learning RMMZ as a complete noob while my wonderful wife and I were on what I hoped was a short hiatus. A few days ago, during the development of this game, she left me.

Over the last fortnight, learning RMMZ has kept me out of my own head and provided me an outlet. This forum has helped my development immeasurably. Sincerely, thank you to all the code wizards and starving artists who contribute here. You don't know me, but you're helping me through a very hard time. I appreciate you and I am in awe of how incredibly talented you are.

Original thread: https://forums.rpgmakerweb.com/threads/an-in-game-lottery-system-and-a-sad-story.174660/