vin1 0 Posted June 3, 2013 Share Posted June 3, 2013 (edited) expandcollapse popup#include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <StaticConstants.au3> _Main() Func _Main() Local $button1 Local $output, $die, $msg, $results1, $results2, $results3, $results4, $results5, $results6 GUICreate("random item stats", 700, 180, -1, -1) $button1 = GUICtrlCreateButton("Generate", 150, 90, 50, 30) $output1 = GUICtrlCreateInput("", 60, 60, 60, 20, BitOR($ES_CENTER, $ES_READONLY)) $output2 = GUICtrlCreateInput("", 130, 60, 60, 20, BitOR($ES_CENTER, $ES_READONLY)) $output3 = GUICtrlCreateInput("", 200, 60, 60, 20, BitOR($ES_CENTER, $ES_READONLY)) $output4 = GUICtrlCreateInput("", 270, 60, 60, 20, BitOR($ES_CENTER, $ES_READONLY)) $output5 = GUICtrlCreateInput("", 340, 60, 60, 20, BitOR($ES_CENTER, $ES_READONLY)) $output6 = GUICtrlCreateInput("", 410, 60, 60, 20, BitOR($ES_CENTER, $ES_READONLY)) $die = GUICtrlCreateLabel("", 905, 120, 70, 20, $SS_SUNKEN) GUICtrlSetFont($output, 8, 800, "", "Comic Sans MS") GUISetState() ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Select Case $msg = $button1 $results1 = Random(1, 1, 1) GUICtrlSetData($output1, $results1) GUICtrlSetData($die, "2 Sided Die") $results2 = Random(1, 3, 1) GUICtrlSetData($output2, $results2) GUICtrlSetData($die, "3 Sided Die") $results3 = Random(1, 4, 1) GUICtrlSetData($output3, $results3) GUICtrlSetData($die, "4 Sided Die") $results4 = Random(1, 6, 1) GUICtrlSetData($output4, $results4) GUICtrlSetData($die, "6 Sided Die") $results5 = Random(1, 8, 1) GUICtrlSetData($output5, $results5) GUICtrlSetData($die, "8 Sided Die") $results6 = Random(1, 10, 1) GUICtrlSetData($output6, $results6) GUICtrlSetData($die, "10 Sided Die") EndSelect If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd EndFunc ;==>_Main i ended up creating a random number generator but now i need there to be a list of possible results to randomize from how can i make it so it generates a result from a list of possible results numgen.au3 Edited June 3, 2013 by vin1 Link to post Share on other sites
DW1 102 Posted June 3, 2013 Share Posted June 3, 2013 The easiest way would be to just toss the results in to an array. expandcollapse popup#include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <StaticConstants.au3> Global $resultdata[10]=["result one", "result two", "result three", "result four", "result five", _ "result six", "result seven", "result eight", "result nine", "result ten"] _Main() Func _Main() Local $button1 Local $output, $die, $msg, $results1, $results2, $results3, $results4, $results5, $results6 GUICreate("random item stats", 700, 180, -1, -1) $button1 = GUICtrlCreateButton("Generate", 150, 90, 50, 30) $output1 = GUICtrlCreateInput("", 60, 60, 60, 20, BitOR($ES_CENTER, $ES_READONLY)) $output2 = GUICtrlCreateInput("", 130, 60, 60, 20, BitOR($ES_CENTER, $ES_READONLY)) $output3 = GUICtrlCreateInput("", 200, 60, 60, 20, BitOR($ES_CENTER, $ES_READONLY)) $output4 = GUICtrlCreateInput("", 270, 60, 60, 20, BitOR($ES_CENTER, $ES_READONLY)) $output5 = GUICtrlCreateInput("", 340, 60, 60, 20, BitOR($ES_CENTER, $ES_READONLY)) $output6 = GUICtrlCreateInput("", 410, 60, 60, 20, BitOR($ES_CENTER, $ES_READONLY)) $die = GUICtrlCreateLabel("", 905, 120, 70, 20, $SS_SUNKEN) GUICtrlSetFont($output, 8, 800, "", "Comic Sans MS") GUISetState() ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Select Case $msg = $button1 $results1 = Random(1, 2, 1) GUICtrlSetData($output1, $resultdata[$results1-1]) GUICtrlSetData($die, "2 Sided Die") $results2 = Random(1, 3, 1) GUICtrlSetData($output2, $resultdata[$results2-1]) GUICtrlSetData($die, "3 Sided Die") $results3 = Random(1, 4, 1) GUICtrlSetData($output3, $resultdata[$results3-1]) GUICtrlSetData($die, "4 Sided Die") $results4 = Random(1, 6, 1) GUICtrlSetData($output4, $resultdata[$results4-1]) GUICtrlSetData($die, "6 Sided Die") $results5 = Random(1, 8, 1) GUICtrlSetData($output5, $resultdata[$results5-1]) GUICtrlSetData($die, "8 Sided Die") $results6 = Random(1, 10, 1) GUICtrlSetData($output6, $resultdata[$results6-1]) GUICtrlSetData($die, "10 Sided Die") EndSelect If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd EndFunc ;==>_Main AutoIt3 Online Help Link to post Share on other sites
FireFox 261 Posted June 3, 2013 Share Posted June 3, 2013 (edited) Hi,Let's understand what you mean.If you want to generate a 3 length binary code, the possible results would be :000 001 010 011 100 101 110 111Is that right?Br, FireFox. Edited June 3, 2013 by FireFox OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDFMy Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme makerMy Examples : Capture tool | IP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewerMy Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control Link to post Share on other sites
vin1 0 Posted June 3, 2013 Author Share Posted June 3, 2013 The easiest way would be to just toss the results in to an array. expandcollapse popup#include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <StaticConstants.au3> Global $resultdata[10]=["result one", "result two", "result three", "result four", "result five", _ "result six", "result seven", "result eight", "result nine", "result ten"] _Main() Func _Main() Local $button1 Local $output, $die, $msg, $results1, $results2, $results3, $results4, $results5, $results6 GUICreate("random item stats", 700, 180, -1, -1) $button1 = GUICtrlCreateButton("Generate", 150, 90, 50, 30) $output1 = GUICtrlCreateInput("", 60, 60, 60, 20, BitOR($ES_CENTER, $ES_READONLY)) $output2 = GUICtrlCreateInput("", 130, 60, 60, 20, BitOR($ES_CENTER, $ES_READONLY)) $output3 = GUICtrlCreateInput("", 200, 60, 60, 20, BitOR($ES_CENTER, $ES_READONLY)) $output4 = GUICtrlCreateInput("", 270, 60, 60, 20, BitOR($ES_CENTER, $ES_READONLY)) $output5 = GUICtrlCreateInput("", 340, 60, 60, 20, BitOR($ES_CENTER, $ES_READONLY)) $output6 = GUICtrlCreateInput("", 410, 60, 60, 20, BitOR($ES_CENTER, $ES_READONLY)) $die = GUICtrlCreateLabel("", 905, 120, 70, 20, $SS_SUNKEN) GUICtrlSetFont($output, 8, 800, "", "Comic Sans MS") GUISetState() ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Select Case $msg = $button1 $results1 = Random(1, 2, 1) GUICtrlSetData($output1, $resultdata[$results1-1]) GUICtrlSetData($die, "2 Sided Die") $results2 = Random(1, 3, 1) GUICtrlSetData($output2, $resultdata[$results2-1]) GUICtrlSetData($die, "3 Sided Die") $results3 = Random(1, 4, 1) GUICtrlSetData($output3, $resultdata[$results3-1]) GUICtrlSetData($die, "4 Sided Die") $results4 = Random(1, 6, 1) GUICtrlSetData($output4, $resultdata[$results4-1]) GUICtrlSetData($die, "6 Sided Die") $results5 = Random(1, 8, 1) GUICtrlSetData($output5, $resultdata[$results5-1]) GUICtrlSetData($die, "8 Sided Die") $results6 = Random(1, 10, 1) GUICtrlSetData($output6, $resultdata[$results6-1]) GUICtrlSetData($die, "10 Sided Die") EndSelect If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd EndFunc ;==>_Main actually i want a list of results for each output box, what this does is it mixes up results between output boxes how do i make it so 1 result from the list1 it goes to output1 does this type work? Local $str $str &= '00' & @LF $str &= '01' & @LF $str &= '02' & @LF $str &= '03' & @LF $str &= '04' & @LF $str &= '05' & @LF $str &= '06' & @LF $str &= '07' & @LF $str &= '08' & @LF $str &= '09' & @LF $str &= '10' & @LF $str &= '11' & @LF $str &= '12' & @LF Link to post Share on other sites
FireFox 261 Posted June 3, 2013 Share Posted June 3, 2013 (edited) actually i want a list of results for each output box, what this does is it mixes up results between output boxesahhhhh. #include <WindowsConstants.au3> ;should work better with this. ;this is an example for the output1, reproduce it for the others. ;in your GUI $iRes1 = GUICtrlCreateEdit("", 60, 80, 60, 100, BitOR($ES_MULTILINE, $WS_VSCROLL)) ;in your loop GUICtrlSetData($iRes1, $results1 & @CrLf, 1)Edit: Or maybe:;in your GUI $iResMix = GUICtrlCreateEdit("", 60, 80, 410, 100, BitOR($ES_MULTILINE, $WS_VSCROLL)) ;in your loop GUICtrlSetData($iResMix, $results1 & $results2 & $results3 & $results4 & $results5 & $results6 & @CrLf, 1)Br, FireFox. Edited June 3, 2013 by FireFox OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDFMy Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme makerMy Examples : Capture tool | IP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewerMy Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control Link to post Share on other sites
Solution DW1 102 Posted June 3, 2013 Solution Share Posted June 3, 2013 I think I know what you are asking, but you could be more clear if not. I think you are asking to have each die have its own set of options, so rolling a 2 on a three sided die isn't the same result as rolling a 2 on a 4 sided die. If that's correct, just use multiple arrays. One for each die. If you are trying to keep them all in the same array, you could use a 2d array to store all of them as well. expandcollapse popup#include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <StaticConstants.au3> Global $result2s[2]=["result2 1", "result2 2"] Global $result3s[3]=["result3 1", "result3 2", "result3 3"] Global $result4s[4]=["result4 1", "result4 2", "result4 3", "result4 4"] Global $result6s[6]=["result6 1", "result6 2", "result6 3", "result6 4", "result6 5", "result6 6"] Global $result8s[8]=["result8 1", "result8 2", "result8 3", "result8 4", "result8 5", "result8 6", "result8 7", "result8 8"] Global $result10s[10]=["result10 1", "result10 2", "result10 3", "result10 4", "result10 5", _ "result10 6", "result10 7", "result10 8", "result10 9", "result10 10"] _Main() Func _Main() Local $button1 Local $output, $die, $msg, $results1, $results2, $results3, $results4, $results5, $results6 GUICreate("random item stats", 700, 180, -1, -1) $button1 = GUICtrlCreateButton("Generate", 150, 90, 50, 30) $output1 = GUICtrlCreateInput("", 60, 60, 60, 20, BitOR($ES_CENTER, $ES_READONLY)) $output2 = GUICtrlCreateInput("", 130, 60, 60, 20, BitOR($ES_CENTER, $ES_READONLY)) $output3 = GUICtrlCreateInput("", 200, 60, 60, 20, BitOR($ES_CENTER, $ES_READONLY)) $output4 = GUICtrlCreateInput("", 270, 60, 60, 20, BitOR($ES_CENTER, $ES_READONLY)) $output5 = GUICtrlCreateInput("", 340, 60, 60, 20, BitOR($ES_CENTER, $ES_READONLY)) $output6 = GUICtrlCreateInput("", 410, 60, 60, 20, BitOR($ES_CENTER, $ES_READONLY)) $die = GUICtrlCreateLabel("", 905, 120, 70, 20, $SS_SUNKEN) GUICtrlSetFont($output, 8, 800, "", "Comic Sans MS") GUISetState() ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Select Case $msg = $button1 $results1 = Random(1, 2, 1) GUICtrlSetData($output1, $result2s[$results1-1]) GUICtrlSetData($die, "2 Sided Die") $results2 = Random(1, 3, 1) GUICtrlSetData($output2, $result3s[$results2-1]) GUICtrlSetData($die, "3 Sided Die") $results3 = Random(1, 4, 1) GUICtrlSetData($output3, $result4s[$results3-1]) GUICtrlSetData($die, "4 Sided Die") $results4 = Random(1, 6, 1) GUICtrlSetData($output4, $result6s[$results4-1]) GUICtrlSetData($die, "6 Sided Die") $results5 = Random(1, 8, 1) GUICtrlSetData($output5, $result8s[$results5-1]) GUICtrlSetData($die, "8 Sided Die") $results6 = Random(1, 10, 1) GUICtrlSetData($output6, $result10s[$results6-1]) GUICtrlSetData($die, "10 Sided Die") EndSelect If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd EndFunc ;==>_Main AutoIt3 Online Help Link to post Share on other sites
vin1 0 Posted June 3, 2013 Author Share Posted June 3, 2013 ahhhhh. #include <WindowsConstants.au3> ;should work better with this. ;this is an example for the output1, reproduce it for the others. ;in your GUI $iRes1 = GUICtrlCreateEdit("", 60, 80, 60, 100, BitOR($ES_MULTILINE, $WS_VSCROLL)) ;in your loop GUICtrlSetData($iRes1, $results1 & @CrLf, 1) Edit: Or maybe:;in your GUI $iResMix = GUICtrlCreateEdit("", 60, 80, 410, 100, BitOR($ES_MULTILINE, $WS_VSCROLL)) ;in your loop GUICtrlSetData($iResMix, $results1 & $results2 & $results3 & $results4 & $results5 & $results6 & @CrLf, 1) Br, FireFox. i keep getting errors when i add those lines Link to post Share on other sites
FireFox 261 Posted June 3, 2013 Share Posted June 3, 2013 Have you added those lines in the right place? Have you understood the errors in order to fix them yourself? OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDFMy Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme makerMy Examples : Capture tool | IP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewerMy Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control Link to post Share on other sites
vin1 0 Posted June 3, 2013 Author Share Posted June 3, 2013 I think I know what you are asking, but you could be more clear if not. I think you are asking to have each die have its own set of options, so rolling a 2 on a three sided die isn't the same result as rolling a 2 on a 4 sided die. If that's correct, just use multiple arrays. One for each die. If you are trying to keep them all in the same array, you could use a 2d array to store all of them as well. expandcollapse popup#include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <StaticConstants.au3> Global $result2s[2]=["result2 1", "result2 2"] Global $result3s[3]=["result3 1", "result3 2", "result3 3"] Global $result4s[4]=["result4 1", "result4 2", "result4 3", "result4 4"] Global $result6s[6]=["result6 1", "result6 2", "result6 3", "result6 4", "result6 5", "result6 6"] Global $result8s[8]=["result8 1", "result8 2", "result8 3", "result8 4", "result8 5", "result8 6", "result8 7", "result8 8"] Global $result10s[10]=["result10 1", "result10 2", "result10 3", "result10 4", "result10 5", _ "result10 6", "result10 7", "result10 8", "result10 9", "result10 10"] _Main() Func _Main() Local $button1 Local $output, $die, $msg, $results1, $results2, $results3, $results4, $results5, $results6 GUICreate("random item stats", 700, 180, -1, -1) $button1 = GUICtrlCreateButton("Generate", 150, 90, 50, 30) $output1 = GUICtrlCreateInput("", 60, 60, 60, 20, BitOR($ES_CENTER, $ES_READONLY)) $output2 = GUICtrlCreateInput("", 130, 60, 60, 20, BitOR($ES_CENTER, $ES_READONLY)) $output3 = GUICtrlCreateInput("", 200, 60, 60, 20, BitOR($ES_CENTER, $ES_READONLY)) $output4 = GUICtrlCreateInput("", 270, 60, 60, 20, BitOR($ES_CENTER, $ES_READONLY)) $output5 = GUICtrlCreateInput("", 340, 60, 60, 20, BitOR($ES_CENTER, $ES_READONLY)) $output6 = GUICtrlCreateInput("", 410, 60, 60, 20, BitOR($ES_CENTER, $ES_READONLY)) $die = GUICtrlCreateLabel("", 905, 120, 70, 20, $SS_SUNKEN) GUICtrlSetFont($output, 8, 800, "", "Comic Sans MS") GUISetState() ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Select Case $msg = $button1 $results1 = Random(1, 2, 1) GUICtrlSetData($output1, $result2s[$results1-1]) GUICtrlSetData($die, "2 Sided Die") $results2 = Random(1, 3, 1) GUICtrlSetData($output2, $result3s[$results2-1]) GUICtrlSetData($die, "3 Sided Die") $results3 = Random(1, 4, 1) GUICtrlSetData($output3, $result4s[$results3-1]) GUICtrlSetData($die, "4 Sided Die") $results4 = Random(1, 6, 1) GUICtrlSetData($output4, $result6s[$results4-1]) GUICtrlSetData($die, "6 Sided Die") $results5 = Random(1, 8, 1) GUICtrlSetData($output5, $result8s[$results5-1]) GUICtrlSetData($die, "8 Sided Die") $results6 = Random(1, 10, 1) GUICtrlSetData($output6, $result10s[$results6-1]) GUICtrlSetData($die, "10 Sided Die") EndSelect If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd EndFunc ;==>_Main thanks alot it works Link to post Share on other sites
FireFox 261 Posted June 3, 2013 Share Posted June 3, 2013 (edited) If you want to learn you should try to fix the errors...My version:#include <GUIConstantsEx.au3> #include <EditConstants.au3> _Main() Func _Main() Local $hGUI = 0, $aiOutput[6], $iGen = 0 Local $aDices[UBound($aiOutput)] = [2, 3, 4, 6, 8, 10], $iMsg = 0, $iRes = 0 $hGUI = GUICreate("random item stats", 700, 180) For $i = 0 To UBound($aiOutput) -1 $aiOutput[$i] = GUICtrlCreateInput("", 60 + $i * 70, 60, 60, 20, BitOR($ES_CENTER, $ES_READONLY)) Next $iGen = GUICtrlCreateButton("Generate", 10, 10, 70, 30) GUISetState(@SW_SHOW, $hGUI) While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE ExitLoop Case $iGen For $i = 0 To UBound($aiOutput) -1 $iRes = Random(1, $aDices[$i], 1) GUICtrlSetData($aiOutput[$i], "Result" & $aDices[$i] & " " & $iRes) Next EndSwitch WEnd GUIDelete($hGUI) EndFunc ;==>_MainBr, FireFox. Edited June 3, 2013 by FireFox OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDFMy Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme makerMy Examples : Capture tool | IP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewerMy Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control Link to post Share on other sites
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