maqleod Posted January 4, 2007 Posted January 4, 2007 I need a function to find the lowest value of 6 variables, and given the chance that two or more are equally low it will select one (at random) to return. then I need a function that will do the same with the highest value. The reason I need this is that I am writing a dice roller script, but I want to include options that if checked will re-roll the lowest die roll, drop the lowest die roll, and add 1, or 2 to the highest die roll. I am just not completely sure how to implement this portion of my script. I included the script and the include file for those of you who wish to look it over and make suggestions, thanks for any help. expandcollapse popup#include <GUIConstants.au3> #include <Dice.au3> #NoTrayIcon FileChangeDir(@ScriptDir) $name="Dice Roller 1.0" Opt("GUICoordMode",1) $parent = GUICreate($name,875,400,-1,-1,-1, $WS_EX_ACCEPTFILES) Opt("RunErrorsFatal", 0) $contextmenu = GUICtrlCreateContextMenu () $fileopt = GUICtrlCreateMenu ("&File") $exititem = GUICtrlCreateMenuitem ("Exit",$fileopt) $editopt = GUICtrlCreateMenu ("Edit") $resetitem = GUICtrlCreateMenuitem ("Reset Dice",$editopt) $aboutopt = GUICtrlCreateMenu ("About") $aboutitem = GUICtrlCreateMenuitem ("About",$aboutopt) $check1 = GUICtrlCreateCheckbox ("DIE 1", 70, 10, 90,20) GUICtrlSetState(-1,$GUI_CHECKED) GUICtrlCreateLabel ("Number Of Sides:", 30, 42, 90,30) $sides1 = GUICtrlCreateCombo ("4", 120,40,50) GUICtrlSetData(-1,"6|8|10|12|20|30|100","6") $sign1 = GUICtrlCreateCombo ("+", 50,80,50) GUICtrlSetData(-1,"-","+") $modifier1 = GUICtrlCreateInput ("0", 115, 80, 50, 20) $result1 = GUICtrlCreateLabel("", 70, 115, 70, 50, 0x1000) GUICtrlSetFont($result1, 28, 850, "", "Comic Sans MS") $check2 = GUICtrlCreateCheckbox ("DIE 2", 240, 10, 90,20) GUICtrlCreateLabel ("Number Of Sides:", 200, 42, 90,30) $sides2 = GUICtrlCreateCombo ("4", 290,40,50) GUICtrlSetData(-1,"6|8|10|12|20|30|100","6") $sign2 = GUICtrlCreateCombo ("+", 220,80,50) GUICtrlSetData(-1,"-","+") $modifier2 = GUICtrlCreateInput ("0", 285, 80, 50, 20) $result2 = GUICtrlCreateLabel ("", 240, 115, 70, 50, 0x1000) GUICtrlSetFont($result2, 28, 850, "", "Comic Sans MS") $check3 = GUICtrlCreateCheckbox ("DIE 3", 410, 10, 90,20) GUICtrlCreateLabel ("Number Of Sides:", 370, 42, 90,30) $sides3 = GUICtrlCreateCombo ("4", 460,40,50) GUICtrlSetData(-1,"6|8|10|12|20|30|100","6") $sign3 = GUICtrlCreateCombo ("+", 390,80,50) GUICtrlSetData(-1,"-","+") $modifier3 = GUICtrlCreateInput ("0", 455, 80, 50, 20) $result3 = GUICtrlCreateLabel ("", 410, 115, 70, 50, 0x1000) GUICtrlSetFont($result3, 28, 850, "", "Comic Sans MS") $check4 = GUICtrlCreateCheckbox ("DIE 4", 70, 160, 90,20) GUICtrlCreateLabel ("Number Of Sides:", 30, 192, 90,30) $sides4 = GUICtrlCreateCombo ("4", 120,190,50) GUICtrlSetData(-1,"6|8|10|12|20|30|100","6") $sign4 = GUICtrlCreateCombo ("+", 50,230,50) GUICtrlSetData(-1,"-","+") $modifier4 = GUICtrlCreateInput ("0", 115, 230, 50, 20) $result4 = GUICtrlCreateLabel("", 70, 265, 70, 50, 0x1000) GUICtrlSetFont($result4, 28, 850, "", "Comic Sans MS") $check5 = GUICtrlCreateCheckbox ("DIE 5", 240, 160, 90,20) GUICtrlCreateLabel ("Number Of Sides:", 200, 192, 90,30) $sides5 = GUICtrlCreateCombo ("4", 290,190,50) GUICtrlSetData(-1,"6|8|10|12|20|30|100","6") $sign5 = GUICtrlCreateCombo ("+", 220,230,50) GUICtrlSetData(-1,"-","+") $modifier5 = GUICtrlCreateInput ("0", 285, 230, 50, 20) $result5 = GUICtrlCreateLabel ("", 240, 265, 70, 50, 0x1000) GUICtrlSetFont($result5, 28, 850, "", "Comic Sans MS") $check6 = GUICtrlCreateCheckbox ("DIE 6", 410, 160, 90,20) GUICtrlCreateLabel ("Number Of Sides:", 370, 192, 90,30) $sides6 = GUICtrlCreateCombo ("4", 460,190,50) GUICtrlSetData(-1,"6|8|10|12|20|30|100","6") $sign6 = GUICtrlCreateCombo ("+", 390,230,50) GUICtrlSetData(-1,"-","+") $modifier6 = GUICtrlCreateInput ("0", 455, 230, 50, 20) $result6 = GUICtrlCreateLabel ("", 410, 265, 70, 50, 0x1000) GUICtrlSetFont($result6, 28, 850, "", "Comic Sans MS") $roll = GUICtrlCreateButton ("Roll", 540, 85,75) GUICtrlCreateLabel ("GLOBAL MODIFIERS", 550, 205, 90,40) $drop = GUICtrlCreateCheckbox ("Drop Lowest Roll", 530, 245, 110,20) $reroll = GUICtrlCreateCheckbox ("Re-roll Lowest Roll", 530, 265, 110,20) $add1 = GUICtrlCreateCheckbox ("Add 1 To Highest Roll", 530, 285, 110,20) $add2 = GUICtrlCreateCheckbox ("Add 2 To Highest Roll", 530, 305, 110,20) $hiddeninput = GUICtrlCreateInput ("0", 10, 10, 100, 100) GUICtrlSetState(-1,$GUI_HIDE) GUICtrlCreateLabel ("Roll Total", 550, 5, 90,40) $totalresult = GUICtrlCreateLabel("", 540, 20, 70, 50, 0x1000) GUICtrlSetFont($totalresult, 28, 850, "", "Comic Sans MS") GUICtrlCreateLabel ("PRESETS", 720, 5, 50,20) $preset = GUICtrlCreateInput ("", 720, 30, 50, 20) $save = GUICtrlCreateButton ("Save", 660, 65, 85, 30) $load = GUICtrlCreateButton ("Load",750, 65, 85, 30) $delete = GUICtrlCreateButton ("Delete",660, 115, 85, 30) $view = GUICtrlCreateButton ("View Presets",750, 115, 85, 30) $butall = GUICtrlCreateButton ("Check All Dice", 665, 195,80,30) $butnone = GUICtrlCreateButton ("Unheck All Dice", 755, 195,80,30) $but4 = GUICtrlCreateButton ("4", 665, 235,30,30) $but6 = GUICtrlCreateButton ("6", 710, 235,30,30) $but8 = GUICtrlCreateButton ("8", 755, 235,30,30) $but10 = GUICtrlCreateButton ("10", 800, 235,30,30) $but12 = GUICtrlCreateButton ("12", 665, 275,30,30) $but20 = GUICtrlCreateButton ("20", 710, 275,30,30) $but30 = GUICtrlCreateButton ("30", 755, 275,30,30) $but100 = GUICtrlCreateButton ("100", 800, 275,30,30) GUISetState() Do $msg = GUIGetMsg() if $msg = $roll then if GUICtrlRead($check1) = $GUI_CHECKED then call("_RollDie1") else GUICtrlSetData($result1,"") endif if GUICtrlRead($check2) = $GUI_CHECKED then call("_RollDie2") else GUICtrlSetData($result2, "") endif if GUICtrlRead($check3) = $GUI_CHECKED then call("_RollDie3") else GUICtrlSetData($result3, "") endif if GUICtrlRead($check4) = $GUI_CHECKED then call("_RollDie4") else GUICtrlSetData($result4, "") endif if GUICtrlRead($check5) = $GUI_CHECKED then call("_RollDie5") else GUICtrlSetData($result5, "") endif if GUICtrlRead($check6) = $GUI_CHECKED then call("_RollDie6") else GUICtrlSetData($result6, "") endif if $drop = $GUI_CHECKED Then call("_LowestRoll") GUICtrlSetData($totalresult,GUICtrlRead($result1) + GUICtrlRead($result2) + GUICtrlRead($result3)+ GUICtrlRead($result4)+ GUICtrlRead($result5)+ GUICtrlRead($result6)- GUICtrlRead($hiddeninput)) else GUICtrlSetData($totalresult,GUICtrlRead($result1) + GUICtrlRead($result2) + GUICtrlRead($result3)+ GUICtrlRead($result4)+ GUICtrlRead($result5)+ GUICtrlRead($result6)) endif endif if $msg = $butall then GUICtrlSetState($check1,$GUI_CHECKED) GUICtrlSetState($check2,$GUI_CHECKED) GUICtrlSetState($check3,$GUI_CHECKED) GUICtrlSetState($check4,$GUI_CHECKED) GUICtrlSetState($check5,$GUI_CHECKED) GUICtrlSetState($check6,$GUI_CHECKED) endif if $msg = $butnone then GUICtrlSetState($check1,$GUI_UNCHECKED) GUICtrlSetState($check2,$GUI_UNCHECKED) GUICtrlSetState($check3,$GUI_UNCHECKED) GUICtrlSetState($check4,$GUI_UNCHECKED) GUICtrlSetState($check5,$GUI_UNCHECKED) GUICtrlSetState($check6,$GUI_UNCHECKED) endif if $msg = $but4 then GUICtrlSetData($sides1,4) GUICtrlSetData($sides2,4) GUICtrlSetData($sides3,4) GUICtrlSetData($sides4,4) GUICtrlSetData($sides5,4) GUICtrlSetData($sides6,4) endif if $msg = $but6 then GUICtrlSetData($sides1,6) GUICtrlSetData($sides2,6) GUICtrlSetData($sides3,6) GUICtrlSetData($sides4,6) GUICtrlSetData($sides5,6) GUICtrlSetData($sides6,6) endif if $msg = $but8 then GUICtrlSetData($sides1,8) GUICtrlSetData($sides2,8) GUICtrlSetData($sides3,8) GUICtrlSetData($sides4,8) GUICtrlSetData($sides5,8) GUICtrlSetData($sides6,8) endif if $msg = $but10 then GUICtrlSetData($sides1,10) GUICtrlSetData($sides2,10) GUICtrlSetData($sides3,10) GUICtrlSetData($sides4,10) GUICtrlSetData($sides5,10) GUICtrlSetData($sides6,10) endif if $msg = $but12 then GUICtrlSetData($sides1,12) GUICtrlSetData($sides2,12) GUICtrlSetData($sides3,12) GUICtrlSetData($sides4,12) GUICtrlSetData($sides5,12) GUICtrlSetData($sides6,12) endif if $msg = $but20 then GUICtrlSetData($sides1,20) GUICtrlSetData($sides2,20) GUICtrlSetData($sides3,20) GUICtrlSetData($sides4,20) GUICtrlSetData($sides5,20) GUICtrlSetData($sides6,20) endif if $msg = $but30 then GUICtrlSetData($sides1,30) GUICtrlSetData($sides2,30) GUICtrlSetData($sides3,30) GUICtrlSetData($sides4,30) GUICtrlSetData($sides5,30) GUICtrlSetData($sides6,30) endif if $msg = $but100 then GUICtrlSetData($sides1,100) GUICtrlSetData($sides2,100) GUICtrlSetData($sides3,100) GUICtrlSetData($sides4,100) GUICtrlSetData($sides5,100) GUICtrlSetData($sides6,100) endif if $msg = $save then $chkpreset = FileExists("ini/" & (GUICtrlRead($preset)) & ".ini") if $chkpreset = 0 Then if GUICtrlRead($check1) = $GUI_CHECKED then $die1checked = 1 else $die1checked = 0 endif if GUICtrlRead($check2) = $GUI_CHECKED then $die2checked = 1 else $die2checked = 0 endif if GUICtrlRead($check3) = $GUI_CHECKED then $die3checked = 1 else $die3checked = 0 endif Filecopy("ini/template.ini", "ini/" & (GUICtrlRead($preset)) & ".ini") IniWrite("ini/Presets.ini", "Presets", (GUICtrlRead($preset)), (GUICtrlRead($preset))) IniWrite("ini/" & (GUICtrlRead($preset)) & ".ini", "Die1", "Checked", $die1checked) IniWrite("ini/" & (GUICtrlRead($preset)) & ".ini", "Die2", "Checked", $die2checked) IniWrite("ini/" & (GUICtrlRead($preset)) & ".ini", "Die3", "Checked", $die3checked) IniWrite("ini/" & (GUICtrlRead($preset)) & ".ini", "Die1", "Sides", (GUICtrlRead($sides1))) IniWrite("ini/" & (GUICtrlRead($preset)) & ".ini", "Die2", "Sides", (GUICtrlRead($sides2))) IniWrite("ini/" & (GUICtrlRead($preset)) & ".ini", "Die3", "Sides", (GUICtrlRead($sides3))) IniWrite("ini/" & (GUICtrlRead($preset)) & ".ini", "Die1", "Sign", (GUICtrlRead($sign1))) IniWrite("ini/" & (GUICtrlRead($preset)) & ".ini", "Die2", "Sign", (GUICtrlRead($sign2))) IniWrite("ini/" & (GUICtrlRead($preset)) & ".ini", "Die3", "Sign", (GUICtrlRead($sign3))) IniWrite("ini/" & (GUICtrlRead($preset)) & ".ini", "Die1", "Modifier", (GUICtrlRead($modifier1))) IniWrite("ini/" & (GUICtrlRead($preset)) & ".ini", "Die2", "Modifier", (GUICtrlRead($modifier2))) IniWrite("ini/" & (GUICtrlRead($preset)) & ".ini", "Die3", "Modifier", (GUICtrlRead($modifier3))) MsgBox(64, "Saved", "Your preset has been saved") else $replace = MsgBox(4, "Attention", "This preset already exists, replace?") if $replace = 6 then if GUICtrlRead($check1) = $GUI_CHECKED then $die1checked = 1 else $die1checked = 0 endif if GUICtrlRead($check2) = $GUI_CHECKED then $die2checked = 1 else $die2checked = 0 endif if GUICtrlRead($check3) = $GUI_CHECKED then $die3checked = 1 else $die3checked = 0 endif IniWrite("ini/" & (GUICtrlRead($preset)) & ".ini", "Die1", "Checked", $die1checked) IniWrite("ini/" & (GUICtrlRead($preset)) & ".ini", "Die2", "Checked", $die2checked) IniWrite("ini/" & (GUICtrlRead($preset)) & ".ini", "Die3", "Checked", $die3checked) IniWrite("ini/" & (GUICtrlRead($preset)) & ".ini", "Die1", "Sides", (GUICtrlRead($sides1))) IniWrite("ini/" & (GUICtrlRead($preset)) & ".ini", "Die2", "Sides", (GUICtrlRead($sides2))) IniWrite("ini/" & (GUICtrlRead($preset)) & ".ini", "Die3", "Sides", (GUICtrlRead($sides3))) IniWrite("ini/" & (GUICtrlRead($preset)) & ".ini", "Die1", "Sign", (GUICtrlRead($sign1))) IniWrite("ini/" & (GUICtrlRead($preset)) & ".ini", "Die2", "Sign", (GUICtrlRead($sign2))) IniWrite("ini/" & (GUICtrlRead($preset)) & ".ini", "Die3", "Sign", (GUICtrlRead($sign3))) IniWrite("ini/" & (GUICtrlRead($preset)) & ".ini", "Die1", "Modifier", (GUICtrlRead($modifier1))) IniWrite("ini/" & (GUICtrlRead($preset)) & ".ini", "Die2", "Modifier", (GUICtrlRead($modifier2))) IniWrite("ini/" & (GUICtrlRead($preset)) & ".ini", "Die3", "Modifier", (GUICtrlRead($modifier3))) MsgBox(64, "Saved", "Your preset has been saved") endif endif endif if $msg = $load then $chkpreset = FileExists("ini/" & (GUICtrlRead($preset)) & ".ini") if $chkpreset = 0 Then MsgBox (48, "Error", "That preset does not exist.") else $die1readchecked = IniRead("ini/" & (GUICtrlRead($preset)) & ".ini", "Die1", "Checked", 42) $die1readsides = IniRead("ini/" & (GUICtrlRead($preset)) & ".ini", "Die1", "Sides", 42) $die1readsign = IniRead("ini/" & (GUICtrlRead($preset)) & ".ini", "Die1", "Sign", 42) $die1readmodifier = IniRead("ini/" & (GUICtrlRead($preset)) & ".ini", "Die1", "Modifier", 42) $die2readchecked = IniRead("ini/" & (GUICtrlRead($preset)) & ".ini", "Die2", "Checked", 42) $die2readsides = IniRead("ini/" & (GUICtrlRead($preset)) & ".ini", "Die2", "Sides", 42) $die2readsign = IniRead("ini/" & (GUICtrlRead($preset)) & ".ini", "Die2", "Sign", 42) $die2readmodifier = IniRead("ini/" & (GUICtrlRead($preset)) & ".ini", "Die2", "Modifier", 42) $die3readchecked = IniRead("ini/" & (GUICtrlRead($preset)) & ".ini", "Die3", "Checked", 42) $die3readsides = IniRead("ini/" & (GUICtrlRead($preset)) & ".ini", "Die3", "Sides", 42) $die3readsign = IniRead("ini/" & (GUICtrlRead($preset)) & ".ini", "Die3", "Sign", 42) $die3readmodifier = IniRead("ini/" & (GUICtrlRead($preset)) & ".ini", "Die3", "Modifier", 42) if $die1readchecked = 1 then GUICtrlSetState($check1,$GUI_CHECKED) elseif $die1readchecked <> 1 then GUICtrlSetState($check1,$GUI_UNCHECKED) endif if $die2readchecked = 1 then GUICtrlSetState($check2,$GUI_CHECKED) elseif $die2readchecked <> 1 then GUICtrlSetState($check2,$GUI_UNCHECKED) endif if $die3readchecked = 1 then GUICtrlSetState($check3,$GUI_CHECKED) elseif $die3readchecked <> 1 then GUICtrlSetState($check3,$GUI_UNCHECKED) endif GUICtrlSetData($sides1, $die1readsides) GUICtrlSetData($sides2, $die2readsides) GUICtrlSetData($sides3, $die3readsides) GUICtrlSetData($sign1, $die1readsign) GUICtrlSetData($sign2, $die2readsign) GUICtrlSetData($sign3, $die3readsign) GUICtrlSetData($modifier1, $die1readmodifier) GUICtrlSetData($modifier2, $die2readmodifier) GUICtrlSetData($modifier3, $die3readmodifier) GUICtrlSetData($result1,"") GUICtrlSetData($result2,"") GUICtrlSetData($result3,"") endif endif if $msg = $delete then $chkpreset = FileExists("ini/" & (GUICtrlRead($preset)) & ".ini") if $chkpreset = 0 Then MsgBox (48, "Error", "That preset does not exist.") else IniDelete("ini/Presets.ini", "Presets", (GUICtrlRead($preset))) FileDelete("ini/" & (GUICtrlRead($preset)) & ".ini") MsgBox (64, "Deleted", "That preset has been deleted.") endif endif if $msg = $view then $presetlog = IniReadSection("ini/Presets.ini", "Presets") if @error then MsgBox (48, "Error", "No presets have been saved.") else $child1 = GUICreate("Saved Presets",200,200,-1,-1,-1,-1,$parent) $listview = GUICtrlCreateListView ("Preset ID",10,10,185,160,$LVS_REPORT) for $i = 1 to $presetlog[0][0] GUICtrlCreateListViewItem($presetlog[$i][1],$listview) next GUISetState() Do $msg1 = GUIGetMsg() Until $msg1 = $GUI_EVENT_CLOSE GUIDelete($child1) endif endif if $msg = $aboutitem then $child2 = GUICreate("About",220, 220,-1,-1,-1,$WS_EX_ACCEPTFILES,$parent) $font = "Ariel" Opt("RunErrorsFatal", 0) GUICtrlCreateLabel ("Dice Roller v1.0", 65, 30, 150,30) GUICtrlSetFont (-1,10, 400, $font) GUICtrlCreateIcon("icons\dice.ico",-1,90,60,48,48) GUICtrlCreateLabel ("by Jared Epstein", 65, 120, 150,30) GUICtrlSetFont (-1,10, 400, $font) $aboutok = GUICtrlCreateButton ("OK", 75, 170, 75,25) GUISetState() Do $msg2 = GUIGetMsg() if $msg2 = $aboutok then ExitLoop endif Until $msg2 = $GUI_EVENT_CLOSE GUIDelete($child2) endif if $msg = $resetitem then GUICtrlSetState($check1,$GUI_CHECKED) GUICtrlSetState($check2,$GUI_UNCHECKED) GUICtrlSetState($check3,$GUI_UNCHECKED) GUICtrlSetState($check4,$GUI_CHECKED) GUICtrlSetState($check5,$GUI_UNCHECKED) GUICtrlSetState($check6,$GUI_UNCHECKED) GUICtrlSetState($drop,$GUI_UNCHECKED) GUICtrlSetState($reroll,$GUI_UNCHECKED) GUICtrlSetState($add1,$GUI_UNCHECKED) GUICtrlSetState($add2,$GUI_UNCHECKED) GUICtrlSetData($sides1, 6) GUICtrlSetData($sides2, 6) GUICtrlSetData($sides3, 6) GUICtrlSetData($sides4, 6) GUICtrlSetData($sides5, 6) GUICtrlSetData($sides6, 6) GUICtrlSetData($sign1, "+") GUICtrlSetData($sign2, "+") GUICtrlSetData($sign3, "+") GUICtrlSetData($sign4, "+") GUICtrlSetData($sign5, "+") GUICtrlSetData($sign6, "+") GUICtrlSetData($modifier1, 0) GUICtrlSetData($modifier2, 0) GUICtrlSetData($modifier3, 0) GUICtrlSetData($modifier4, 0) GUICtrlSetData($modifier5, 0) GUICtrlSetData($modifier6, 0) GUICtrlSetData($result1,"") GUICtrlSetData($result2,"") GUICtrlSetData($result3,"") GUICtrlSetData($result4,"") GUICtrlSetData($result5,"") GUICtrlSetData($result6,"") GUICtrlSetData($totalresult,"") endif if $msg = $exititem then ExitLoop endif Until $msg = $GUI_EVENT_CLOSE GUIDelete() expandcollapse popupFunc _RollDie1() if GUICtrlRead($sides1) = 4 then $d4 = Random (1,4,1) if GUICtrlRead($sign1) = "+" then $d4a = $d4 + GUICtrlRead($modifier1) elseif GUICtrlRead($sign1) = "-" then $d4a = $d4 - GUICtrlRead($modifier1) endif GUICtrlSetData($result1,$d4a) elseif GUICtrlRead($sides1) = 6 then $d6 = Random (1,6,1) if GUICtrlRead($sign1) = "+" then $d6a = $d6 + GUICtrlRead($modifier1) elseif GUICtrlRead($sign1) = "-" then $d6a = $d6 - GUICtrlRead($modifier1) endif GUICtrlSetData($result1,$d6a) elseif GUICtrlRead($sides1) = 8 then $d8 = Random (1,8,1) if GUICtrlRead($sign1) = "+" then $d8a = $d8 + GUICtrlRead($modifier1) elseif GUICtrlRead($sign1) = "-" then $d8a = $d8 - GUICtrlRead($modifier1) endif GUICtrlSetData($result1,$d8a) elseif GUICtrlRead($sides1) = 10 then $d10 = Random (1,10,1) if GUICtrlRead($sign1) = "+" then $d10a = $d10 + GUICtrlRead($modifier1) elseif GUICtrlRead($sign1) = "-" then $d10a = $d10 - GUICtrlRead($modifier1) endif GUICtrlSetData($result1,$d10a) elseif GUICtrlRead($sides1) = 12 then $d12 = Random (1,12,1) if GUICtrlRead($sign1) = "+" then $d12a = $d12 + GUICtrlRead($modifier1) elseif GUICtrlRead($sign1) = "-" then $d12a = $d12 - GUICtrlRead($modifier1) endif GUICtrlSetData($result1,$d12a) elseif GUICtrlRead($sides1) = 20 then $d20 = Random (1,20,1) if GUICtrlRead($sign1) = "+" then $d20a = $d20 + GUICtrlRead($modifier1) elseif GUICtrlRead($sign1) = "-" then $d20a = $d20 - GUICtrlRead($modifier1) endif GUICtrlSetData($result1,$d20a) elseif GUICtrlRead($sides1) = 30 then $d30 = Random (1,30,1) if GUICtrlRead($sign1) = "+" then $d30a = $d30 + GUICtrlRead($modifier1) elseif GUICtrlRead($sign1) = "-" then $d30a = $d30 - GUICtrlRead($modifier1) endif GUICtrlSetData($result1,$d30a) elseif GUICtrlRead($sides1) = 100 then $d100 = Random (1,100,1) if GUICtrlRead($sign1) = "+" then $d100a = $d100 + GUICtrlRead($modifier1) elseif GUICtrlRead($sign1) = "-" then $d100a = $d100 - GUICtrlRead($modifier1) endif GUICtrlSetData($result1,$d100a) endif endfunc Func _RollDie2() if GUICtrlRead($sides2) = 4 then $d4 = Random (1,4,1) if GUICtrlRead($sign2) = "+" then $d4a = $d4 + GUICtrlRead($modifier2) elseif GUICtrlRead($sign2) = "-" then $d4a = $d4 - GUICtrlRead($modifier2) endif GUICtrlSetData($result2,$d4a) elseif GUICtrlRead($sides2) = 6 then $d6 = Random (1,6,1) if GUICtrlRead($sign2) = "+" then $d6a = $d6 + GUICtrlRead($modifier2) elseif GUICtrlRead($sign2) = "-" then $d6a = $d6 - GUICtrlRead($modifier2) endif GUICtrlSetData($result2,$d6a) elseif GUICtrlRead($sides2) = 8 then $d8 = Random (1,8,1) if GUICtrlRead($sign2) = "+" then $d8a = $d8 + GUICtrlRead($modifier2) elseif GUICtrlRead($sign2) = "-" then $d8a = $d8 - GUICtrlRead($modifier2) endif GUICtrlSetData($result2,$d8a) elseif GUICtrlRead($sides2) = 10 then $d10 = Random (1,10,1) if GUICtrlRead($sign2) = "+" then $d10a = $d10 + GUICtrlRead($modifier2) elseif GUICtrlRead($sign2) = "-" then $d10a = $d10 - GUICtrlRead($modifier2) endif GUICtrlSetData($result2,$d10a) elseif GUICtrlRead($sides2) = 12 then $d12 = Random (1,12,1) if GUICtrlRead($sign2) = "+" then $d12a = $d12 + GUICtrlRead($modifier2) elseif GUICtrlRead($sign2) = "-" then $d12a = $d12 - GUICtrlRead($modifier2) endif GUICtrlSetData($result2,$d12a) elseif GUICtrlRead($sides2) = 20 then $d20 = Random (1,20,1) if GUICtrlRead($sign2) = "+" then $d20a = $d20 + GUICtrlRead($modifier2) elseif GUICtrlRead($sign2) = "-" then $d20a = $d20 - GUICtrlRead($modifier2) endif GUICtrlSetData($result2,$d20a) elseif GUICtrlRead($sides2) = 30 then $d30 = Random (1,30,1) if GUICtrlRead($sign2) = "+" then $d30a = $d30 + GUICtrlRead($modifier2) elseif GUICtrlRead($sign2) = "-" then $d30a = $d30 - GUICtrlRead($modifier2) endif GUICtrlSetData($result2,$d30a) elseif GUICtrlRead($sides2) = 100 then $d100 = Random (1,100,1) if GUICtrlRead($sign2) = "+" then $d100a = $d100 + GUICtrlRead($modifier2) elseif GUICtrlRead($sign2) = "-" then $d100a = $d100 - GUICtrlRead($modifier2) endif GUICtrlSetData($result2,$d100a) endif endfunc Func _RollDie3() if GUICtrlRead($sides3) = 4 then $d4 = Random (1,4,1) if GUICtrlRead($sign3) = "+" then $d4a = $d4 + GUICtrlRead($modifier3) elseif GUICtrlRead($sign3) = "-" then $d4a = $d4 - GUICtrlRead($modifier3) endif GUICtrlSetData($result3,$d4a) elseif GUICtrlRead($sides3) = 6 then $d6 = Random (1,6,1) if GUICtrlRead($sign3) = "+" then $d6a = $d6 + GUICtrlRead($modifier3) elseif GUICtrlRead($sign3) = "-" then $d6a = $d6 - GUICtrlRead($modifier3) endif GUICtrlSetData($result3,$d6a) elseif GUICtrlRead($sides3) = 8 then $d8 = Random (1,8,1) if GUICtrlRead($sign3) = "+" then $d8a = $d8 + GUICtrlRead($modifier3) elseif GUICtrlRead($sign3) = "-" then $d8a = $d8 - GUICtrlRead($modifier3) endif GUICtrlSetData($result3,$d8a) elseif GUICtrlRead($sides3) = 10 then $d10 = Random (1,10,1) if GUICtrlRead($sign3) = "+" then $d10a = $d10 + GUICtrlRead($modifier3) elseif GUICtrlRead($sign3) = "-" then $d10a = $d10 - GUICtrlRead($modifier3) endif GUICtrlSetData($result3,$d10a) elseif GUICtrlRead($sides3) = 12 then $d12 = Random (1,12,1) if GUICtrlRead($sign3) = "+" then $d12a = $d12 + GUICtrlRead($modifier3) elseif GUICtrlRead($sign3) = "-" then $d12a = $d12 - GUICtrlRead($modifier3) endif GUICtrlSetData($result3,$d12a) elseif GUICtrlRead($sides3) = 20 then $d20 = Random (1,20,1) if GUICtrlRead($sign3) = "+" then $d20a = $d20 + GUICtrlRead($modifier3) elseif GUICtrlRead($sign3) = "-" then $d20a = $d20 - GUICtrlRead($modifier3) endif GUICtrlSetData($result3,$d20a) elseif GUICtrlRead($sides3) = 30 then $d30 = Random (1,30,1) if GUICtrlRead($sign3) = "+" then $d30a = $d30 + GUICtrlRead($modifier3) elseif GUICtrlRead($sign3) = "-" then $d30a = $d30 - GUICtrlRead($modifier3) endif GUICtrlSetData($result3,$d30a) elseif GUICtrlRead($sides3) = 100 then $d100 = Random (1,100,1) if GUICtrlRead($sign3) = "+" then $d100a = $d100 + GUICtrlRead($modifier3) elseif GUICtrlRead($sign3) = "-" then $d100a = $d100 - GUICtrlRead($modifier3) endif GUICtrlSetData($result3,$d100a) endif endfunc Func _RollDie4() if GUICtrlRead($sides4) = 4 then $d4 = Random (1,4,1) if GUICtrlRead($sign4) = "+" then $d4a = $d4 + GUICtrlRead($modifier4) elseif GUICtrlRead($sign4) = "-" then $d4a = $d4 - GUICtrlRead($modifier4) endif GUICtrlSetData($result4,$d4a) elseif GUICtrlRead($sides4) = 6 then $d6 = Random (1,6,1) if GUICtrlRead($sign4) = "+" then $d6a = $d6 + GUICtrlRead($modifier4) elseif GUICtrlRead($sign4) = "-" then $d6a = $d6 - GUICtrlRead($modifier4) endif GUICtrlSetData($result4,$d6a) elseif GUICtrlRead($sides4) = 8 then $d8 = Random (1,8,1) if GUICtrlRead($sign4) = "+" then $d8a = $d8 + GUICtrlRead($modifier4) elseif GUICtrlRead($sign4) = "-" then $d8a = $d8 - GUICtrlRead($modifier4) endif GUICtrlSetData($result4,$d8a) elseif GUICtrlRead($sides4) = 10 then $d10 = Random (1,10,1) if GUICtrlRead($sign4) = "+" then $d10a = $d10 + GUICtrlRead($modifier4) elseif GUICtrlRead($sign4) = "-" then $d10a = $d10 - GUICtrlRead($modifier4) endif GUICtrlSetData($result4,$d10a) elseif GUICtrlRead($sides4) = 12 then $d12 = Random (1,12,1) if GUICtrlRead($sign4) = "+" then $d12a = $d12 + GUICtrlRead($modifier4) elseif GUICtrlRead($sign4) = "-" then $d12a = $d12 - GUICtrlRead($modifier4) endif GUICtrlSetData($result4,$d12a) elseif GUICtrlRead($sides4) = 20 then $d20 = Random (1,20,1) if GUICtrlRead($sign4) = "+" then $d20a = $d20 + GUICtrlRead($modifier4) elseif GUICtrlRead($sign4) = "-" then $d20a = $d20 - GUICtrlRead($modifier4) endif GUICtrlSetData($result4,$d20a) elseif GUICtrlRead($sides4) = 30 then $d30 = Random (1,30,1) if GUICtrlRead($sign4) = "+" then $d30a = $d30 + GUICtrlRead($modifier4) elseif GUICtrlRead($sign4) = "-" then $d30a = $d30 - GUICtrlRead($modifier4) endif GUICtrlSetData($result4,$d30a) elseif GUICtrlRead($sides4) = 100 then $d100 = Random (1,100,1) if GUICtrlRead($sign4) = "+" then $d100a = $d100 + GUICtrlRead($modifier4) elseif GUICtrlRead($sign4) = "-" then $d100a = $d100 - GUICtrlRead($modifier4) endif GUICtrlSetData($result4,$d100a) endif endfunc Func _RollDie5() if GUICtrlRead($sides5) = 4 then $d4 = Random (1,4,1) if GUICtrlRead($sign5) = "+" then $d4a = $d4 + GUICtrlRead($modifier5) elseif GUICtrlRead($sign5) = "-" then $d4a = $d4 - GUICtrlRead($modifier5) endif GUICtrlSetData($result5,$d4a) elseif GUICtrlRead($sides5) = 6 then $d6 = Random (1,6,1) if GUICtrlRead($sign5) = "+" then $d6a = $d6 + GUICtrlRead($modifier5) elseif GUICtrlRead($sign5) = "-" then $d6a = $d6 - GUICtrlRead($modifier5) endif GUICtrlSetData($result5,$d6a) elseif GUICtrlRead($sides5) = 8 then $d8 = Random (1,8,1) if GUICtrlRead($sign5) = "+" then $d8a = $d8 + GUICtrlRead($modifier5) elseif GUICtrlRead($sign5) = "-" then $d8a = $d8 - GUICtrlRead($modifier5) endif GUICtrlSetData($result5,$d8a) elseif GUICtrlRead($sides5) = 10 then $d10 = Random (1,10,1) if GUICtrlRead($sign5) = "+" then $d10a = $d10 + GUICtrlRead($modifier5) elseif GUICtrlRead($sign3) = "-" then $d10a = $d10 - GUICtrlRead($modifier5) endif GUICtrlSetData($result5,$d10a) elseif GUICtrlRead($sides5) = 12 then $d12 = Random (1,12,1) if GUICtrlRead($sign5) = "+" then $d12a = $d12 + GUICtrlRead($modifier5) elseif GUICtrlRead($sign5) = "-" then $d12a = $d12 - GUICtrlRead($modifier5) endif GUICtrlSetData($result5,$d12a) elseif GUICtrlRead($sides5) = 20 then $d20 = Random (1,20,1) if GUICtrlRead($sign5) = "+" then $d20a = $d20 + GUICtrlRead($modifier5) elseif GUICtrlRead($sign5) = "-" then $d20a = $d20 - GUICtrlRead($modifier5) endif GUICtrlSetData($result5,$d20a) elseif GUICtrlRead($sides5) = 30 then $d30 = Random (1,30,1) if GUICtrlRead($sign5) = "+" then $d30a = $d30 + GUICtrlRead($modifier5) elseif GUICtrlRead($sign5) = "-" then $d30a = $d30 - GUICtrlRead($modifier5) endif GUICtrlSetData($result5,$d30a) elseif GUICtrlRead($sides5) = 100 then $d100 = Random (1,100,1) if GUICtrlRead($sign5) = "+" then $d100a = $d100 + GUICtrlRead($modifier5) elseif GUICtrlRead($sign5) = "-" then $d100a = $d100 - GUICtrlRead($modifier5) endif GUICtrlSetData($result5,$d100a) endif endfunc Func _RollDie6() if GUICtrlRead($sides6) = 4 then $d4 = Random (1,4,1) if GUICtrlRead($sign6) = "+" then $d4a = $d4 + GUICtrlRead($modifier6) elseif GUICtrlRead($sign6) = "-" then $d4a = $d4 - GUICtrlRead($modifier6) endif GUICtrlSetData($result6,$d4a) elseif GUICtrlRead($sides6) = 6 then $d6 = Random (1,6,1) if GUICtrlRead($sign6) = "+" then $d6a = $d6 + GUICtrlRead($modifier6) elseif GUICtrlRead($sign6) = "-" then $d6a = $d6 - GUICtrlRead($modifier6) endif GUICtrlSetData($result6,$d6a) elseif GUICtrlRead($sides6) = 8 then $d8 = Random (1,8,1) if GUICtrlRead($sign6) = "+" then $d8a = $d8 + GUICtrlRead($modifier6) elseif GUICtrlRead($sign6) = "-" then $d8a = $d8 - GUICtrlRead($modifier6) endif GUICtrlSetData($result3,$d8a) elseif GUICtrlRead($sides6) = 10 then $d10 = Random (1,10,1) if GUICtrlRead($sign6) = "+" then $d10a = $d10 + GUICtrlRead($modifier6) elseif GUICtrlRead($sign6) = "-" then $d10a = $d10 - GUICtrlRead($modifier6) endif GUICtrlSetData($result3,$d10a) elseif GUICtrlRead($sides6) = 12 then $d12 = Random (1,12,1) if GUICtrlRead($sign6) = "+" then $d12a = $d12 + GUICtrlRead($modifier6) elseif GUICtrlRead($sign6) = "-" then $d12a = $d12 - GUICtrlRead($modifier6) endif GUICtrlSetData($result3,$d12a) elseif GUICtrlRead($sides6) = 20 then $d20 = Random (1,20,1) if GUICtrlRead($sign6) = "+" then $d20a = $d20 + GUICtrlRead($modifier6) elseif GUICtrlRead($sign6) = "-" then $d20a = $d20 - GUICtrlRead($modifier6) endif GUICtrlSetData($result6,$d20a) elseif GUICtrlRead($sides6) = 30 then $d30 = Random (1,30,1) if GUICtrlRead($sign6) = "+" then $d30a = $d30 + GUICtrlRead($modifier6) elseif GUICtrlRead($sign6) = "-" then $d30a = $d30 - GUICtrlRead($modifier6) endif GUICtrlSetData($result6,$d30a) elseif GUICtrlRead($sides6) = 100 then $d100 = Random (1,100,1) if GUICtrlRead($sign6) = "+" then $d100a = $d100 + GUICtrlRead($modifier6) elseif GUICtrlRead($sign6) = "-" then $d100a = $d100 - GUICtrlRead($modifier6) endif GUICtrlSetData($result6,$d100a) endif endfunc Func _LowestRoll() endfunc Func _HighestRoll() endfunc [u]You can download my projects at:[/u] Pulsar Software
tmo Posted January 4, 2007 Posted January 4, 2007 (edited) Func _Lowest($aiNumbers) Local $iMin = $aiNumbers[0] For $i = 1To Ubound($aiNumbers)-1 If $aiNumbers[$i] < $iMin Then $iMin = $aiNumbers[$i] Next Return $iMin EndFunc same works for the highest, just use > instead of < the numbers of which you want to determinate the lowest have to be given in an array. Edited January 4, 2007 by tmo
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