litlmike Posted July 6, 2006 Share Posted July 6, 2006 Attached below is the full script to download/view. The GUI keeps a running total of Dice Rolls when the user clicks on a button. Also, it calculates the percentage of the numbers rolled. What I can't figure out, is how to tell the script to create the label for 'Actual' percentage and 'Deviant' Percentage, underneath the button that was just clicked. So if the clicked on button '6', then what is in the Tooltip (percentage), shows beneath the button '6'. So it seems that I have to tell the script to GUICtrlCreateLabel to the proper (X,Y) coordinates. If you download and run the entire script it should make sense. Because you can see where the 'Actual' and 'Deviant' should appear, because I put some place markers there for reference. Thanks in advance. expandcollapse popup#include <GUIConstants.au3> Global $r2 = 0, $r3 = 0, $r4 = 0, $r5 = 0, $r6 = 0, $r7 = 0, $r8 = 0, $r9 = 0, $r10 = 0, $r11 = 0, $r12 = 0 $y_coord_Rolls_button_Row1 = 31 $y_coord_Rolls_button_Row2 = 180 $y_coord_Rolls_Theo_Row1 = $y_coord_Rolls_button_Row1 - 20 $y_coord_Rolls_Theo_Row2 = $y_coord_Rolls_button_Row2 - 20 ;~ .028 - 2's & 12's ;~ .056 - 3's & 11's ;~ .083 - 4's & 10's ;~ .111 - 5's & 9's ;~ .139 - 6's & 8's ;~ .167 - 7's ; == GUI generated with Koda == $Form1 = GUICreate("AForm1", 618, 352, 192, 125) $Button2 = GUICtrlCreateButton("2", 8, $y_coord_Rolls_button_Row1, 75, 25) $Button3 = GUICtrlCreateButton("3", 96, $y_coord_Rolls_button_Row1, 75, 25) $Button4 = GUICtrlCreateButton("4", 184, $y_coord_Rolls_button_Row1, 75, 25) $Button5 = GUICtrlCreateButton("5", 272, $y_coord_Rolls_button_Row1, 75, 25) $Button6 = GUICtrlCreateButton("6", 360, $y_coord_Rolls_button_Row1, 75, 25) $Button7 = GUICtrlCreateButton("7", 448, $y_coord_Rolls_button_Row1, 75, 25) $Button8 = GUICtrlCreateButton("8", 8, $y_coord_Rolls_button_Row2, 75, 25) $Button9 = GUICtrlCreateButton("9", 96, $y_coord_Rolls_button_Row2, 75, 25) $Button10 = GUICtrlCreateButton("10", 184, $y_coord_Rolls_button_Row2, 75, 25) $Button11 = GUICtrlCreateButton("11", 272, $y_coord_Rolls_button_Row2, 75, 25) $Button12 = GUICtrlCreateButton("12", 360, $y_coord_Rolls_button_Row2, 75, 25) $x_coord_Rolls_Theo_Row1 = 16 $x_coord_Rolls_Theo_Row1_variance = 88 ;~ Theoretical Row 1 GUICtrlCreateLabel(".028", $x_coord_Rolls_Theo_Row1, $y_coord_Rolls_Theo_Row1, 43, 17, $SS_CENTER) $x_coord_Rolls_Theo_Row1 = $x_coord_Rolls_Theo_Row1 + $x_coord_Rolls_Theo_Row1_variance GUICtrlCreateLabel(".056",$x_coord_Rolls_Theo_Row1, $y_coord_Rolls_Theo_Row1, 43, 17, $SS_CENTER) $x_coord_Rolls_Theo_Row1 = $x_coord_Rolls_Theo_Row1 + $x_coord_Rolls_Theo_Row1_variance GUICtrlCreateLabel(".083", $x_coord_Rolls_Theo_Row1, $y_coord_Rolls_Theo_Row1, 43, 17, $SS_CENTER) $x_coord_Rolls_Theo_Row1 = $x_coord_Rolls_Theo_Row1 + $x_coord_Rolls_Theo_Row1_variance GUICtrlCreateLabel(".111", $x_coord_Rolls_Theo_Row1, $y_coord_Rolls_Theo_Row1, 43, 17, $SS_CENTER) $x_coord_Rolls_Theo_Row1 = $x_coord_Rolls_Theo_Row1 + $x_coord_Rolls_Theo_Row1_variance GUICtrlCreateLabel(".139", $x_coord_Rolls_Theo_Row1, $y_coord_Rolls_Theo_Row1, 43, 17, $SS_CENTER) $x_coord_Rolls_Theo_Row1 = $x_coord_Rolls_Theo_Row1 + $x_coord_Rolls_Theo_Row1_variance GUICtrlCreateLabel(".167", $x_coord_Rolls_Theo_Row1, $y_coord_Rolls_Theo_Row1, 43, 17, $SS_CENTER) $x_coord_Rolls_Theo_Row1 = 16 ;~ Theoretical Row 2 GUICtrlCreateLabel(".139", $x_coord_Rolls_Theo_Row1, $y_coord_Rolls_Theo_Row2, 43, 17, $SS_CENTER) $x_coord_Rolls_Theo_Row1 = $x_coord_Rolls_Theo_Row1 + $x_coord_Rolls_Theo_Row1_variance GUICtrlCreateLabel(".111", $x_coord_Rolls_Theo_Row1, $y_coord_Rolls_Theo_Row2, 43, 17, $SS_CENTER) $x_coord_Rolls_Theo_Row1 = $x_coord_Rolls_Theo_Row1 + $x_coord_Rolls_Theo_Row1_variance GUICtrlCreateLabel(".083", $x_coord_Rolls_Theo_Row1, $y_coord_Rolls_Theo_Row2, 43, 17, $SS_CENTER) $x_coord_Rolls_Theo_Row1 = $x_coord_Rolls_Theo_Row1 + $x_coord_Rolls_Theo_Row1_variance GUICtrlCreateLabel(".056", $x_coord_Rolls_Theo_Row1, $y_coord_Rolls_Theo_Row2, 43, 17, $SS_CENTER) $x_coord_Rolls_Theo_Row1 = $x_coord_Rolls_Theo_Row1 + $x_coord_Rolls_Theo_Row1_variance GUICtrlCreateLabel(".028", $x_coord_Rolls_Theo_Row1, $y_coord_Rolls_Theo_Row2, 43, 17, $SS_CENTER) ;;;;;;;;;;;;;;;;;;;;;;;;;;;Only a Place Marker;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; $x_coord_Rolls_Actual_Row1 = 16 $x_coord_Rolls_Actual_Row1_variance = 88 $y_coord_Rolls_Actual_Row1 = $y_coord_Rolls_button_Row1 + 60 $y_coord_Rolls_Actual_Row2 = $y_coord_Rolls_button_Row2 + 60 ;~ Current/Actual Row 1 GUICtrlCreateLabel("Actual", $x_coord_Rolls_Actual_Row1, $y_coord_Rolls_Actual_Row1, 43, 17, $SS_CENTER) $x_coord_Rolls_Actual_Row1 = $x_coord_Rolls_Actual_Row1 + $x_coord_Rolls_Actual_Row1_variance GUICtrlCreateLabel("Actual",$x_coord_Rolls_Actual_Row1, $y_coord_Rolls_Actual_Row1, 43, 17, $SS_CENTER) $x_coord_Rolls_Actual_Row1 = $x_coord_Rolls_Actual_Row1 + $x_coord_Rolls_Actual_Row1_variance GUICtrlCreateLabel("Actual", $x_coord_Rolls_Actual_Row1, $y_coord_Rolls_Actual_Row1, 43, 17, $SS_CENTER) $x_coord_Rolls_Actual_Row1 = $x_coord_Rolls_Actual_Row1 + $x_coord_Rolls_Actual_Row1_variance GUICtrlCreateLabel("Actual", $x_coord_Rolls_Actual_Row1, $y_coord_Rolls_Actual_Row1, 43, 17, $SS_CENTER) $x_coord_Rolls_Actual_Row1 = $x_coord_Rolls_Actual_Row1 + $x_coord_Rolls_Actual_Row1_variance GUICtrlCreateLabel("Actual", $x_coord_Rolls_Actual_Row1, $y_coord_Rolls_Actual_Row1, 43, 17, $SS_CENTER) $x_coord_Rolls_Actual_Row1 = $x_coord_Rolls_Actual_Row1 + $x_coord_Rolls_Actual_Row1_variance GUICtrlCreateLabel("Actual", $x_coord_Rolls_Actual_Row1, $y_coord_Rolls_Actual_Row1, 43, 17, $SS_CENTER) $x_coord_Rolls_Actual_Row1 = 16 ;~ Current/Actual Row 2 GUICtrlCreateLabel("Actual", $x_coord_Rolls_Actual_Row1, $y_coord_Rolls_Actual_Row2, 43, 17, $SS_CENTER) $x_coord_Rolls_Actual_Row1 = $x_coord_Rolls_Actual_Row1 + $x_coord_Rolls_Actual_Row1_variance GUICtrlCreateLabel("Actual", $x_coord_Rolls_Actual_Row1, $y_coord_Rolls_Actual_Row2, 43, 17, $SS_CENTER) $x_coord_Rolls_Actual_Row1 = $x_coord_Rolls_Actual_Row1 + $x_coord_Rolls_Actual_Row1_variance GUICtrlCreateLabel("Actual", $x_coord_Rolls_Actual_Row1, $y_coord_Rolls_Actual_Row2, 43, 17, $SS_CENTER) $x_coord_Rolls_Actual_Row1 = $x_coord_Rolls_Actual_Row1 + $x_coord_Rolls_Actual_Row1_variance GUICtrlCreateLabel("Actual", $x_coord_Rolls_Actual_Row1, $y_coord_Rolls_Actual_Row2, 43, 17, $SS_CENTER) $x_coord_Rolls_Actual_Row1 = $x_coord_Rolls_Actual_Row1 + $x_coord_Rolls_Actual_Row1_variance GUICtrlCreateLabel("Actual", $x_coord_Rolls_Actual_Row1, $y_coord_Rolls_Actual_Row2, 43, 17, $SS_CENTER) ;;;;;;;;;;;;;;;;;;;;;;;;;;;Only a Place Marker;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;Deviant $x_coord_Rolls_Deviant_Row1 = 16 $x_coord_Rolls_Deviant_Row1_variance = 88 $y_coord_Rolls_Deviant_Row1 = $y_coord_Rolls_button_Row1 + 80 $y_coord_Rolls_Deviant_Row2 = $y_coord_Rolls_button_Row2 + 80 ;~ Deviant Row 1 GUICtrlCreateLabel("Deviant", $x_coord_Rolls_Deviant_Row1, $y_coord_Rolls_Deviant_Row1, 43, 17, $SS_CENTER) $x_coord_Rolls_Deviant_Row1 = $x_coord_Rolls_Deviant_Row1 + $x_coord_Rolls_Deviant_Row1_variance GUICtrlCreateLabel("Deviant",$x_coord_Rolls_Deviant_Row1, $y_coord_Rolls_Deviant_Row1, 43, 17, $SS_CENTER) $x_coord_Rolls_Deviant_Row1 = $x_coord_Rolls_Deviant_Row1 + $x_coord_Rolls_Deviant_Row1_variance GUICtrlCreateLabel("Deviant", $x_coord_Rolls_Deviant_Row1, $y_coord_Rolls_Deviant_Row1, 43, 17, $SS_CENTER) $x_coord_Rolls_Deviant_Row1 = $x_coord_Rolls_Deviant_Row1 + $x_coord_Rolls_Deviant_Row1_variance GUICtrlCreateLabel("Deviant", $x_coord_Rolls_Deviant_Row1, $y_coord_Rolls_Deviant_Row1, 43, 17, $SS_CENTER) $x_coord_Rolls_Deviant_Row1 = $x_coord_Rolls_Deviant_Row1 + $x_coord_Rolls_Deviant_Row1_variance GUICtrlCreateLabel("Deviant", $x_coord_Rolls_Deviant_Row1, $y_coord_Rolls_Deviant_Row1, 43, 17, $SS_CENTER) $x_coord_Rolls_Deviant_Row1 = $x_coord_Rolls_Deviant_Row1 + $x_coord_Rolls_Deviant_Row1_variance GUICtrlCreateLabel("Deviant", $x_coord_Rolls_Deviant_Row1, $y_coord_Rolls_Deviant_Row1, 43, 17, $SS_CENTER) $x_coord_Rolls_Deviant_Row1 = 16 ;~ Deviant Row 2 GUICtrlCreateLabel("Deviant", $x_coord_Rolls_Deviant_Row1, $y_coord_Rolls_Deviant_Row2, 43, 17, $SS_CENTER) $x_coord_Rolls_Deviant_Row1 = $x_coord_Rolls_Deviant_Row1 + $x_coord_Rolls_Deviant_Row1_variance GUICtrlCreateLabel("Deviant", $x_coord_Rolls_Deviant_Row1, $y_coord_Rolls_Deviant_Row2, 43, 17, $SS_CENTER) $x_coord_Rolls_Deviant_Row1 = $x_coord_Rolls_Deviant_Row1 + $x_coord_Rolls_Deviant_Row1_variance GUICtrlCreateLabel("Deviant", $x_coord_Rolls_Deviant_Row1, $y_coord_Rolls_Deviant_Row2, 43, 17, $SS_CENTER) $x_coord_Rolls_Deviant_Row1 = $x_coord_Rolls_Deviant_Row1 + $x_coord_Rolls_Deviant_Row1_variance GUICtrlCreateLabel("Deviant", $x_coord_Rolls_Deviant_Row1, $y_coord_Rolls_Deviant_Row2, 43, 17, $SS_CENTER) $x_coord_Rolls_Deviant_Row1 = $x_coord_Rolls_Deviant_Row1 + $x_coord_Rolls_Deviant_Row1_variance GUICtrlCreateLabel("Deviant", $x_coord_Rolls_Deviant_Row1, $y_coord_Rolls_Deviant_Row2, 43, 17, $SS_CENTER) GUISetState(@SW_SHOW) $y_coord_Rolls_label_Row1 = $y_coord_Rolls_button_Row1 + 35 $y_coord_Rolls_label_Row2 = $y_coord_Rolls_button_Row2 + 35 $x_coord_Count_initial = 24 $x_coord_Count_variance = 88 While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button2 $r2 = $r2 + 1 GUICtrlCreateLabel($r2, 24, $y_coord_Rolls_label_Row1, 43, 17, $SS_CENTER) Calculate_Percentages ($r2) Case $msg = $Button3 $r3 = $r3 + 1 GUICtrlCreateLabel($r3, 112, $y_coord_Rolls_label_Row1, 43, 17, $SS_CENTER) Calculate_Percentages ($r3) Case $msg = $Button4 $r4 = $r4 + 1 GUICtrlCreateLabel($r4, 200, $y_coord_Rolls_label_Row1, 43, 17, $SS_CENTER) Calculate_Percentages ($r4) Case $msg = $Button5 $r5 = $r5 + 1 GUICtrlCreateLabel($r5, 288, $y_coord_Rolls_label_Row1, 43, 17, $SS_CENTER) Calculate_Percentages ($r5) Case $msg = $Button6 $r6 = $r6 + 1 GUICtrlCreateLabel($r6, 376, $y_coord_Rolls_label_Row1, 43, 17, $SS_CENTER) Calculate_Percentages ($r6) Case $msg = $Button7 $r7 = $r7 + 1 GUICtrlCreateLabel($r7, 464, $y_coord_Rolls_label_Row1, 43, 17, $SS_CENTER) Calculate_Percentages ($r7) Case $msg = $Button8 $r8 = $r8 + 1 GUICtrlCreateLabel($r8, 24, $y_coord_Rolls_label_Row2, 43, 17, $SS_CENTER) Calculate_Percentages ($r8) Case $msg = $Button9 $r9 = $r9 + 1 GUICtrlCreateLabel($r9, 112, $y_coord_Rolls_label_Row2, 43, 17, $SS_CENTER) Calculate_Percentages ($r9) Case $msg = $Button10 $r10 = $r10 + 1 GUICtrlCreateLabel($r10, 200, $y_coord_Rolls_label_Row2, 43, 17, $SS_CENTER) Calculate_Percentages ($r10) Case $msg = $Button11 $r11 = $r11 + 1 GUICtrlCreateLabel($r11, 288, $y_coord_Rolls_label_Row2, 43, 17, $SS_CENTER) Calculate_Percentages ($r11) Case $msg = $Button12 $r12 = $r12 + 1 GUICtrlCreateLabel($r12, 368, $y_coord_Rolls_label_Row2, 43, 17, $SS_CENTER) Calculate_Percentages ($r12) EndSelect WEnd Exit Func Calculate_Percentages ($r) $total_rolls = $r2 + $r3 + $r4 + $r5 + $r6 + $r7 + $r8 + $r9 + $r10 + $r11 + $r12 $percent = $r/$total_rolls ToolTip ($percent) GUICtrlCreateLabel ($total_rolls, 448, 296, 75, 25) GUICtrlCreateLabel ($total_rolls, 448, 296, 75, 25) ;~ ToolTip ($total_rolls) ;~ GUICtrlCreateLabel ($button, 448, 156, 75, 25) ;Actual EndFunc Settlers.au3 _ArrayPermute()_ArrayUnique()Excel.au3 UDF Link to comment Share on other sites More sharing options...
Xenobiologist Posted July 6, 2006 Share Posted July 6, 2006 Hi, I don't understand the calc right noe. But I did what you want for the first two buttons, I guess. expandcollapse popup#include <GUIConstants.au3> Global $r2 = 0, $r3 = 0, $r4 = 0, $r5 = 0, $r6 = 0, $r7 = 0, $r8 = 0, $r9 = 0, $r10 = 0, $r11 = 0, $r12 = 0 $y_coord_Rolls_button_Row1 = 31 $y_coord_Rolls_button_Row2 = 180 $y_coord_Rolls_Theo_Row1 = $y_coord_Rolls_button_Row1 - 20 $y_coord_Rolls_Theo_Row2 = $y_coord_Rolls_button_Row2 - 20 ;~ .028 - 2's & 12's ;~ .056 - 3's & 11's ;~ .083 - 4's & 10's ;~ .111 - 5's & 9's ;~ .139 - 6's & 8's ;~ .167 - 7's ; == GUI generated with Koda == $Form1 = GUICreate("AForm1", 618, 352, 192, 125) $Button2 = GUICtrlCreateButton("2", 8, $y_coord_Rolls_button_Row1, 75, 25) $Button3 = GUICtrlCreateButton("3", 96, $y_coord_Rolls_button_Row1, 75, 25) $Button4 = GUICtrlCreateButton("4", 184, $y_coord_Rolls_button_Row1, 75, 25) $Button5 = GUICtrlCreateButton("5", 272, $y_coord_Rolls_button_Row1, 75, 25) $Button6 = GUICtrlCreateButton("6", 360, $y_coord_Rolls_button_Row1, 75, 25) $Button7 = GUICtrlCreateButton("7", 448, $y_coord_Rolls_button_Row1, 75, 25) $Button8 = GUICtrlCreateButton("8", 8, $y_coord_Rolls_button_Row2, 75, 25) $Button9 = GUICtrlCreateButton("9", 96, $y_coord_Rolls_button_Row2, 75, 25) $Button10 = GUICtrlCreateButton("10", 184, $y_coord_Rolls_button_Row2, 75, 25) $Button11 = GUICtrlCreateButton("11", 272, $y_coord_Rolls_button_Row2, 75, 25) $Button12 = GUICtrlCreateButton("12", 360, $y_coord_Rolls_button_Row2, 75, 25) $x_coord_Rolls_Theo_Row1 = 16 $x_coord_Rolls_Theo_Row1_variance = 88 ;~ Theoretical Row 1 GUICtrlCreateLabel(".028", $x_coord_Rolls_Theo_Row1, $y_coord_Rolls_Theo_Row1, 43, 17, $SS_CENTER) $x_coord_Rolls_Theo_Row1 = $x_coord_Rolls_Theo_Row1 + $x_coord_Rolls_Theo_Row1_variance GUICtrlCreateLabel(".056", $x_coord_Rolls_Theo_Row1, $y_coord_Rolls_Theo_Row1, 43, 17, $SS_CENTER) $x_coord_Rolls_Theo_Row1 = $x_coord_Rolls_Theo_Row1 + $x_coord_Rolls_Theo_Row1_variance GUICtrlCreateLabel(".083", $x_coord_Rolls_Theo_Row1, $y_coord_Rolls_Theo_Row1, 43, 17, $SS_CENTER) $x_coord_Rolls_Theo_Row1 = $x_coord_Rolls_Theo_Row1 + $x_coord_Rolls_Theo_Row1_variance GUICtrlCreateLabel(".111", $x_coord_Rolls_Theo_Row1, $y_coord_Rolls_Theo_Row1, 43, 17, $SS_CENTER) $x_coord_Rolls_Theo_Row1 = $x_coord_Rolls_Theo_Row1 + $x_coord_Rolls_Theo_Row1_variance GUICtrlCreateLabel(".139", $x_coord_Rolls_Theo_Row1, $y_coord_Rolls_Theo_Row1, 43, 17, $SS_CENTER) $x_coord_Rolls_Theo_Row1 = $x_coord_Rolls_Theo_Row1 + $x_coord_Rolls_Theo_Row1_variance GUICtrlCreateLabel(".167", $x_coord_Rolls_Theo_Row1, $y_coord_Rolls_Theo_Row1, 43, 17, $SS_CENTER) $x_coord_Rolls_Theo_Row1 = 16 ;~ Theoretical Row 2 GUICtrlCreateLabel(".139", $x_coord_Rolls_Theo_Row1, $y_coord_Rolls_Theo_Row2, 43, 17, $SS_CENTER) $x_coord_Rolls_Theo_Row1 = $x_coord_Rolls_Theo_Row1 + $x_coord_Rolls_Theo_Row1_variance GUICtrlCreateLabel(".111", $x_coord_Rolls_Theo_Row1, $y_coord_Rolls_Theo_Row2, 43, 17, $SS_CENTER) $x_coord_Rolls_Theo_Row1 = $x_coord_Rolls_Theo_Row1 + $x_coord_Rolls_Theo_Row1_variance GUICtrlCreateLabel(".083", $x_coord_Rolls_Theo_Row1, $y_coord_Rolls_Theo_Row2, 43, 17, $SS_CENTER) $x_coord_Rolls_Theo_Row1 = $x_coord_Rolls_Theo_Row1 + $x_coord_Rolls_Theo_Row1_variance GUICtrlCreateLabel(".056", $x_coord_Rolls_Theo_Row1, $y_coord_Rolls_Theo_Row2, 43, 17, $SS_CENTER) $x_coord_Rolls_Theo_Row1 = $x_coord_Rolls_Theo_Row1 + $x_coord_Rolls_Theo_Row1_variance GUICtrlCreateLabel(".028", $x_coord_Rolls_Theo_Row1, $y_coord_Rolls_Theo_Row2, 43, 17, $SS_CENTER) ;;;;;;;;;;;;;;;;;;;;;;;;;;;Only a Place Marker;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; $x_coord_Rolls_Actual_Row1 = 16 $x_coord_Rolls_Actual_Row1_variance = 88 $y_coord_Rolls_Actual_Row1 = $y_coord_Rolls_button_Row1 + 60 $y_coord_Rolls_Actual_Row2 = $y_coord_Rolls_button_Row2 + 60 ;~ Current/Actual Row 1 $2 = GUICtrlCreateLabel("Actual", $x_coord_Rolls_Actual_Row1, $y_coord_Rolls_Actual_Row1, 43, 17, $SS_CENTER) $x_coord_Rolls_Actual_Row1 = $x_coord_Rolls_Actual_Row1 + $x_coord_Rolls_Actual_Row1_variance $3 = GUICtrlCreateLabel("Actual", $x_coord_Rolls_Actual_Row1, $y_coord_Rolls_Actual_Row1, 43, 17, $SS_CENTER) $x_coord_Rolls_Actual_Row1 = $x_coord_Rolls_Actual_Row1 + $x_coord_Rolls_Actual_Row1_variance $4 = GUICtrlCreateLabel("Actual", $x_coord_Rolls_Actual_Row1, $y_coord_Rolls_Actual_Row1, 43, 17, $SS_CENTER) $x_coord_Rolls_Actual_Row1 = $x_coord_Rolls_Actual_Row1 + $x_coord_Rolls_Actual_Row1_variance $5 = GUICtrlCreateLabel("Actual", $x_coord_Rolls_Actual_Row1, $y_coord_Rolls_Actual_Row1, 43, 17, $SS_CENTER) $x_coord_Rolls_Actual_Row1 = $x_coord_Rolls_Actual_Row1 + $x_coord_Rolls_Actual_Row1_variance $6 = GUICtrlCreateLabel("Actual", $x_coord_Rolls_Actual_Row1, $y_coord_Rolls_Actual_Row1, 43, 17, $SS_CENTER) $x_coord_Rolls_Actual_Row1 = $x_coord_Rolls_Actual_Row1 + $x_coord_Rolls_Actual_Row1_variance $7 = GUICtrlCreateLabel("Actual", $x_coord_Rolls_Actual_Row1, $y_coord_Rolls_Actual_Row1, 43, 17, $SS_CENTER) $x_coord_Rolls_Actual_Row1 = 16 ;~ Current/Actual Row 2 $8 = GUICtrlCreateLabel("Actual", $x_coord_Rolls_Actual_Row1, $y_coord_Rolls_Actual_Row2, 43, 17, $SS_CENTER) $x_coord_Rolls_Actual_Row1 = $x_coord_Rolls_Actual_Row1 + $x_coord_Rolls_Actual_Row1_variance $9 = GUICtrlCreateLabel("Actual", $x_coord_Rolls_Actual_Row1, $y_coord_Rolls_Actual_Row2, 43, 17, $SS_CENTER) $x_coord_Rolls_Actual_Row1 = $x_coord_Rolls_Actual_Row1 + $x_coord_Rolls_Actual_Row1_variance $10 = GUICtrlCreateLabel("Actual", $x_coord_Rolls_Actual_Row1, $y_coord_Rolls_Actual_Row2, 43, 17, $SS_CENTER) $x_coord_Rolls_Actual_Row1 = $x_coord_Rolls_Actual_Row1 + $x_coord_Rolls_Actual_Row1_variance $11 = GUICtrlCreateLabel("Actual", $x_coord_Rolls_Actual_Row1, $y_coord_Rolls_Actual_Row2, 43, 17, $SS_CENTER) $x_coord_Rolls_Actual_Row1 = $x_coord_Rolls_Actual_Row1 + $x_coord_Rolls_Actual_Row1_variance $12 = GUICtrlCreateLabel("Actual", $x_coord_Rolls_Actual_Row1, $y_coord_Rolls_Actual_Row2, 43, 17, $SS_CENTER) ;;;;;;;;;;;;;;;;;;;;;;;;;;;Only a Place Marker;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;Deviant $x_coord_Rolls_Deviant_Row1 = 16 $x_coord_Rolls_Deviant_Row1_variance = 88 $y_coord_Rolls_Deviant_Row1 = $y_coord_Rolls_button_Row1 + 80 $y_coord_Rolls_Deviant_Row2 = $y_coord_Rolls_button_Row2 + 80 ;~ Deviant Row 1 GUICtrlCreateLabel("Deviant", $x_coord_Rolls_Deviant_Row1, $y_coord_Rolls_Deviant_Row1, 43, 17, $SS_CENTER) $x_coord_Rolls_Deviant_Row1 = $x_coord_Rolls_Deviant_Row1 + $x_coord_Rolls_Deviant_Row1_variance GUICtrlCreateLabel("Deviant", $x_coord_Rolls_Deviant_Row1, $y_coord_Rolls_Deviant_Row1, 43, 17, $SS_CENTER) $x_coord_Rolls_Deviant_Row1 = $x_coord_Rolls_Deviant_Row1 + $x_coord_Rolls_Deviant_Row1_variance GUICtrlCreateLabel("Deviant", $x_coord_Rolls_Deviant_Row1, $y_coord_Rolls_Deviant_Row1, 43, 17, $SS_CENTER) $x_coord_Rolls_Deviant_Row1 = $x_coord_Rolls_Deviant_Row1 + $x_coord_Rolls_Deviant_Row1_variance GUICtrlCreateLabel("Deviant", $x_coord_Rolls_Deviant_Row1, $y_coord_Rolls_Deviant_Row1, 43, 17, $SS_CENTER) $x_coord_Rolls_Deviant_Row1 = $x_coord_Rolls_Deviant_Row1 + $x_coord_Rolls_Deviant_Row1_variance GUICtrlCreateLabel("Deviant", $x_coord_Rolls_Deviant_Row1, $y_coord_Rolls_Deviant_Row1, 43, 17, $SS_CENTER) $x_coord_Rolls_Deviant_Row1 = $x_coord_Rolls_Deviant_Row1 + $x_coord_Rolls_Deviant_Row1_variance GUICtrlCreateLabel("Deviant", $x_coord_Rolls_Deviant_Row1, $y_coord_Rolls_Deviant_Row1, 43, 17, $SS_CENTER) $x_coord_Rolls_Deviant_Row1 = 16 ;~ Deviant Row 2 GUICtrlCreateLabel("Deviant", $x_coord_Rolls_Deviant_Row1, $y_coord_Rolls_Deviant_Row2, 43, 17, $SS_CENTER) $x_coord_Rolls_Deviant_Row1 = $x_coord_Rolls_Deviant_Row1 + $x_coord_Rolls_Deviant_Row1_variance GUICtrlCreateLabel("Deviant", $x_coord_Rolls_Deviant_Row1, $y_coord_Rolls_Deviant_Row2, 43, 17, $SS_CENTER) $x_coord_Rolls_Deviant_Row1 = $x_coord_Rolls_Deviant_Row1 + $x_coord_Rolls_Deviant_Row1_variance GUICtrlCreateLabel("Deviant", $x_coord_Rolls_Deviant_Row1, $y_coord_Rolls_Deviant_Row2, 43, 17, $SS_CENTER) $x_coord_Rolls_Deviant_Row1 = $x_coord_Rolls_Deviant_Row1 + $x_coord_Rolls_Deviant_Row1_variance GUICtrlCreateLabel("Deviant", $x_coord_Rolls_Deviant_Row1, $y_coord_Rolls_Deviant_Row2, 43, 17, $SS_CENTER) $x_coord_Rolls_Deviant_Row1 = $x_coord_Rolls_Deviant_Row1 + $x_coord_Rolls_Deviant_Row1_variance GUICtrlCreateLabel("Deviant", $x_coord_Rolls_Deviant_Row1, $y_coord_Rolls_Deviant_Row2, 43, 17, $SS_CENTER) GUISetState(@SW_SHOW) $y_coord_Rolls_label_Row1 = $y_coord_Rolls_button_Row1 + 35 $y_coord_Rolls_label_Row2 = $y_coord_Rolls_button_Row2 + 35 $x_coord_Count_initial = 24 $x_coord_Count_variance = 88 While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button2 $r2 += 1 setState() GUICtrlCreateLabel($r2, 24, $y_coord_Rolls_label_Row1, 43, 17, $SS_CENTER) GUICtrlSetData($2, Calculate_Percentages($r2)) GUICtrlSetState($2, $GUI_ENABLE) Case $msg = $Button3 $r3 +=1 setState() GUICtrlCreateLabel($r3, 112, $y_coord_Rolls_label_Row1, 43, 17, $SS_CENTER) GUICtrlSetData($3, Calculate_Percentages($r3)) GUICtrlSetState($3, $GUI_ENABLE) Case $msg = $Button4 $r4 = $r4 + 1 GUICtrlCreateLabel($r4, 200, $y_coord_Rolls_label_Row1, 43, 17, $SS_CENTER) Calculate_Percentages($r4) Case $msg = $Button5 $r5 = $r5 + 1 GUICtrlCreateLabel($r5, 288, $y_coord_Rolls_label_Row1, 43, 17, $SS_CENTER) Calculate_Percentages($r5) Case $msg = $Button6 $r6 = $r6 + 1 GUICtrlCreateLabel($r6, 376, $y_coord_Rolls_label_Row1, 43, 17, $SS_CENTER) Calculate_Percentages($r6) Case $msg = $Button7 $r7 = $r7 + 1 GUICtrlCreateLabel($r7, 464, $y_coord_Rolls_label_Row1, 43, 17, $SS_CENTER) Calculate_Percentages($r7) Case $msg = $Button8 $r8 = $r8 + 1 GUICtrlCreateLabel($r8, 24, $y_coord_Rolls_label_Row2, 43, 17, $SS_CENTER) Calculate_Percentages($r8) Case $msg = $Button9 $r9 = $r9 + 1 GUICtrlCreateLabel($r9, 112, $y_coord_Rolls_label_Row2, 43, 17, $SS_CENTER) Calculate_Percentages($r9) Case $msg = $Button10 $r10 = $r10 + 1 GUICtrlCreateLabel($r10, 200, $y_coord_Rolls_label_Row2, 43, 17, $SS_CENTER) Calculate_Percentages($r10) Case $msg = $Button11 $r11 = $r11 + 1 GUICtrlCreateLabel($r11, 288, $y_coord_Rolls_label_Row2, 43, 17, $SS_CENTER) Calculate_Percentages($r11) Case $msg = $Button12 $r12 = $r12 + 1 GUICtrlCreateLabel($r12, 368, $y_coord_Rolls_label_Row2, 43, 17, $SS_CENTER) Calculate_Percentages($r12) EndSelect WEnd Exit Func setState() Local $label_A[12] = ['', $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12] For $i = 1 To UBound($label_A) - 1 GUICtrlSetState($label_A[$i], $GUI_DISABLE) Next EndFunc ;==>setState Func Calculate_Percentages($r) $total_rolls = $r2 + $r3 + $r4 + $r5 + $r6 + $r7 + $r8 + $r9 + $r10 + $r11 + $r12 $percent = $r / $total_rolls ToolTip($percent) GUICtrlCreateLabel($total_rolls, 448, 296, 75, 25) GUICtrlCreateLabel($total_rolls, 448, 296, 75, 25) return $percent EndFunc ;==>Calculate_Percentages Hope it is correct and helps you a little bit. So long, Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
litlmike Posted July 6, 2006 Author Share Posted July 6, 2006 Hi, I don't understand the calc right noe. But I did what you want for the first two buttons, I guess. Hope it is correct and helps you a little bit. So long, MegaGreat job! This helps more than a little, it helps a lot. I did just notice something that I over looked before. Everytime any of the buttons are pressed, it should calculate all the percentages, because each of them changes every roll (button press). Is it much harder to make that change? For instance, if I press (roll) 2 it is 100%. If I then press 3, the percent is 50% for 2, and 50% for 3. If I press 2 again, then it is 66% and 33% for 2 and 3. How do I modify this script to recalculate all the percentages, everytime a button is pressed? I updated the script with your changes and it is posted below. expandcollapse popup#include <GUIConstants.au3> Global $r2 = 0, $r3 = 0, $r4 = 0, $r5 = 0, $r6 = 0, $r7 = 0, $r8 = 0, $r9 = 0, $r10 = 0, $r11 = 0, $r12 = 0 $y_coord_Rolls_button_Row1 = 31 $y_coord_Rolls_button_Row2 = 180 $y_coord_Rolls_Theo_Row1 = $y_coord_Rolls_button_Row1 - 20 $y_coord_Rolls_Theo_Row2 = $y_coord_Rolls_button_Row2 - 20 ;~ .028 - 2's & 12's ;~ .056 - 3's & 11's ;~ .083 - 4's & 10's ;~ .111 - 5's & 9's ;~ .139 - 6's & 8's ;~ .167 - 7's ; == GUI generated with Koda == $Form1 = GUICreate("AForm1", 618, 352, 192, 125) $Button2 = GUICtrlCreateButton("2", 8, $y_coord_Rolls_button_Row1, 75, 25) $Button3 = GUICtrlCreateButton("3", 96, $y_coord_Rolls_button_Row1, 75, 25) $Button4 = GUICtrlCreateButton("4", 184, $y_coord_Rolls_button_Row1, 75, 25) $Button5 = GUICtrlCreateButton("5", 272, $y_coord_Rolls_button_Row1, 75, 25) $Button6 = GUICtrlCreateButton("6", 360, $y_coord_Rolls_button_Row1, 75, 25) $Button7 = GUICtrlCreateButton("7", 448, $y_coord_Rolls_button_Row1, 75, 25) $Button8 = GUICtrlCreateButton("8", 8, $y_coord_Rolls_button_Row2, 75, 25) $Button9 = GUICtrlCreateButton("9", 96, $y_coord_Rolls_button_Row2, 75, 25) $Button10 = GUICtrlCreateButton("10", 184, $y_coord_Rolls_button_Row2, 75, 25) $Button11 = GUICtrlCreateButton("11", 272, $y_coord_Rolls_button_Row2, 75, 25) $Button12 = GUICtrlCreateButton("12", 360, $y_coord_Rolls_button_Row2, 75, 25) $x_coord_Rolls_Theo_Row1 = 16 $x_coord_Rolls_Theo_Row1_variance = 88 ;~ Theoretical Row 1 GUICtrlCreateLabel("2.8%", $x_coord_Rolls_Theo_Row1, $y_coord_Rolls_Theo_Row1, 43, 17, $SS_CENTER) $x_coord_Rolls_Theo_Row1 = $x_coord_Rolls_Theo_Row1 + $x_coord_Rolls_Theo_Row1_variance GUICtrlCreateLabel("5.6%", $x_coord_Rolls_Theo_Row1, $y_coord_Rolls_Theo_Row1, 43, 17, $SS_CENTER) $x_coord_Rolls_Theo_Row1 = $x_coord_Rolls_Theo_Row1 + $x_coord_Rolls_Theo_Row1_variance GUICtrlCreateLabel("8.3%", $x_coord_Rolls_Theo_Row1, $y_coord_Rolls_Theo_Row1, 43, 17, $SS_CENTER) $x_coord_Rolls_Theo_Row1 = $x_coord_Rolls_Theo_Row1 + $x_coord_Rolls_Theo_Row1_variance GUICtrlCreateLabel("11.1%", $x_coord_Rolls_Theo_Row1, $y_coord_Rolls_Theo_Row1, 43, 17, $SS_CENTER) $x_coord_Rolls_Theo_Row1 = $x_coord_Rolls_Theo_Row1 + $x_coord_Rolls_Theo_Row1_variance GUICtrlCreateLabel("13.9%", $x_coord_Rolls_Theo_Row1, $y_coord_Rolls_Theo_Row1, 43, 17, $SS_CENTER) $x_coord_Rolls_Theo_Row1 = $x_coord_Rolls_Theo_Row1 + $x_coord_Rolls_Theo_Row1_variance GUICtrlCreateLabel("16.7%", $x_coord_Rolls_Theo_Row1, $y_coord_Rolls_Theo_Row1, 43, 17, $SS_CENTER) $x_coord_Rolls_Theo_Row1 = 16 ;~ Theoretical Row 2 GUICtrlCreateLabel("13.9%", $x_coord_Rolls_Theo_Row1, $y_coord_Rolls_Theo_Row2, 43, 17, $SS_CENTER) $x_coord_Rolls_Theo_Row1 = $x_coord_Rolls_Theo_Row1 + $x_coord_Rolls_Theo_Row1_variance GUICtrlCreateLabel("11.1%", $x_coord_Rolls_Theo_Row1, $y_coord_Rolls_Theo_Row2, 43, 17, $SS_CENTER) $x_coord_Rolls_Theo_Row1 = $x_coord_Rolls_Theo_Row1 + $x_coord_Rolls_Theo_Row1_variance GUICtrlCreateLabel("8.3%", $x_coord_Rolls_Theo_Row1, $y_coord_Rolls_Theo_Row2, 43, 17, $SS_CENTER) $x_coord_Rolls_Theo_Row1 = $x_coord_Rolls_Theo_Row1 + $x_coord_Rolls_Theo_Row1_variance GUICtrlCreateLabel("5.6%", $x_coord_Rolls_Theo_Row1, $y_coord_Rolls_Theo_Row2, 43, 17, $SS_CENTER) $x_coord_Rolls_Theo_Row1 = $x_coord_Rolls_Theo_Row1 + $x_coord_Rolls_Theo_Row1_variance GUICtrlCreateLabel("2.8%", $x_coord_Rolls_Theo_Row1, $y_coord_Rolls_Theo_Row2, 43, 17, $SS_CENTER) ;;;;;;;;;;;;;;;;;;;;;;;;;;;Only a Place Marker;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; $x_coord_Rolls_Actual_Row1 = 16 $x_coord_Rolls_Actual_Row1_variance = 88 $y_coord_Rolls_Actual_Row1 = $y_coord_Rolls_button_Row1 + 60 $y_coord_Rolls_Actual_Row2 = $y_coord_Rolls_button_Row2 + 60 ;~ Current/Actual Row 1 $2 = GUICtrlCreateLabel("Actual", $x_coord_Rolls_Actual_Row1, $y_coord_Rolls_Actual_Row1, 43, 17, $SS_CENTER) $x_coord_Rolls_Actual_Row1 = $x_coord_Rolls_Actual_Row1 + $x_coord_Rolls_Actual_Row1_variance $3 = GUICtrlCreateLabel("Actual", $x_coord_Rolls_Actual_Row1, $y_coord_Rolls_Actual_Row1, 43, 17, $SS_CENTER) $x_coord_Rolls_Actual_Row1 = $x_coord_Rolls_Actual_Row1 + $x_coord_Rolls_Actual_Row1_variance $4 = GUICtrlCreateLabel("Actual", $x_coord_Rolls_Actual_Row1, $y_coord_Rolls_Actual_Row1, 43, 17, $SS_CENTER) $x_coord_Rolls_Actual_Row1 = $x_coord_Rolls_Actual_Row1 + $x_coord_Rolls_Actual_Row1_variance $5 = GUICtrlCreateLabel("Actual", $x_coord_Rolls_Actual_Row1, $y_coord_Rolls_Actual_Row1, 43, 17, $SS_CENTER) $x_coord_Rolls_Actual_Row1 = $x_coord_Rolls_Actual_Row1 + $x_coord_Rolls_Actual_Row1_variance $6 = GUICtrlCreateLabel("Actual", $x_coord_Rolls_Actual_Row1, $y_coord_Rolls_Actual_Row1, 43, 17, $SS_CENTER) $x_coord_Rolls_Actual_Row1 = $x_coord_Rolls_Actual_Row1 + $x_coord_Rolls_Actual_Row1_variance $7 = GUICtrlCreateLabel("Actual", $x_coord_Rolls_Actual_Row1, $y_coord_Rolls_Actual_Row1, 43, 17, $SS_CENTER) $x_coord_Rolls_Actual_Row1 = 16 ;~ Current/Actual Row 2 $8 = GUICtrlCreateLabel("Actual", $x_coord_Rolls_Actual_Row1, $y_coord_Rolls_Actual_Row2, 43, 17, $SS_CENTER) $x_coord_Rolls_Actual_Row1 = $x_coord_Rolls_Actual_Row1 + $x_coord_Rolls_Actual_Row1_variance $9 = GUICtrlCreateLabel("Actual", $x_coord_Rolls_Actual_Row1, $y_coord_Rolls_Actual_Row2, 43, 17, $SS_CENTER) $x_coord_Rolls_Actual_Row1 = $x_coord_Rolls_Actual_Row1 + $x_coord_Rolls_Actual_Row1_variance $10 = GUICtrlCreateLabel("Actual", $x_coord_Rolls_Actual_Row1, $y_coord_Rolls_Actual_Row2, 43, 17, $SS_CENTER) $x_coord_Rolls_Actual_Row1 = $x_coord_Rolls_Actual_Row1 + $x_coord_Rolls_Actual_Row1_variance $11 = GUICtrlCreateLabel("Actual", $x_coord_Rolls_Actual_Row1, $y_coord_Rolls_Actual_Row2, 43, 17, $SS_CENTER) $x_coord_Rolls_Actual_Row1 = $x_coord_Rolls_Actual_Row1 + $x_coord_Rolls_Actual_Row1_variance $12 = GUICtrlCreateLabel("Actual", $x_coord_Rolls_Actual_Row1, $y_coord_Rolls_Actual_Row2, 43, 17, $SS_CENTER) ;;;;;;;;;;;;;;;;;;;;;;;;;;;Only a Place Marker;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;Deviant $x_coord_Rolls_Deviant_Row1 = 16 $x_coord_Rolls_Deviant_Row1_variance = 88 $y_coord_Rolls_Deviant_Row1 = $y_coord_Rolls_button_Row1 + 80 $y_coord_Rolls_Deviant_Row2 = $y_coord_Rolls_button_Row2 + 80 ;~ Deviant Row 1 GUICtrlCreateLabel("Deviant", $x_coord_Rolls_Deviant_Row1, $y_coord_Rolls_Deviant_Row1, 43, 17, $SS_CENTER) $x_coord_Rolls_Deviant_Row1 = $x_coord_Rolls_Deviant_Row1 + $x_coord_Rolls_Deviant_Row1_variance GUICtrlCreateLabel("Deviant", $x_coord_Rolls_Deviant_Row1, $y_coord_Rolls_Deviant_Row1, 43, 17, $SS_CENTER) $x_coord_Rolls_Deviant_Row1 = $x_coord_Rolls_Deviant_Row1 + $x_coord_Rolls_Deviant_Row1_variance GUICtrlCreateLabel("Deviant", $x_coord_Rolls_Deviant_Row1, $y_coord_Rolls_Deviant_Row1, 43, 17, $SS_CENTER) $x_coord_Rolls_Deviant_Row1 = $x_coord_Rolls_Deviant_Row1 + $x_coord_Rolls_Deviant_Row1_variance GUICtrlCreateLabel("Deviant", $x_coord_Rolls_Deviant_Row1, $y_coord_Rolls_Deviant_Row1, 43, 17, $SS_CENTER) $x_coord_Rolls_Deviant_Row1 = $x_coord_Rolls_Deviant_Row1 + $x_coord_Rolls_Deviant_Row1_variance GUICtrlCreateLabel("Deviant", $x_coord_Rolls_Deviant_Row1, $y_coord_Rolls_Deviant_Row1, 43, 17, $SS_CENTER) $x_coord_Rolls_Deviant_Row1 = $x_coord_Rolls_Deviant_Row1 + $x_coord_Rolls_Deviant_Row1_variance GUICtrlCreateLabel("Deviant", $x_coord_Rolls_Deviant_Row1, $y_coord_Rolls_Deviant_Row1, 43, 17, $SS_CENTER) $x_coord_Rolls_Deviant_Row1 = 16 ;~ Deviant Row 2 GUICtrlCreateLabel("Deviant", $x_coord_Rolls_Deviant_Row1, $y_coord_Rolls_Deviant_Row2, 43, 17, $SS_CENTER) $x_coord_Rolls_Deviant_Row1 = $x_coord_Rolls_Deviant_Row1 + $x_coord_Rolls_Deviant_Row1_variance GUICtrlCreateLabel("Deviant", $x_coord_Rolls_Deviant_Row1, $y_coord_Rolls_Deviant_Row2, 43, 17, $SS_CENTER) $x_coord_Rolls_Deviant_Row1 = $x_coord_Rolls_Deviant_Row1 + $x_coord_Rolls_Deviant_Row1_variance GUICtrlCreateLabel("Deviant", $x_coord_Rolls_Deviant_Row1, $y_coord_Rolls_Deviant_Row2, 43, 17, $SS_CENTER) $x_coord_Rolls_Deviant_Row1 = $x_coord_Rolls_Deviant_Row1 + $x_coord_Rolls_Deviant_Row1_variance GUICtrlCreateLabel("Deviant", $x_coord_Rolls_Deviant_Row1, $y_coord_Rolls_Deviant_Row2, 43, 17, $SS_CENTER) $x_coord_Rolls_Deviant_Row1 = $x_coord_Rolls_Deviant_Row1 + $x_coord_Rolls_Deviant_Row1_variance GUICtrlCreateLabel("Deviant", $x_coord_Rolls_Deviant_Row1, $y_coord_Rolls_Deviant_Row2, 43, 17, $SS_CENTER) GUISetState(@SW_SHOW) $y_coord_Rolls_label_Row1 = $y_coord_Rolls_button_Row1 + 35 $y_coord_Rolls_label_Row2 = $y_coord_Rolls_button_Row2 + 35 $x_coord_Count_initial = 24 $x_coord_Count_variance = 88 While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button2 $r2 += 1 setState() GUICtrlCreateLabel($r2, 24, $y_coord_Rolls_label_Row1, 43, 17, $SS_CENTER) GUICtrlSetData($2, Calculate_Percentages($r2)) GUICtrlSetState($2, $GUI_ENABLE) Case $msg = $Button3 $r3 += 1 setState() GUICtrlCreateLabel($r3, 112, $y_coord_Rolls_label_Row1, 43, 17, $SS_CENTER) GUICtrlSetData($3, Calculate_Percentages($r3)) GUICtrlSetState($3, $GUI_ENABLE) Case $msg = $Button4 $r4 += 1 setState() GUICtrlCreateLabel($r4, 200, $y_coord_Rolls_label_Row1, 43, 17, $SS_CENTER) GUICtrlSetData($4, Calculate_Percentages($r4)) GUICtrlSetState($4, $GUI_ENABLE) Case $msg = $Button5 $r5 += 1 setState() GUICtrlCreateLabel($r5, 200, $y_coord_Rolls_label_Row1, 43, 17, $SS_CENTER) GUICtrlSetData($5, Calculate_Percentages($r5)) GUICtrlSetState($5, $GUI_ENABLE) Case $msg = $Button6 $r6 += 1 setState() GUICtrlCreateLabel($r6, 200, $y_coord_Rolls_label_Row1, 43, 17, $SS_CENTER) GUICtrlSetData($6, Calculate_Percentages($r6)) GUICtrlSetState($6, $GUI_ENABLE) Case $msg = $Button7 $r7 += 1 setState() GUICtrlCreateLabel($r7, 200, $y_coord_Rolls_label_Row1, 43, 17, $SS_CENTER) GUICtrlSetData($7, Calculate_Percentages($r7)) GUICtrlSetState($7, $GUI_ENABLE) Case $msg = $Button8 $r8 += 1 setState() GUICtrlCreateLabel($r8, 200, $y_coord_Rolls_label_Row1, 43, 17, $SS_CENTER) GUICtrlSetData($8, Calculate_Percentages($r8)) GUICtrlSetState($8, $GUI_ENABLE) Case $msg = $Button9 $r9 += 1 setState() GUICtrlCreateLabel($r9, 200, $y_coord_Rolls_label_Row1, 43, 17, $SS_CENTER) GUICtrlSetData($9, Calculate_Percentages($r9)) GUICtrlSetState($9, $GUI_ENABLE) Case $msg = $Button10 $r10 += 1 setState() GUICtrlCreateLabel($r10, 200, $y_coord_Rolls_label_Row1, 43, 17, $SS_CENTER) GUICtrlSetData($10, Calculate_Percentages($r10)) GUICtrlSetState($10, $GUI_ENABLE) Case $msg = $Button11 $r11 += 1 setState() GUICtrlCreateLabel($r11, 200, $y_coord_Rolls_label_Row1, 43, 17, $SS_CENTER) GUICtrlSetData($11, Calculate_Percentages($r11)) GUICtrlSetState($11, $GUI_ENABLE) Case $msg = $Button12 $r12 += 1 setState() GUICtrlCreateLabel($r12, 200, $y_coord_Rolls_label_Row1, 43, 17, $SS_CENTER) GUICtrlSetData($12, Calculate_Percentages($r12)) GUICtrlSetState($12, $GUI_ENABLE) EndSelect WEnd Exit Func setState() Local $label_A[12] = ['', $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12] For $i = 1 To UBound($label_A) - 1 GUICtrlSetState($label_A[$i], $GUI_DISABLE) Next EndFunc ;==>setState Func Calculate_Percentages($r) $total_rolls = $r2 + $r3 + $r4 + $r5 + $r6 + $r7 + $r8 + $r9 + $r10 + $r11 + $r12 $percent = Round ( $r / $total_rolls * 100, 2 ) ToolTip($percent) GUICtrlCreateLabel($total_rolls, 448, 296, 75, 25) GUICtrlCreateLabel($total_rolls, 448, 296, 75, 25) return $percent EndFunc ;==>Calculate_Percentages _ArrayPermute()_ArrayUnique()Excel.au3 UDF Link to comment Share on other sites More sharing options...
Xenobiologist Posted July 7, 2006 Share Posted July 7, 2006 Hi, didn't know what you exactly want to do, but does this fit whar you expect? expandcollapse popup#include <GUIConstants.au3> ; == GUI generated with Koda == $Form1 = GUICreate("RollDice", 602, 441, 192, 125) $Dice_G = GUICtrlCreateGroup("Game", 16, 40, 569, 393) ;buttons $2_B = GUICtrlCreateButton("2", 76, 72, 75, 25) $3_B = GUICtrlCreateButton("3", 76, 104, 75, 25) $4_B = GUICtrlCreateButton("4", 76, 136, 75, 25) $5_B = GUICtrlCreateButton("5", 76, 168, 75, 25) $6_B = GUICtrlCreateButton("6", 76, 200, 75, 25) $7_B = GUICtrlCreateButton("7", 76, 232, 75, 25) $8_B = GUICtrlCreateButton("8", 76, 264, 75, 25) $9_B = GUICtrlCreateButton("9", 76, 296, 75, 25) $10_B = GUICtrlCreateButton("10", 76, 328, 75, 25) $11_B = GUICtrlCreateButton("11", 76, 360, 75, 25) $12_B = GUICtrlCreateButton("12", 76, 392, 75, 25) ; static labels $2n_L = GUICtrlCreateLabel(" 2.8 %", 24, 80, 43, 17, $SS_SUNKEN) $3n_L = GUICtrlCreateLabel(" 5.6 %", 24, 112, 43, 17, $SS_SUNKEN) $4n_L = GUICtrlCreateLabel(" 8.3 %", 24, 144, 43, 17, $SS_SUNKEN) $5n_L = GUICtrlCreateLabel("11.1 %", 24, 176, 43, 17, $SS_SUNKEN) $6n_L = GUICtrlCreateLabel("13.9 %", 24, 208, 43, 17, $SS_SUNKEN) $7n_L = GUICtrlCreateLabel("16.7 %", 24, 240, 43, 17, $SS_SUNKEN) $8n_L = GUICtrlCreateLabel("13.9 %", 24, 272, 43, 17, $SS_SUNKEN) $9n_L = GUICtrlCreateLabel("11.1 %", 24, 304, 43, 17, $SS_SUNKEN) $10n_L = GUICtrlCreateLabel(" 8.3 %", 24, 336, 43, 17, $SS_SUNKEN) $11n_L = GUICtrlCreateLabel(" 5.6 %", 24, 368, 43, 17, $SS_SUNKEN) $12n_L = GUICtrlCreateLabel(" 2.8 %", 24, 400, 43, 17, $SS_SUNKEN) ; Count labels $2c_L = GUICtrlCreateLabel("0", 160, 80, 30, 17, $SS_SUNKEN) $3c_L = GUICtrlCreateLabel("0", 160, 112, 30, 17, $SS_SUNKEN) $4c_L = GUICtrlCreateLabel("0", 160, 144, 30, 17, $SS_SUNKEN) $5c_L = GUICtrlCreateLabel("0", 160, 176, 30, 17, $SS_SUNKEN) $6c_L = GUICtrlCreateLabel("0", 160, 208, 30, 17, $SS_SUNKEN) $7c_L = GUICtrlCreateLabel("0", 160, 240, 30, 17, $SS_SUNKEN) $8c_L = GUICtrlCreateLabel("0", 160, 272, 30, 17, $SS_SUNKEN) $9c_L = GUICtrlCreateLabel("0", 160, 304, 30, 17, $SS_SUNKEN) $10c_L = GUICtrlCreateLabel("0", 160, 336, 30, 17, $SS_SUNKEN) $11c_L = GUICtrlCreateLabel("0", 160, 368, 30, 17, $SS_SUNKEN) $12c_L = GUICtrlCreateLabel("0", 160, 400, 30, 17, $SS_SUNKEN) ;Actual $Actual_G = GUICtrlCreateGroup("Actual", 200, 56, 113, 369) $actual2_L = GUICtrlCreateLabel("0", 208, 80, 97, 17, $SS_SUNKEN) $actual3_L = GUICtrlCreateLabel("0", 208, 112, 97, 17, $SS_SUNKEN) $actual4_L = GUICtrlCreateLabel("0", 208, 144, 97, 17, $SS_SUNKEN) $actual5_L = GUICtrlCreateLabel("0", 208, 176, 97, 17, $SS_SUNKEN) $actual6_L = GUICtrlCreateLabel("0", 208, 208, 97, 17, $SS_SUNKEN) $actual7_L = GUICtrlCreateLabel("0", 208, 240, 97, 17, $SS_SUNKEN) $actual8_L = GUICtrlCreateLabel("0", 208, 272, 97, 17, $SS_SUNKEN) $actual9_L = GUICtrlCreateLabel("0", 208, 304, 97, 17, $SS_SUNKEN) $actual10_L = GUICtrlCreateLabel("0", 208, 336, 97, 17, $SS_SUNKEN) $actual11_L = GUICtrlCreateLabel("0", 208, 368, 97, 17, $SS_SUNKEN) $actual12_L = GUICtrlCreateLabel("0", 208, 400, 97, 17, $SS_SUNKEN) GUICtrlCreateGroup("", -99, -99, 1, 1) ; Deviant $deviant_G = GUICtrlCreateGroup("Deviant", 328, 56, 113, 369) $deviant2_L = GUICtrlCreateLabel("0", 336, 80, 97, 17, $SS_SUNKEN) $deviant3_L = GUICtrlCreateLabel("0", 336, 112, 97, 17, $SS_SUNKEN) $deviant4_L = GUICtrlCreateLabel("0", 336, 144, 97, 17, $SS_SUNKEN) $deviant5_L = GUICtrlCreateLabel("0", 336, 176, 97, 17, $SS_SUNKEN) $deviant6_L = GUICtrlCreateLabel("0", 336, 208, 97, 17, $SS_SUNKEN) $deviant7_L = GUICtrlCreateLabel("0", 336, 240, 97, 17, $SS_SUNKEN) $deviant8_L = GUICtrlCreateLabel("0", 336, 272, 97, 17, $SS_SUNKEN) $deviant9_L = GUICtrlCreateLabel("0", 336, 304, 97, 17, $SS_SUNKEN) $deviant10_L = GUICtrlCreateLabel("0", 336, 336, 97, 17, $SS_SUNKEN) $deviant11_L = GUICtrlCreateLabel("0", 336, 368, 97, 17, $SS_SUNKEN) $deviant12_L = GUICtrlCreateLabel("0", 336, 400, 97, 17, $SS_SUNKEN) GUICtrlCreateGroup("", -99, -99, 1, 1) ; Total $total_G = GUICtrlCreateGroup("Total", 456, 56, 113, 369) $exit_B = GUICtrlCreateButton("Exit", 464, 144, 97, 25) GUICtrlCreateLabel("Total Rolls", 464, 80, 97, 17, $SS_SUNKEN) $totalRolls_L = GUICtrlCreateLabel("0", 464, 112, 97, 17, $SS_SUNKEN) GUICtrlCreateGroup("", -99, -99, 1, 1) GUICtrlCreateLabel("Roll- Dice", 16, 8, 571, 17) GUISetState(@SW_SHOW) ; variables Global $rolls_A[12] = ['', $2c_L, $3c_L, $4c_L, $5c_L, $6c_L, $7c_L, $8c_L, $9c_L, $10c_L, $11c_L, $12c_L] Global $actual_A[12] = ['', $actual2_L, $actual3_L, $actual4_L, $actual5_L, $actual6_L, $actual7_L, $actual8_L, $actual9_L, $actual10_L, $actual11_L, $actual12_L] Global $deviant_A[12] = ['', $deviant2_L, $deviant3_L, $deviant4_L, $deviant5_L, $deviant6_L, $deviant7_L, $deviant8_L, $deviant9_L, $deviant10_L, $deviant11_L, $deviant12_L] Global $norm_A[12] = ['', $2n_L, $3n_L, $4n_L, $5n_L, $6n_L, $7n_L, $8n_L, $9n_L, $10n_L, $11n_L, $12n_L] Func calcTotalScore() Local $score For $i = 1 To UBound($rolls_A) - 1 $score += GUICtrlRead($rolls_A[$i]) Next GUICtrlSetData($totalRolls_L, $score) setState() calcPerCent() EndFunc ;==>calcTotalScore Func setState() For $i = 1 To UBound($actual_A) - 1 GUICtrlSetState($actual_A[$i], $GUI_DISABLE) GUICtrlSetState($deviant_A[$i], $GUI_DISABLE) Next EndFunc ;==>setState Func calcPerCent() For $i = 1 To UBound($actual_A)-1 GUICtrlSetData($actual_A[$i], Round(GUICtrlRead($rolls_A[$i]) / GUICtrlRead($totalRolls_L) * 100, 2)) GUICtrlSetData($deviant_A[$i], GUICtrlRead($norm_A[$i]) - GUICtrlRead($actual_A[$i])) Next EndFunc While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Or $msg = $exit_B ExitLoop Case $msg = $2_B GUICtrlSetData($rolls_A[1], (GUICtrlRead($rolls_A[1]) + 1)) calcTotalScore() GUICtrlSetState($actual_A[1], $GUI_ENABLE) GUICtrlSetState($deviant_A[1], $GUI_ENABLE) Case $msg = $3_B GUICtrlSetData($rolls_A[2], (GUICtrlRead($rolls_A[2]) + 1)) calcTotalScore() GUICtrlSetState($actual_A[2], $GUI_ENABLE) GUICtrlSetState($deviant_A[2], $GUI_ENABLE) Case $msg = $4_B GUICtrlSetData($rolls_A[3], (GUICtrlRead($rolls_A[3]) + 1)) calcTotalScore() GUICtrlSetState($actual_A[3], $GUI_ENABLE) GUICtrlSetState($deviant_A[3], $GUI_ENABLE) Case $msg = $5_B GUICtrlSetData($rolls_A[4], (GUICtrlRead($rolls_A[4]) + 1)) calcTotalScore() GUICtrlSetState($actual_A[4], $GUI_ENABLE) GUICtrlSetState($deviant_A[4], $GUI_ENABLE) Case $msg = $6_B GUICtrlSetData($rolls_A[5], (GUICtrlRead($rolls_A[5]) + 1)) calcTotalScore() GUICtrlSetState($actual_A[5], $GUI_ENABLE) GUICtrlSetState($deviant_A[5], $GUI_ENABLE) Case $msg = $7_B GUICtrlSetData($rolls_A[6], (GUICtrlRead($rolls_A[6]) + 1)) calcTotalScore() GUICtrlSetState($actual_A[6], $GUI_ENABLE) GUICtrlSetState($deviant_A[6], $GUI_ENABLE) Case $msg = $8_B GUICtrlSetData($rolls_A[7], (GUICtrlRead($rolls_A[7]) + 1)) calcTotalScore() GUICtrlSetState($actual_A[7], $GUI_ENABLE) GUICtrlSetState($deviant_A[7], $GUI_ENABLE) Case $msg = $9_B GUICtrlSetData($rolls_A[8], (GUICtrlRead($rolls_A[8]) + 1)) calcTotalScore() GUICtrlSetState($actual_A[8], $GUI_ENABLE) GUICtrlSetState($deviant_A[8], $GUI_ENABLE) Case $msg = $10_B GUICtrlSetData($rolls_A[9], (GUICtrlRead($rolls_A[9]) + 1)) calcTotalScore() GUICtrlSetState($actual_A[9], $GUI_ENABLE) GUICtrlSetState($deviant_A[9], $GUI_ENABLE) Case $msg = $11_B GUICtrlSetData($rolls_A[10], (GUICtrlRead($rolls_A[10]) + 1)) calcTotalScore() GUICtrlSetState($actual_A[10], $GUI_ENABLE) GUICtrlSetState($deviant_A[10], $GUI_ENABLE) Case $msg = $12_B GUICtrlSetData($rolls_A[11], (GUICtrlRead($rolls_A[11]) + 1)) calcTotalScore() GUICtrlSetState($actual_A[11], $GUI_ENABLE) GUICtrlSetState($deviant_A[11], $GUI_ENABLE) Case Else ;;;;;;; EndSelect WEnd Exit So long, Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
litlmike Posted July 7, 2006 Author Share Posted July 7, 2006 Hi,didn't know what you exactly want to do, but does this fit whar you expect?So long,MegaHmmmm, let me think about that....Yea that EXACTLY what I wanted! Thanks so much! I really need to learn how to get better at arrays. Wish I was as smart as you.The only other thing I could possibly think that I would need to add to this, is a way to save the data for long term use. A way that I could close the script, and when I reopen it, the data would be available to import. What is the best way for me to do this? Is it FileWrite and FileRead?Thanks Again! _ArrayPermute()_ArrayUnique()Excel.au3 UDF Link to comment Share on other sites More sharing options...
Xenobiologist Posted July 10, 2006 Share Posted July 10, 2006 Hi, okay I did it 4 you. expandcollapse popup#include <GUIConstants.au3> #include<File.au3> #include<Array.au3> $Form1 = GUICreate("RollDice", 602, 441, 192, 125) $Dice_G = GUICtrlCreateGroup("Game", 16, 40, 569, 393) ;buttons $2_B = GUICtrlCreateButton("2", 76, 72, 75, 25) $3_B = GUICtrlCreateButton("3", 76, 104, 75, 25) $4_B = GUICtrlCreateButton("4", 76, 136, 75, 25) $5_B = GUICtrlCreateButton("5", 76, 168, 75, 25) $6_B = GUICtrlCreateButton("6", 76, 200, 75, 25) $7_B = GUICtrlCreateButton("7", 76, 232, 75, 25) $8_B = GUICtrlCreateButton("8", 76, 264, 75, 25) $9_B = GUICtrlCreateButton("9", 76, 296, 75, 25) $10_B = GUICtrlCreateButton("10", 76, 328, 75, 25) $11_B = GUICtrlCreateButton("11", 76, 360, 75, 25) $12_B = GUICtrlCreateButton("12", 76, 392, 75, 25) ; static labels $2n_L = GUICtrlCreateLabel(" 2.8 %", 24, 80, 43, 17, $SS_SUNKEN) $3n_L = GUICtrlCreateLabel(" 5.6 %", 24, 112, 43, 17, $SS_SUNKEN) $4n_L = GUICtrlCreateLabel(" 8.3 %", 24, 144, 43, 17, $SS_SUNKEN) $5n_L = GUICtrlCreateLabel("11.1 %", 24, 176, 43, 17, $SS_SUNKEN) $6n_L = GUICtrlCreateLabel("13.9 %", 24, 208, 43, 17, $SS_SUNKEN) $7n_L = GUICtrlCreateLabel("16.7 %", 24, 240, 43, 17, $SS_SUNKEN) $8n_L = GUICtrlCreateLabel("13.9 %", 24, 272, 43, 17, $SS_SUNKEN) $9n_L = GUICtrlCreateLabel("11.1 %", 24, 304, 43, 17, $SS_SUNKEN) $10n_L = GUICtrlCreateLabel(" 8.3 %", 24, 336, 43, 17, $SS_SUNKEN) $11n_L = GUICtrlCreateLabel(" 5.6 %", 24, 368, 43, 17, $SS_SUNKEN) $12n_L = GUICtrlCreateLabel(" 2.8 %", 24, 400, 43, 17, $SS_SUNKEN) ; Count labels $2c_L = GUICtrlCreateLabel("0", 160, 80, 30, 17, $SS_SUNKEN) $3c_L = GUICtrlCreateLabel("0", 160, 112, 30, 17, $SS_SUNKEN) $4c_L = GUICtrlCreateLabel("0", 160, 144, 30, 17, $SS_SUNKEN) $5c_L = GUICtrlCreateLabel("0", 160, 176, 30, 17, $SS_SUNKEN) $6c_L = GUICtrlCreateLabel("0", 160, 208, 30, 17, $SS_SUNKEN) $7c_L = GUICtrlCreateLabel("0", 160, 240, 30, 17, $SS_SUNKEN) $8c_L = GUICtrlCreateLabel("0", 160, 272, 30, 17, $SS_SUNKEN) $9c_L = GUICtrlCreateLabel("0", 160, 304, 30, 17, $SS_SUNKEN) $10c_L = GUICtrlCreateLabel("0", 160, 336, 30, 17, $SS_SUNKEN) $11c_L = GUICtrlCreateLabel("0", 160, 368, 30, 17, $SS_SUNKEN) $12c_L = GUICtrlCreateLabel("0", 160, 400, 30, 17, $SS_SUNKEN) ;Actual $Actual_G = GUICtrlCreateGroup("Actual", 200, 56, 113, 369) $actual2_L = GUICtrlCreateLabel("0", 208, 80, 97, 17, $SS_SUNKEN) $actual3_L = GUICtrlCreateLabel("0", 208, 112, 97, 17, $SS_SUNKEN) $actual4_L = GUICtrlCreateLabel("0", 208, 144, 97, 17, $SS_SUNKEN) $actual5_L = GUICtrlCreateLabel("0", 208, 176, 97, 17, $SS_SUNKEN) $actual6_L = GUICtrlCreateLabel("0", 208, 208, 97, 17, $SS_SUNKEN) $actual7_L = GUICtrlCreateLabel("0", 208, 240, 97, 17, $SS_SUNKEN) $actual8_L = GUICtrlCreateLabel("0", 208, 272, 97, 17, $SS_SUNKEN) $actual9_L = GUICtrlCreateLabel("0", 208, 304, 97, 17, $SS_SUNKEN) $actual10_L = GUICtrlCreateLabel("0", 208, 336, 97, 17, $SS_SUNKEN) $actual11_L = GUICtrlCreateLabel("0", 208, 368, 97, 17, $SS_SUNKEN) $actual12_L = GUICtrlCreateLabel("0", 208, 400, 97, 17, $SS_SUNKEN) GUICtrlCreateGroup("", -99, -99, 1, 1) ; Deviant $deviant_G = GUICtrlCreateGroup("Deviant", 328, 56, 113, 369) $deviant2_L = GUICtrlCreateLabel("0", 336, 80, 97, 17, $SS_SUNKEN) $deviant3_L = GUICtrlCreateLabel("0", 336, 112, 97, 17, $SS_SUNKEN) $deviant4_L = GUICtrlCreateLabel("0", 336, 144, 97, 17, $SS_SUNKEN) $deviant5_L = GUICtrlCreateLabel("0", 336, 176, 97, 17, $SS_SUNKEN) $deviant6_L = GUICtrlCreateLabel("0", 336, 208, 97, 17, $SS_SUNKEN) $deviant7_L = GUICtrlCreateLabel("0", 336, 240, 97, 17, $SS_SUNKEN) $deviant8_L = GUICtrlCreateLabel("0", 336, 272, 97, 17, $SS_SUNKEN) $deviant9_L = GUICtrlCreateLabel("0", 336, 304, 97, 17, $SS_SUNKEN) $deviant10_L = GUICtrlCreateLabel("0", 336, 336, 97, 17, $SS_SUNKEN) $deviant11_L = GUICtrlCreateLabel("0", 336, 368, 97, 17, $SS_SUNKEN) $deviant12_L = GUICtrlCreateLabel("0", 336, 400, 97, 17, $SS_SUNKEN) GUICtrlCreateGroup("", -99, -99, 1, 1) ; Total $total_G = GUICtrlCreateGroup("Total", 456, 56, 113, 369) $import_B = GUICtrlCreateButton("Import", 464, 144, 97, 25) $export_B = GUICtrlCreateButton("Export", 464, 174, 97, 25) $restart_B = GUICtrlCreateButton("Restart", 464, 204, 97, 25) $exit_B = GUICtrlCreateButton("Exit", 464, 234, 97, 25) GUICtrlCreateLabel("Total Rolls", 464, 80, 97, 17, $SS_SUNKEN) $totalRolls_L = GUICtrlCreateLabel("0", 464, 112, 97, 17, $SS_SUNKEN) GUICtrlCreateGroup("", -99, -99, 1, 1) GUICtrlCreateLabel("Roll - Dice", 16, 8, 571, 30) GUICtrlSetFont(-1, 16, 500, 4) GUISetState(@SW_SHOW) ; variables Global $rolls_A[12] = ['', $2c_L, $3c_L, $4c_L, $5c_L, $6c_L, $7c_L, $8c_L, $9c_L, $10c_L, $11c_L, $12c_L] Global $actual_A[12] = ['', $actual2_L, $actual3_L, $actual4_L, $actual5_L, $actual6_L, $actual7_L, $actual8_L, $actual9_L, $actual10_L, $actual11_L, $actual12_L] Global $deviant_A[12] = ['', $deviant2_L, $deviant3_L, $deviant4_L, $deviant5_L, $deviant6_L, $deviant7_L, $deviant8_L, $deviant9_L, $deviant10_L, $deviant11_L, $deviant12_L] Global $norm_A[12] = ['', $2n_L, $3n_L, $4n_L, $5n_L, $6n_L, $7n_L, $8n_L, $9n_L, $10n_L, $11n_L, $12n_L] Global $score = 0 Func calcTotalScore() For $i = 1 To UBound($rolls_A) - 1 $score += GUICtrlRead($rolls_A[$i]) Next GUICtrlSetData($totalRolls_L, $score) $score = 0 setState() calcPerCent() EndFunc ;==>calcTotalScore Func setState() For $i = 1 To UBound($actual_A) - 1 GUICtrlSetState($actual_A[$i], $GUI_DISABLE) GUICtrlSetState($deviant_A[$i], $GUI_DISABLE) Next EndFunc ;==>setState Func _restart() For $i = 1 To UBound($actual_A) - 1 GUICtrlSetData($actual_A[$i], 0) GUICtrlSetData($deviant_A[$i], 0) GUICtrlSetData($rolls_A[$i], 0) GUICtrlSetState($actual_A[$i], $GUI_DISABLE) GUICtrlSetState($deviant_A[$i], $GUI_DISABLE) Next GUICtrlSetData($totalRolls_L, 0) EndFunc ;==>_restart Func calcPerCent() For $i = 1 To UBound($actual_A) - 1 GUICtrlSetData($actual_A[$i], Round(GUICtrlRead($rolls_A[$i]) / GUICtrlRead($totalRolls_L) * 100, 2)) GUICtrlSetData($deviant_A[$i], GUICtrlRead($norm_A[$i]) - GUICtrlRead($actual_A[$i])) Next EndFunc ;==>calcPerCent Func _import() $dataFile = FileOpenDialog("Chose saved Roll-Dice file", @ScriptDir, "Ini file (*.ini)", 3, "data.ini") If @error Then MsgBox(4096, "Error", "No File(s) chosen", 3) Else For $i = 1 To UBound($rolls_A) - 1 Local $data_A = StringSplit(IniRead($dataFile, "RollDice", $i + 1, "Data not found!"), "|") GUICtrlSetData($rolls_A[$i], $data_A[1]) GUICtrlSetData($actual_A[$i], $data_A[2]) GUICtrlSetData($deviant_A[$i], $data_A[3]) Next GUICtrlSetData($totalRolls_L, IniRead($dataFile, "RollDice", "Total", "Data not found!")) setState() EndIf EndFunc ;==>_import Func _export() $savedFile = FileSaveDialog("Save Roll-Dice data", @ScriptDir, "Ini file (*.ini)", 2 + 16, "data.ini") If @error Then MsgBox(4096, "Error", "Save cancelled.", 3) Else For $i = 1 To UBound($rolls_A) - 1 IniWrite($savedFile, "RollDice", $i + 1, GUICtrlRead($rolls_A[$i]) & "|" & GUICtrlRead($actual_A[$i]) & "|" & GUICtrlRead($deviant_A[$i])) Next IniWrite($savedFile, "RollDice", "Total", GUICtrlRead($totalRolls_L)) EndIf EndFunc ;==>_export While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Or $msg = $exit_B ExitLoop Case $msg = $2_B GUICtrlSetData($rolls_A[1], (GUICtrlRead($rolls_A[1]) + 1)) calcTotalScore() GUICtrlSetState($actual_A[1], $GUI_ENABLE) GUICtrlSetState($deviant_A[1], $GUI_ENABLE) Case $msg = $3_B GUICtrlSetData($rolls_A[2], (GUICtrlRead($rolls_A[2]) + 1)) calcTotalScore() GUICtrlSetState($actual_A[2], $GUI_ENABLE) GUICtrlSetState($deviant_A[2], $GUI_ENABLE) Case $msg = $4_B GUICtrlSetData($rolls_A[3], (GUICtrlRead($rolls_A[3]) + 1)) calcTotalScore() GUICtrlSetState($actual_A[3], $GUI_ENABLE) GUICtrlSetState($deviant_A[3], $GUI_ENABLE) Case $msg = $5_B GUICtrlSetData($rolls_A[4], (GUICtrlRead($rolls_A[4]) + 1)) calcTotalScore() GUICtrlSetState($actual_A[4], $GUI_ENABLE) GUICtrlSetState($deviant_A[4], $GUI_ENABLE) Case $msg = $6_B GUICtrlSetData($rolls_A[5], (GUICtrlRead($rolls_A[5]) + 1)) calcTotalScore() GUICtrlSetState($actual_A[5], $GUI_ENABLE) GUICtrlSetState($deviant_A[5], $GUI_ENABLE) Case $msg = $7_B GUICtrlSetData($rolls_A[6], (GUICtrlRead($rolls_A[6]) + 1)) calcTotalScore() GUICtrlSetState($actual_A[6], $GUI_ENABLE) GUICtrlSetState($deviant_A[6], $GUI_ENABLE) Case $msg = $8_B GUICtrlSetData($rolls_A[7], (GUICtrlRead($rolls_A[7]) + 1)) calcTotalScore() GUICtrlSetState($actual_A[7], $GUI_ENABLE) GUICtrlSetState($deviant_A[7], $GUI_ENABLE) Case $msg = $9_B GUICtrlSetData($rolls_A[8], (GUICtrlRead($rolls_A[8]) + 1)) calcTotalScore() GUICtrlSetState($actual_A[8], $GUI_ENABLE) GUICtrlSetState($deviant_A[8], $GUI_ENABLE) Case $msg = $10_B GUICtrlSetData($rolls_A[9], (GUICtrlRead($rolls_A[9]) + 1)) calcTotalScore() GUICtrlSetState($actual_A[9], $GUI_ENABLE) GUICtrlSetState($deviant_A[9], $GUI_ENABLE) Case $msg = $11_B GUICtrlSetData($rolls_A[10], (GUICtrlRead($rolls_A[10]) + 1)) calcTotalScore() GUICtrlSetState($actual_A[10], $GUI_ENABLE) GUICtrlSetState($deviant_A[10], $GUI_ENABLE) Case $msg = $12_B GUICtrlSetData($rolls_A[11], (GUICtrlRead($rolls_A[11]) + 1)) calcTotalScore() GUICtrlSetState($actual_A[11], $GUI_ENABLE) GUICtrlSetState($deviant_A[11], $GUI_ENABLE) Case $msg = $export_B _export() Case $msg = $import_B _import() Case $msg = $restart_B _restart() Case Else ;;;;;;; EndSelect WEnd Exit So long, Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
litlmike Posted July 10, 2006 Author Share Posted July 10, 2006 Hi,okay I did it 4 you.So long,Mega*bows* Thanks! Great job in the World Cup too!Ich schätze wirklich Ihre Hilfe! Dank wieder! _ArrayPermute()_ArrayUnique()Excel.au3 UDF Link to comment Share on other sites More sharing options...
Xenobiologist Posted July 10, 2006 Share Posted July 10, 2006 *bows* Thanks! Great job in the World Cup too!Ich schätze wirklich Ihre Hilfe! Dank wieder!Hi,no problem. Hope the program allows you to reach your aim. Thanks again! Yeah the world cup was absolutely awesome! Ich schätze wirklich Ihre Hilfe! Dank wieder! Very polite! So long,Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now