home *** CD-ROM | disk | FTP | other *** search
/ PC World 2006 February / PCWorld_2006-02_cd.bin / software / vyzkuste / triky / triky.exe / autoit-v3-setup.exe / Examples / dice.au3 < prev    next >
Text File  |  2005-01-19  |  4KB  |  91 lines

  1. ; autoit version: 3.0
  2. ; language:       English
  3. ; author:         Larry Bailey
  4. ; email:          psichosis@tvn.net
  5. ; Date: November 15, 2004
  6. ;
  7. ; Script Function
  8. ; Creates a GUI based dice rolling program
  9. ; using the Random function
  10.  
  11. #include <GUIConstants.au3>
  12.  
  13. GUICreate("Dice Roller", 265, 150, -1, -1)
  14.  
  15. $button1= GUICtrlCreateButton("D2", 5, 25, 50, 30)
  16. $button2= GUICtrlCreateButton("D3", 65, 25, 50, 30)
  17. $button3= GUICtrlCreateButton("D4", 125, 25, 50, 30)
  18. $button4= GUICtrlCreateButton("D6", 5, 65, 50, 30)
  19. $button5= GUICtrlCreateButton("D8", 65, 65, 50, 30)
  20. $button6= GUICtrlCreateButton("D10", 125, 65, 50, 30)
  21. $button7= GUICtrlCreateButton("D12", 5, 105, 50, 30)
  22. $button8= GUICtrlCreateButton("D20", 65, 105, 50, 30)
  23. $button9= GUICtrlCreateButton("D100", 125, 105, 50, 30)
  24. $button10= GUICtrlCreateButton("Clear Dice", 185, 105, 65, 30) 
  25. $output = GUICtrlCreateLabel("", 185, 45, 70, 50, 0x1000)
  26. $die = GUICtrlCreateLabel("", 185, 25, 70, 20, 0x1000)
  27. GUICtrlSetFont($output, 24, 800, "", "Comic Sans MS")
  28.  
  29. GuiSetState ()
  30.  
  31. ; Run the GUI until the dialog is closed
  32. While 1
  33.     $msg = GUIGetMsg()
  34.        Select
  35.          Case $msg = $button1
  36.              $results = Random(1,2, 1)
  37.              $results = "  " & $results
  38.              GUICtrlSetData($output, $results)
  39.              GUICtrlSetData($die, "2 Sided Die")
  40.          Case $msg = $button2
  41.              $results = Random(1,4)
  42.              $results = Int($results)
  43.              $results = "  " & $results
  44.              GUICtrlSetData($output, $results)
  45.              GUICtrlSetData($die, "3 Sided Die")
  46.           Case $msg = $button3
  47.              $results = Random(1,4, 1)
  48.              $results = "  " & $results
  49.              GUICtrlSetData($output, $results)
  50.              GUICtrlSetData($die, "4 Sided Die")
  51.          Case $msg = $button4
  52.              $results = Random(1,6, 1)
  53.              $results = "  " & $results
  54.              GUICtrlSetData($output, $results)
  55.              GUICtrlSetData($die, "6 Sided Die")
  56.          Case $msg = $button5
  57.              $results = Random(1,8)
  58.              $results = "  " & $results
  59.              GUICtrlSetData($output, $results)
  60.              GUICtrlSetData($die, "8 Sided Die")
  61.          Case $msg = $button6
  62.              $results = Random(1,10, 1)
  63.                 If $results < 10 Then $results = "  " & $results
  64.                    If $results > 9 Then $results = " " & $results
  65.              GUICtrlSetData($output, $results)
  66.              GUICtrlSetData($die, "10 Sided Die")
  67.          Case $msg = $button7
  68.              $results = Random(1,12, 1)
  69.                 If $results < 10 Then $results = "  " & $results
  70.                    If $results > 9 Then $results = " " & $results
  71.             GUICtrlSetData($output, $results)
  72.             GUICtrlSetData($die, "12 Sided Die")
  73.          Case $msg = $button8
  74.             $results = Random(1,20, 1)
  75.                If $results < 10 Then $results = "  " & $results
  76.                   If $results > 9 Then $results = " " & $results
  77.              GUICtrlSetData($output, $results)
  78.              GUICtrlSetData($die, "20 Sided Die")
  79.          Case $msg = $button9
  80.              $results = Random(1,100, 1)
  81.                 If $results <10 Then $results = "  " & $results
  82.                    If $results > 9 and $results < 100 Then $results = " " & $results
  83.              GUICtrlSetData($output, $results)
  84.              GUICtrlSetData($die, "100 Sided Die")
  85.           Case $msg = $button10
  86.              GUICtrlSetData($output, "")
  87.              GUICtrlSetData($die, "")
  88.       EndSelect
  89.    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
  90. Wend
  91.