Jump to content

Need help "Rolling Up" a GUI, all the controls crowd the window


Zealot
 Share

Recommended Posts

Hi all,

I'm pretty new to auto it, and coding in general. I'm trying to modify Flanf's Dice Roller (with his knowledge) to suit my needs for gaming. I've done a bunch already, but I am having trouble getting the Roll Up and Roll Down functions to work right. Every time I resize the window using WinMove all of the controls crowd into the visible portion of the window. If you modify line 57 of the script and put in 30 instead of 405, you'll see what I would like it to look like with the window "rolled up".

I've come up with some possible solutions, but theres a couple of problems with them.

First, I could create a duplicate child window and hide the original. I'm not sure how I would pass the always on top state between them though, and I don't know if there will be any other problems.

Second, I could figure out some way to cycle through all the contolID's, and hide/disable the ones whose tops are >= 30. My main problem with this is that I have no idea how the controlIDs are assigned, or how to cycle through them. For all I know I may end up affecting some other window I have open.

Third, I could just brute force it and manually enable/disable, show/hide all the controls. This is my very, very last option. Way too much coding, and way too hard to maintain.

Does anyone know an easier way to do what I want? Please!

Thanks,

Z

Here is the code...

CODE

;~ Program: Odds and Evens

;~ Script Compiler: Autoit version: 3

;~ Author: Simon Goodson

;~ Email: zealott@hotmail.com

;~ Date: 7 Nov 2007

;~

;~ Based on: Flanf's Die Roller v1.6

;~ Coded by: Christoph Flandorfer

;~ Created on: 13 Sept 2006

;~ Script Function:

;~ A dice roller and card picker for use in RPGs or whatever

;~ Odds and Evens

;~ --------------

;~ v0.1 Renamed app to "Odds and Evens"

;~ Began redisign of GUI

;~ Adding "Stay on Top" feature

;~ Adding "Roll-up Window" feature

;~ Adding Fate Dice function

;~

;~ Flanf's Dice Roller

;~ -------------------

;- Version 1.6a: Switched the output window around to get more space for the dice buttons

;- Added a tab to perform d1 through d20 wild dice.

;- Added the d20 dice to the S.Worlds tab, mostly for asthetics

;- Moved the card functions to its own section

;- Implemented 3 decks, 1 always containing all the cards, 1 to pick 1 card at a time out, and

;- one to issue multiple cards for combat also with a function to pick singles if needed

;- Moved the sort function so that all the dice results could be sorted or not depending on preference

;- Generated a random number and used it to seed the random table

;- Added a bunch of remarks to help me (Simon) understand the code

;~ Version 1.6: You can now draw Cards WITHOUT Shuffeling under Savage Worlds.

;~ Version 1.5: Marked the Wild Die Result in Savage Worlds.

;~ Version 1.4: The Fate-Table moved from the tabs to the right side and will be always easily available. Massive Changes to the GUI

;~ Version 1.3: Changes in the Output of the Savage Die Rolls (Wild Card & Sort Function). Savage Worlds is now default Tab

;~ Version 1.2: Includes now part of the Fate-Table from the Mythic RPG

;~ Version 1.1: Now with Pokercards (+2 Joker) (Savage Worlds)

#include <GUIConstants.au3>

#include <Array.au3>

;Global $cardsindeck

Global $FullDeck ;Declare 3 arrays to contain card decks

Global $CardDeck1

Global $CardDeck2

InitializeFullDeck() ;Calls the Initialize function to create the cards decks

InitializeCardDeck1()

InitializeCardDeck2()

; Generates a random number between 1 and 1 million and uses it to seed the random number generator

$RandomSeed=random(1,1000000,1)

SRandom($RandomSeed)

; Define the GUI

$GUIHandle= GUICreate("Odds and Evens", 420, 405, -1, -1)

GUICtrlCreateGroup("Essentials",259,28,156,173)

$x=22

$BeginningRow=46

$FateButtonWeak= GUICtrlCreateButton("Weak", 265, $BeginningRow, 65, 15)

$FateButtonLow= GUICtrlCreateButton("Low", 265, $BeginningRow+($x*1), 65, 15)

$FateButtonBelowAvg= GUICtrlCreateButton("Below Av.", 265, $BeginningRow+($x*2), 65, 15)

$FateButtonAvg= GUICtrlCreateButton("Average", 265, $BeginningRow+($x*3), 65, 15)

$FateButtonAboveAvg= GUICtrlCreateButton("Above Av.", 265, $BeginningRow+($x*4), 65, 15)

$FateButtonHigh= GUICtrlCreateButton("High", 265, $BeginningRow+($x*5), 65, 15)

$FateButtonExcep= GUICtrlCreateButton("Exceptional", 265, $BeginningRow+($x*6), 65, 15)

$x=30

$BeginningRow2=50

$QuickButtonD2= GUICtrlCreatebutton("d2", 335, $BeginningRow2, 35, 20)

$QuickButtonD3= GUICtrlCreatebutton("d3", 335, $BeginningRow2+($x), 35, 20)

$QuickButtonD4= GUICtrlCreatebutton("d4", 335, $BeginningRow2+($x*2), 35, 20)

$QuickButtonD6= GUICtrlCreatebutton("d6", 335, $BeginningRow2+($x*3), 35, 20)

$QuickButtonD8= GUICtrlCreatebutton("d8", 335, $BeginningRow2+($x*4), 35, 20)

$QuickButtonD10= GUICtrlCreatebutton("d10", 375, $BeginningRow2, 35, 20)

$QuickButtonD12= GUICtrlCreatebutton("d12", 375, $BeginningRow2+($x), 35, 20)

$QuickButtonD20= GUICtrlCreatebutton("d20", 375, $BeginningRow2+($x*2), 35, 20)

$QuickButtonD100= GUICtrlCreatebutton("d100", 375, $BeginningRow2+($x*3), 35, 20)

$QuickButtonDX= GUICtrlCreatebutton("dX", 375, $BeginningRow2+($x*4), 35, 20)

GUICtrlCreateGroup("An Always Full Deck",296,207,119,34)

$DrawRandomCard= GUICtrlCreatebutton("Draw a Random Card", 299, 221, 113, 17)

GUICtrlCreateGroup("Deck 1",296,244,119,53)

$DrawFromDeck1= GUICtrlCreatebutton("Draw a Card", 299, 257, 113, 17)

$ReshuffleDeck1= GUICtrlCreateButton("Reshuffle Deck", 299, 276, 113, 17)

GUICtrlCreateGroup("Deck 2",296,298,119,72)

$IssueCards= GUICtrlCreateButton("Issue X Cards", 299, 312, 113, 17)

$DrawFromDeck2= GUICtrlCreatebutton("Draw a Single Card", 299, 331, 113, 17)

$ReshuffleDeck2= GUICtrlCreateButton("Reshuffle Deck", 299, 350, 113, 17)

$ShowADeck= GUICtrlCreatebutton("Show Deck", 296, 372, 73, 29)

$DisplayHelp= GUICtrlCreatebutton("Help", 371, 372, 45, 29)

$OutputWindow = GUICtrlCreateEdit("", 5, 30, 249, 170)

GUICtrlCreateLabel("Select a" & @crlf & "Number",11,238)

$NumberSelected = GUICtrlCreateList("1", 5,267,55,146,$WS_VSCROLL)

for $i= 2 to 100

GUICtrlSetData($NumberSelected,$i)

next

$ClearButton= GUICtrlCreateButton("Clear Results",5,5,75,20)

$RollUpWindow= GUICtrlCreateButton("Roll Up Window",150,5,105,20)

$RollDownWindow= GUICtrlCreateButton("Roll Down Window",150,5,105,20)

;~ Hide and disable the Roll Down button

GUICtrlSetState($RollDownWindow,$GUI_DISABLE + $GUI_HIDE)

$KeepOnTop= GUICtrlCreateCheckbox("",294,7,15,15)

GUICtrlCreateLabel("Keep Window on Top",310,8)

$SortResults= GUICtrlCreateCheckbox("",5,209,15,15)

GUICtrlCreateLabel("Sort" & @crlf & "Results",23,204)

$tab=GUICtrlCreateTab (67,205,225,197)

$sworlds=GUICtrlCreateTabitem ("S. Worlds")

$MainButtonW=30

$BigButtonW=55

$SmallButtonW=17

$ButtonH=25

$1stCLSide=117

$2ndCLSide=218

$MidCLSide=155

$TopRow=243

$1stRTop=244

$2ndRTop=$TopRow+40

$3rdRTop=$TopRow+80

$4thRTop=$TopRow+120

;First Row

$SWButtonUnsk= GUICtrlCreatebutton("Unskilled", $MidCLSide, $1stRTop, $BigButtonW, $ButtonH)

$SWButtonUnskx= GUICtrlCreatebutton("x", $MidCLSide-$SmallButtonW, $1stRTop, $SmallButtonW, $ButtonH)

$SWButtonUnskw= GUICtrlCreatebutton("w", $MidCLSide+$BigButtonW, $1stRTop, $SmallButtonW, $ButtonH)

;Second Row

$SWButtonD4= GUICtrlCreatebutton("d4", $1stCLSide, $2ndRTop, $MainButtonW, $ButtonH)

$SWButtonD4x= GUICtrlCreatebutton("x", $1stCLSide-$SmallButtonW, $2ndRTop, $SmallButtonW, $ButtonH)

$SWButtonD4w= GUICtrlCreatebutton("w", $1stCLSide+$MainButtonW, $2ndRTop, $SmallButtonW, $ButtonH)

$SWButtonD6= GUICtrlCreatebutton("d6", $2ndCLSide, $2ndRTop, $MainButtonW, $ButtonH)

$SWButtonD6x= GUICtrlCreatebutton("x", $2ndCLSide-$SmallButtonW, $2ndRTop, $SmallButtonW, $ButtonH)

$SWButtonD6w= GUICtrlCreatebutton("w", $2ndCLSide+$MainButtonW, $2ndRTop, $SmallButtonW, $ButtonH)

;Third Row

$SWButtonD8= GUICtrlCreatebutton("d8", $1stCLSide, $3rdRTop, $MainButtonW, $ButtonH)

$SWButtonD8x= GUICtrlCreatebutton("x", $1stCLSide-$SmallButtonW, $3rdRTop, $SmallButtonW, $ButtonH)

$SWButtonD8w= GUICtrlCreatebutton("w", $1stCLSide+$MainButtonW, $3rdRTop, $SmallButtonW, $ButtonH)

$SWButtonD10= GUICtrlCreatebutton("d10", $2ndCLSide, $3rdRTop, $MainButtonW, $ButtonH)

$SWButtonD10x= GUICtrlCreatebutton("x", $2ndCLSide-$SmallButtonW, $3rdRTop, $SmallButtonW, $ButtonH)

$SWButtonD10w= GUICtrlCreatebutton("w", $2ndCLSide+$MainButtonW, $3rdRTop, $SmallButtonW, $ButtonH)

;Forth Row

$SWButtonD12= GUICtrlCreatebutton("d12", $1stCLSide, $4thRTop, $MainButtonW, $ButtonH)

$SWButtonD12x= GUICtrlCreatebutton("x", $1stCLSide-$SmallButtonW, $4thRTop, $SmallButtonW, $ButtonH)

$SWButtonD12w= GUICtrlCreatebutton("w", $1stCLSide+$MainButtonW, $4thRTop, $SmallButtonW, $ButtonH)

$SWButtonD20= GUICtrlCreateButton("d20", $2ndCLSide, $4thRTop, $MainButtonW, $ButtonH)

$SWButtonD20x= GUICtrlCreateButton("x", $2ndCLSide-$SmallButtonW, $4thRTop, $SmallButtonW, $ButtonH)

$SWButtonD20w= GUICtrlCreateButton("w", $2ndCLSide+$MainButtonW, $4thRTop, $SmallButtonW, $ButtonH)

$SavWorldsMod=GUICtrlCreateTabitem ("S.W.- R.R.")

$MainButtonW=30

$SmallButtonW=17

$ButtonH=20

$1stCLSide=87

$2ndCLSide=163

$3rdCLSide=240

$LSideMod=37

$TopRow=230

$1stRTop=$TopRow

$2ndRTop=$TopRow+24

$3rdRTop=$TopRow+49

$4thRTop=$TopRow+73

$5thRTop=$TopRow+98

$6thRTop=$TopRow+122

$7thRTop=$TopRow+147

;First Row

$SWModButtonD1= GUICtrlCreatebutton("d1", $1stCLSide, $1stRTop, $MainButtonW, $ButtonH)

$SWModButtonD1x= GUICtrlCreatebutton("x", $1stCLSide-$SmallButtonW, $1stRTop, $SmallButtonW, $ButtonH)

$SWModButtonD1W= GUICtrlCreatebutton("w", $1stCLSide+$MainButtonW, $1stRTop, $SmallButtonW, $ButtonH)

$SWModButtonD2= GUICtrlCreatebutton("d2", $2ndCLSide, $1stRTop, $MainButtonW, $ButtonH)

$SWModButtonD2x= GUICtrlCreatebutton("x", $2ndCLSide-$SmallButtonW, $1stRTop, $SmallButtonW, $ButtonH)

$SWModButtonD2W= GUICtrlCreatebutton("w", $2ndCLSide+$MainButtonW, $1stRTop, $SmallButtonW, $ButtonH)

$SWModButtonD3= GUICtrlCreatebutton("d3", $3rdCLSide, $1stRTop, $MainButtonW, $ButtonH)

$SWModButtonD3x= GUICtrlCreatebutton("x", $3rdCLSide-$SmallButtonW, $1stRTop, $SmallButtonW, $ButtonH)

$SWModButtonD3W= GUICtrlCreatebutton("w", $3rdCLSide+$MainButtonW, $1stRTop, $SmallButtonW, $ButtonH)

;Second Row

$SWModButtonD4= GUICtrlCreatebutton("d4", $1stCLSide, $2ndRTop, $MainButtonW, $ButtonH)

$SWModButtonD4x= GUICtrlCreatebutton("x", $1stCLSide-$SmallButtonW, $2ndRTop, $SmallButtonW, $ButtonH)

$SWModButtonD4W= GUICtrlCreatebutton("w", $1stCLSide+$MainButtonW, $2ndRTop, $SmallButtonW, $ButtonH)

$SWModButtonD5= GUICtrlCreatebutton("d5", $2ndCLSide, $2ndRTop, $MainButtonW, $ButtonH)

$SWModButtonD5x= GUICtrlCreatebutton("x", $2ndCLSide-$SmallButtonW, $2ndRTop, $SmallButtonW, $ButtonH)

$SWModButtonD5W= GUICtrlCreatebutton("w", $2ndCLSide+$MainButtonW, $2ndRTop, $SmallButtonW, $ButtonH)

$SWModButtonD6= GUICtrlCreatebutton("d6", $3rdCLSide, $2ndRTop, $MainButtonW, $ButtonH)

$SWModButtonD6x= GUICtrlCreatebutton("x", $3rdCLSide-$SmallButtonW, $2ndRTop, $SmallButtonW, $ButtonH)

$SWModButtonD6W= GUICtrlCreatebutton("w", $3rdCLSide+$MainButtonW, $2ndRTop, $SmallButtonW, $ButtonH)

;Third Row

$SWModButtonD7= GUICtrlCreatebutton("d7", $1stCLSide, $3rdRTop, $MainButtonW, $ButtonH)

$SWModButtonD7x= GUICtrlCreatebutton("x", $1stCLSide-$SmallButtonW, $3rdRTop, $SmallButtonW, $ButtonH)

$SWModButtonD7W= GUICtrlCreatebutton("w", $1stCLSide+$MainButtonW, $3rdRTop, $SmallButtonW, $ButtonH)

$SWModButtonD8= GUICtrlCreatebutton("d8", $2ndCLSide, $3rdRTop, $MainButtonW, $ButtonH)

$SWModButtonD8x= GUICtrlCreatebutton("x", $2ndCLSide-$SmallButtonW, $3rdRTop, $SmallButtonW, $ButtonH)

$SWModButtonD8W= GUICtrlCreatebutton("w", $2ndCLSide+$MainButtonW, $3rdRTop, $SmallButtonW, $ButtonH)

$SWModButtonD9= GUICtrlCreatebutton("d9", $3rdCLSide, $3rdRTop, $MainButtonW, $ButtonH)

$SWModButtonD9x= GUICtrlCreatebutton("x", $3rdCLSide-$SmallButtonW, $3rdRTop, $SmallButtonW, $ButtonH)

$SWModButtonD9W= GUICtrlCreatebutton("w", $3rdCLSide+$MainButtonW, $3rdRTop, $SmallButtonW, $ButtonH)

;Fourth Row

$SWModButtonD10= GUICtrlCreatebutton("d10", $1stCLSide, $4thRTop, $MainButtonW, $ButtonH)

$SWModButtonD10x= GUICtrlCreatebutton("x", $1stCLSide-$SmallButtonW, $4thRTop, $SmallButtonW, $ButtonH)

$SWModButtonD10W= GUICtrlCreatebutton("w", $1stCLSide+$MainButtonW, $4thRTop, $SmallButtonW, $ButtonH)

$SWModButtonD11= GUICtrlCreatebutton("d11", $2ndCLSide, $4thRTop, $MainButtonW, $ButtonH)

$SWModButtonD11x= GUICtrlCreatebutton("x", $2ndCLSide-$SmallButtonW, $4thRTop, $SmallButtonW, $ButtonH)

$SWModButtonD11W= GUICtrlCreatebutton("w", $2ndCLSide+$MainButtonW, $4thRTop, $SmallButtonW, $ButtonH)

$SWModButtonD12= GUICtrlCreatebutton("d12", $3rdCLSide, $4thRTop, $MainButtonW, $ButtonH)

$SWModButtonD12x= GUICtrlCreatebutton("x", $3rdCLSide-$SmallButtonW, $4thRTop, $SmallButtonW, $ButtonH)

$SWModButtonD12W= GUICtrlCreatebutton("w", $3rdCLSide+$MainButtonW, $4thRTop, $SmallButtonW, $ButtonH)

;Fifth Row

$SWModButtonD13= GUICtrlCreatebutton("d13", $1stCLSide, $5thRTop, $MainButtonW, $ButtonH)

$SWModButtonD13x= GUICtrlCreatebutton("x", $1stCLSide-$SmallButtonW, $5thRTop, $SmallButtonW, $ButtonH)

$SWModButtonD13W= GUICtrlCreatebutton("w", $1stCLSide+$MainButtonW, $5thRTop, $SmallButtonW, $ButtonH)

$SWModButtonD14= GUICtrlCreatebutton("d14", $2ndCLSide, $5thRTop, $MainButtonW, $ButtonH)

$SWModButtonD14x= GUICtrlCreatebutton("x", $2ndCLSide-$SmallButtonW, $5thRTop, $SmallButtonW, $ButtonH)

$SWModButtonD14W= GUICtrlCreatebutton("w", $2ndCLSide+$MainButtonW, $5thRTop, $SmallButtonW, $ButtonH)

$SWModButtonD15= GUICtrlCreatebutton("d15", $3rdCLSide, $5thRTop, $MainButtonW, $ButtonH)

$SWModButtonD15x= GUICtrlCreatebutton("x", $3rdCLSide-$SmallButtonW, $5thRTop, $SmallButtonW, $ButtonH)

$SWModButtonD15W= GUICtrlCreatebutton("w", $3rdCLSide+$MainButtonW, $5thRTop, $SmallButtonW, $ButtonH)

;Sixth Row

$SWModButtonD16= GUICtrlCreatebutton("d16", $1stCLSide, $6thRTop, $MainButtonW, $ButtonH)

$SWModButtonD16x= GUICtrlCreatebutton("x", $1stCLSide-$SmallButtonW, $6thRTop, $SmallButtonW, $ButtonH)

$SWModButtonD16W= GUICtrlCreatebutton("w", $1stCLSide+$MainButtonW, $6thRTop, $SmallButtonW, $ButtonH)

$SWModButtonD17= GUICtrlCreatebutton("d17", $2ndCLSide, $6thRTop, $MainButtonW, $ButtonH)

$SWModButtonD17x= GUICtrlCreatebutton("x", $2ndCLSide-$SmallButtonW, $6thRTop, $SmallButtonW, $ButtonH)

$SWModButtonD17W= GUICtrlCreatebutton("w", $2ndCLSide+$MainButtonW, $6thRTop, $SmallButtonW, $ButtonH)

$SWModButtonD18= GUICtrlCreatebutton("d18", $3rdCLSide, $6thRTop, $MainButtonW, $ButtonH)

$SWModButtonD18x= GUICtrlCreatebutton("x", $3rdCLSide-$SmallButtonW, $6thRTop, $SmallButtonW, $ButtonH)

$SWModButtonD18W= GUICtrlCreatebutton("w", $3rdCLSide+$MainButtonW, $6thRTop, $SmallButtonW, $ButtonH)

;Seventh Row

$SWModButtonD19= GUICtrlCreatebutton("d19", $1stCLSide+$LSideMod, $7thRTop, $MainButtonW, $ButtonH)

$SWModButtonD19x= GUICtrlCreatebutton("x", $1stCLSide+$LSideMod-$SmallButtonW, $7thRTop, $SmallButtonW, $ButtonH)

$SWModButtonD19W= GUICtrlCreatebutton("w", $1stCLSide+$LSideMod+$MainButtonW, $7thRTop, $SmallButtonW, $ButtonH)

$SWModButtonD20= GUICtrlCreatebutton("d20", $2ndCLSide+$LSideMod, $7thRTop, $MainButtonW, $ButtonH)

$SWModButtonD20x= GUICtrlCreatebutton("x", $2ndCLSide+$LSideMod-$SmallButtonW, $7thRTop, $SmallButtonW, $ButtonH)

$SWModButtonD20W= GUICtrlCreatebutton("w", $2ndCLSide+$LSideMod+$MainButtonW, $7thRTop, $SmallButtonW, $ButtonH)

$Fate=GUICtrlCreateTabitem ("Fate")

$special=GUICtrlCreateTabitem ("Generic")

$ButtonW=50

$HalfButtonW=25

$ButtonH=25

$1stCLSide=83

$2ndCLSide=153

$3rdCLSide=223

$TopRow=241

$1stRTop=$TopRow

$2ndRTop=$TopRow+40

$3rdRTop=$TopRow+80

$4thRTop=$TopRow+120

$SpecialButtonXD2= GUICtrlCreatebutton("x d2", $1stCLSide, $1stRTop, $ButtonW, $ButtonH)

$SpecialButtonXD3= GUICtrlCreatebutton("x d3", $2ndCLSide, $1stRTop, $ButtonW, $ButtonH)

$SpecialButtonXD4= GUICtrlCreatebutton("x d4", $3rdCLSide, $1stRTop, $ButtonW, $ButtonH)

$SpecialButtonXD6= GUICtrlCreatebutton("x d6", $1stCLSide, $2ndRTop, $ButtonW, $ButtonH)

$SpecialButtonXD8= GUICtrlCreatebutton("x d8", $2ndCLSide, $2ndRTop, $ButtonW, $ButtonH)

$SpecialButtonXD10= GUICtrlCreatebutton("x d10", $3rdCLSide, $2ndRTop, $ButtonW, $ButtonH)

$SpecialButtonXD12= GUICtrlCreatebutton("x d12", $1stCLSide, $3rdRTop, $ButtonW, $ButtonH)

$SpecialButtonXD20= GUICtrlCreatebutton("x d20", $2ndCLSide, $3rdRTop, $ButtonW, $ButtonH)

$SpecialButtonXD100= GUICtrlCreatebutton("x d100", $3rdCLSide, $3rdRTop, $ButtonW, $ButtonH)

$SpecialButtonXDY= GUICtrlCreatebutton("x d", $1stCLSide, $4thRTop, $HalfButtonW, $ButtonH)

$SpecialButtonDiePip= GUICtrlCreatebutton("Y", $1stCLSide+$HalfButtonW, $4thRTop, $ButtonW-$HalfButtonW, $ButtonH)

$DnDAttrib= GUICtrlCreatebutton("DnD Attribute Roll", $2ndCLSide, $4thRTop, $2ndCLSide-$1stCLSide+$ButtonW, $ButtonH)

GUICtrlCreateTabitem ("")

GuiSetState ()

; Run the GUI until the dialog is closed

While 1

$msg = GUIGetMsg()

Select

Case $msg = $DisplayHelp

GUICtrlSetData($OutputWindow,"Help file not written yet, sorry." & @CRLF & GuiCtrlRead($OutputWindow))

Case $msg = $ClearButton

GUICtrlSetData($OutputWindow,"")

Case $msg = $DnDAttrib

DnDAttributes()

Case $msg = $DrawRandomCard

DrawRandomCard()

Case $msg = $DrawFromDeck1

DrawFromDeck1()

Case $msg = $ReshuffleDeck1

InitializeCardDeck1()

GUICtrlSetData($OutputWindow,"Shuffled deck 1" & @CRLF & GuiCtrlRead($OutputWindow))

Case $msg = $IssueCards

IssueCards(GUICtrlRead($NumberSelected)) ;Read the number selection to get the number of players to issue cards to.

Case $msg = $DrawFromDeck2

DrawFromDeck2()

Case $msg = $ReshuffleDeck2

InitializeCardDeck2()

GUICtrlSetData($OutputWindow,"Shuffled deck 2" & @CRLF & GuiCtrlRead($OutputWindow))

Case $msg = $ShowADeck

_ArrayDisplay($FullDeck,"Card Deck")

Case $msg = $QuickButtonD2

easydie(2)

Case $msg = $QuickButtonD3

easydie(3)

Case $msg = $QuickButtonD4

easydie(4)

Case $msg = $QuickButtonD6

easydie(6)

Case $msg = $QuickButtonD8

easydie(8)

Case $msg = $QuickButtonD10

easydie(10)

Case $msg = $QuickButtonD12

easydie(12)

Case $msg = $QuickButtonD20

easydie(20)

Case $msg = $QuickButtonD100

easydie(100)

Case $msg = $QuickButtonDX

easydie(GUICtrlRead($NumberSelected))

Case $msg = $SpecialButtonXD2

multidie(2)

Case $msg = $SpecialButtonXD3

multidie(3)

Case $msg = $SpecialButtonXD4

multidie(4)

Case $msg = $SpecialButtonXD6

multidie(6)

Case $msg = $SpecialButtonXD8

multidie(8)

Case $msg = $SpecialButtonXD10

multidie(10)

Case $msg = $SpecialButtonXD12

multidie(12)

Case $msg = $SpecialButtonXD20

multidie(20)

Case $msg = $SpecialButtonXD100

multidie(100)

Case $msg = $SpecialButtonXDY

if $x = "Y" then

GUICtrlSetData($OutputWindow, "You have to choose a die-type and press the right button" & @CRLF & GuiCtrlRead($OutputWindow))

else

multidie(GUICtrlRead($SpecialButtonDiePip))

endif

Case $msg = $SpecialButtonDiePip

GUICtrlSetData ($SpecialButtonDiePip, GUICtrlRead($NumberSelected))

Case $msg = $RollDownWindow

GUICtrlSetState($RollUpWindow,$GUI_ENABLE + $GUI_SHOW)

GUICtrlSetState($RollDownWindow,$GUI_DISABLE + $GUI_HIDE)

$WinSizeArray= WinGetPos($GUIHandle)

WinMove($GUIHandle,"",$WinSizeArray[0],$WinSizeArray[1],$WinSizeArray[2],$WinSizeArray[3]+375)

Case $msg = $RollUpWindow

GUICtrlSetState($RollDownWindow,$GUI_ENABLE + $GUI_SHOW)

GUICtrlSetState($RollUpWindow,$GUI_DISABLE + $GUI_HIDE)

$WinSizeArray= WinGetPos($GUIHandle)

WinMove($GUIHandle,"",$WinSizeArray[0],$WinSizeArray[1],$WinSizeArray[2],$WinSizeArray[3]-375)

Case $msg = $SWButtonUnsk

savagedie("unskilled")

Case $msg = $SWButtonUnskx ;x dices

savagemultidie("unskilled")

Case $msg = $SWButtonUnskw ;Wild Die

savagewilddie("unskilled")

Case $msg = $SWButtonD4

savagedie(4)

Case $msg = $SWButtonD4x ;x dices

savagemultidie(4)

Case $msg = $SWButtonD4w ;Wild Die

savagewilddie(4)

Case $msg = $SWButtonD6

savagedie(6)

Case $msg = $SWButtonD6x ;x dices

savagemultidie(6)

Case $msg = $SWButtonD6w ;Wild Die

savagewilddie(6)

Case $msg = $SWButtonD8

savagedie(8)

Case $msg = $SWButtonD8x ;x dices

savagemultidie(8)

Case $msg = $SWButtonD8w ;Wild Die

savagewilddie(8)

Case $msg = $SWButtonD10

savagedie(10)

Case $msg = $SWButtonD10x ;x dices

savagemultidie(10)

Case $msg = $SWButtonD10w ;Wild Die

savagewilddie(10)

Case $msg = $SWButtonD12

savagedie(12)

Case $msg = $SWButtonD12x ;x dices

savagemultidie(12)

Case $msg = $SWButtonD12w ;Wild Die

savagewilddie(12)

Case $msg = $SWButtonD20

savagedie(20)

Case $msg = $SWButtonD20x ;x dices

savagemultidie(20)

Case $msg = $SWButtonD20w ;Wild Die

savagewilddie(20)

Case $msg = $SWModButtonD1

savagedie(1)

Case $msg = $SWModButtonD1x ;x dices

savagemultidie(1)

Case $msg = $SWModButtonD1W ;Wild Die

savagewilddie(1)

Case $msg = $SWModButtonD2

savagedie(2)

Case $msg = $SWModButtonD2x ;x dices

savagemultidie(2)

Case $msg = $SWModButtonD2W ;Wild Die

savagewilddie(2)

Case $msg = $SWModButtonD3

savagedie(3)

Case $msg = $SWModButtonD3x ;x dices

savagemultidie(3)

Case $msg = $SWModButtonD3W ;Wild Die

savagewilddie(3)

Case $msg = $SWModButtonD4

savagedie(4)

Case $msg = $SWModButtonD4x ;x dices

savagemultidie(4)

Case $msg = $SWModButtonD4W ;Wild Die

savagewilddie(4)

Case $msg = $SWModButtonD5

savagedie(5)

Case $msg = $SWModButtonD5x ;x dices

savagemultidie(5)

Case $msg = $SWModButtonD5W ;Wild Die

savagewilddie(5)

Case $msg = $SWModButtonD6

savagedie(6)

Case $msg = $SWModButtonD6x ;x dices

savagemultidie(6)

Case $msg = $SWModButtonD6W ;Wild Die

savagewilddie(6)

Case $msg = $SWModButtonD7

savagedie(7)

Case $msg = $SWModButtonD7x ;x dices

savagemultidie(7)

Case $msg = $SWModButtonD7W ;Wild Die

savagewilddie(7)

Case $msg = $SWModButtonD8

savagedie(8)

Case $msg = $SWModButtonD8x ;x dices

savagemultidie(8)

Case $msg = $SWModButtonD8W ;Wild Die

savagewilddie(8)

Case $msg = $SWModButtonD9

savagedie(9)

Case $msg = $SWModButtonD9x ;x dices

savagemultidie(9)

Case $msg = $SWModButtonD9W ;Wild Die

savagewilddie(9)

Case $msg = $SWModButtonD10

savagedie(10)

Case $msg = $SWModButtonD10x ;x dices

savagemultidie(10)

Case $msg = $SWModButtonD10W ;Wild Die

savagewilddie(10)

Case $msg = $SWModButtonD11

savagedie(11)

Case $msg = $SWModButtonD11x ;x dices

savagemultidie(11)

Case $msg = $SWModButtonD11W ;Wild Die

savagewilddie(11)

Case $msg = $SWModButtonD12

savagedie(12)

Case $msg = $SWModButtonD12x ;x dices

savagemultidie(12)

Case $msg = $SWModButtonD12W ;Wild Die

savagewilddie(12)

Case $msg = $SWModButtonD13

savagedie(13)

Case $msg = $SWModButtonD13x ;x dices

savagemultidie(13)

Case $msg = $SWModButtonD13W ;Wild Die

savagewilddie(13)

Case $msg = $SWModButtonD14

savagedie(14)

Case $msg = $SWModButtonD14x ;x dices

savagemultidie(14)

Case $msg = $SWModButtonD14W ;Wild Die

savagewilddie(14)

Case $msg = $SWModButtonD15

savagedie(15)

Case $msg = $SWModButtonD15x ;x dices

savagemultidie(15)

Case $msg = $SWModButtonD15W ;Wild Die

savagewilddie(15)

Case $msg = $SWModButtonD16

savagedie(16)

Case $msg = $SWModButtonD16x ;x dices

savagemultidie(16)

Case $msg = $SWModButtonD16W ;Wild Die

savagewilddie(16)

Case $msg = $SWModButtonD17

savagedie(17)

Case $msg = $SWModButtonD17x ;x dices

savagemultidie(17)

Case $msg = $SWModButtonD17W ;Wild Die

savagewilddie(17)

Case $msg = $SWModButtonD18

savagedie(18)

Case $msg = $SWModButtonD18x ;x dices

savagemultidie(18)

Case $msg = $SWModButtonD18W ;Wild Die

savagewilddie(18)

Case $msg = $SWModButtonD19

savagedie(19)

Case $msg = $SWModButtonD19x ;x dices

savagemultidie(19)

Case $msg = $SWModButtonD19W ;Wild Die

savagewilddie(19)

Case $msg = $SWModButtonD20

savagedie(20)

Case $msg = $SWModButtonD20x ;x dices

savagemultidie(20)

Case $msg = $SWModButtonD20W ;Wild Die

savagewilddie(20)

Case $msg = $FateButtonWeak

fatetable(3,15,84)

Case $msg = $FateButtonLow

fatetable(5,25,86)

Case $msg = $FateButtonBelowAvg

fatetable(7,35,88)

Case $msg = $FateButtonAvg

fatetable(10,50,91)

Case $msg = $FateButtonAboveAvg

fatetable(13,65,94)

Case $msg = $FateButtonHigh

fatetable(15,75,96)

Case $msg = $FateButtonExcep

fatetable(16,85,97)

EndSelect

If $msg = $GUI_EVENT_CLOSE Then ExitLoop

Wend

;~ ---------------------------------------------------------------------------------------------------------------

;~ --------------------------------------- End of Main Script ----------------------------------------------------

;~ ---------------------------------------------------------------------------------------------------------------

Func easydie($die) ; simple die with output

$results = Random(1,$die, 1)

GUICtrlSetData($OutputWindow, $results & " (d" &$die &")" & @CRLF & GuiCtrlRead($OutputWindow))

EndFunc

Func multidie($die) ; multible dice rolls with output

dim $avArray[GUICtrlRead($NumberSelected)+1] ;This seems like the array is being declared with an extra element, don't know why

$string1=GUICtrlRead($NumberSelected)&"d"&$die ;the number of dice followed by the number of pips

for $i = 1 to GUICtrlRead($NumberSelected)

$avArray[$i-1]=Random(1,$die,1) ;$avArray[$i-1] is because the array element numbering starts at 0

Next

if GUICtrlRead($SortResults)=1 then _ArraySort( $avArray,1) ;Sorts array, 1= descending

$string=$avArray[0] ;Load the first element of the array inro $string

$total=int($avArray[0]) ;Load the first element of the array into $total

for $i = 1 to (GUICtrlRead($NumberSelected)-1)

$string= $string & ", " & $avArray[$i] ;Read the array values into a variable seperated by a comma and a space

$total=$total+int($avArray[$i]) ;Add the values in the array together

Next

GUICtrlSetData($OutputWindow, $string & " (" & "Total: " & $total & " | " &$string1 & ")" & @CRLF & GuiCtrlRead($OutputWindow))

EndFunc

Func DnDAttributes() ; D&D 3 Attribute roller (4d6 keep highest 3)

dim $avArray[4]

dim $total[6]

for $j = 0 to 5 ;Generate 6 different numbers

for $i = 0 to 3 ;Track array elements

$avArray[$i]=Random(1,6,1) ;Generate random values to store in the array.

next

_ArraySort( $avArray,1) ;Sort the array, descneding

$total[$j]=$avArray[0]+$avArray[1]+$avArray[2] ;add the first three (highest) values of the sorted array into the result array

next

_ArraySort($total,1) ;Sort the six results, descending

GUICtrlSetData($OutputWindow, "D&D Attributes: " & $total[0] & ", " & $total[1] & ", " & $total[2] & ", " & $total[3] & ", " & $total[4] & ", " & $total[5] & @CRLF & GuiCtrlRead($OutputWindow))

endfunc

Func savagedie($diex) ; roll again on max, unskilled d4-2

if $diex="unskilled" then ;If the button (die) = unskilled, then set the die to 4 and subtract 2 from the results.

$die=4

$results=-2

$string1="unskilled"

elseif $diex=1 then ;If a 1 is passed, use the formula d2-1 provided in the SW Attribute+ Skill doc to resolve the roll

$die=2

$results=-1

$string1="d"&$diex

else ;if $diex is 2 or more, the die = the value of the button and the results are not modified.

$die=$diex

$results=0

$string1="d"&$diex

endif

Do ;Generate die numbers until the number generated is less than the maximum number of pips on the die. Add the numbers to get the final results

$x=Random(1,$die,1)

$results=$results+$x

until $x<$die

GUICtrlSetData($OutputWindow, $results & " (" & $string1 & ")" & @CRLF & GuiCtrlRead($OutputWindow))

EndFunc

Func savagemultidie($diex) ;Same as savagedie but multiple dies

dim $avArray[GUICtrlRead($NumberSelected)+1]

if $diex="unskilled" then

$die=4

$string1="unskilled"

elseif $diex=1 Then

$die=2

$string1=GUICtrlRead($NumberSelected)&"d"&$diex

else

$die=$diex

$string1=GUICtrlRead($NumberSelected)&"d"&$diex

endif

for $i = 1 to GUICtrlRead($NumberSelected)

if $diex="unskilled" then

$avArray[$i-1]=-2

elseif $diex=1 then

$avArray[$i-1]=-1

else

$avArray[$i-1]=0

endif

Do

$x=Random(1,$die,1)

$avArray[$i-1]=$avArray[$i-1]+$x ;add the numbers to the $avArray variable at element $i-1

until $x<$die

Next

if GUICtrlRead($SortResults)=1 then _ArraySort( $avArray,1)

$string=$avArray[0]

$total=int($avArray[0])

for $i = 1 to (GUICtrlRead($NumberSelected)-1)

$string= $string & ", " & $avArray[$i]

$total=$total+int($avArray[$i])

Next

GUICtrlSetData($OutputWindow, $string & " (" & "Total: " & $total & " | " &$string1 & ")" & @CRLF & GuiCtrlRead($OutputWindow))

Endfunc

Func savagewilddie($diex) ; same as savagedie but roll also an additional d6 (wild die) -> higher roll counts

if $diex="unskilled" then

$die=4

$results1=-2

$results2=-2

$string1="unskilled"

elseif $diex=1 then

$die=2

$results1=-1

$results2=-1

$string1="d"&$diex

else

$die=$diex

$results1=0

$results2=0

$string1="d"&$diex

endif

Do

$x=Random(1,$die,1)

$results1=$results1+$x

until $x<$die

Do

$x=Random(1,6,1)

$results2=$results2+$x

until $x<6

if $results1 >= $results2 then

$string = $results1 & ", " & $results2 & "w (" & $string1 & ")"

else

$string = $results2 & "w, " & $results1 & " (" & $string1 & ")"

endif

GUICtrlSetData($OutputWindow, $string & @CRLF & GuiCtrlRead($OutputWindow))

endfunc

Func InitializeFullDeck() ;Create an array containing a full deck of cards, the placeholder is just window dressing in this deck

$FullDeck = _ArrayCreate("Ace of Spades", "Ace of Diamonds", "Ace of Hearts", "Ace of Clubs")

For $i=2 To 13

Switch $i

Case 2 To 10

$CardValue= $i

Case 11

$CardValue= "Jack"

Case 12

$CardValue= "Queen"

Case 13

$CardValue= "King"

EndSwitch

_ArrayAdd( $FullDeck,$CardValue&" of Spades")

_ArrayAdd( $FullDeck,$CardValue&" of Diamonds")

_ArrayAdd( $FullDeck,$CardValue&" of Hearts")

_ArrayAdd( $FullDeck,$CardValue&" of Clubs")

Next

_ArrayAdd($FullDeck,"Little Joker")

_ArrayAdd($FullDeck,"Big Joker")

_ArrayAdd($FullDeck,"Placeholder")

EndFunc

Func InitializeCardDeck1() ;create a deck of cards, the placeholder is so that there is still an element in the array when all the rest of the cards have been chosen.

$CardDeck1 = _ArrayCreate("Ace of Spades", "Ace of Diamonds", "Ace of Hearts", "Ace of Clubs")

For $i=2 To 13

Switch $i

Case 2 To 10

$CardValue= $i

Case 11

$CardValue= "Jack"

Case 12

$CardValue= "Queen"

Case 13

$CardValue= "King"

EndSwitch

_ArrayAdd( $CardDeck1,$CardValue&" of Spades")

_ArrayAdd( $CardDeck1,$CardValue&" of Diamonds")

_ArrayAdd( $CardDeck1,$CardValue&" of Hearts")

_ArrayAdd( $CardDeck1,$CardValue&" of Clubs")

Next

_ArrayAdd($CardDeck1,"Little Joker")

_ArrayAdd($CardDeck1,"Big Joker")

_ArrayAdd($CardDeck1,"Placeholder")

EndFunc

Func InitializeCardDeck2() ;Same as Deck 1

$CardDeck2 = _ArrayCreate("Ace of Spades", "Ace of Diamonds", "Ace of Hearts", "Ace of Clubs")

For $i=2 To 13

Switch $i

Case 2 To 10

$CardValue= $i

Case 11

$CardValue= "Jack"

Case 12

$CardValue= "Queen"

Case 13

$CardValue= "King"

EndSwitch

_ArrayAdd( $CardDeck2,$CardValue&" of Spades")

_ArrayAdd( $CardDeck2,$CardValue&" of Diamonds")

_ArrayAdd( $CardDeck2,$CardValue&" of Hearts")

_ArrayAdd( $CardDeck2,$CardValue&" of Clubs")

Next

_ArrayAdd($CardDeck2,"Little Joker")

_ArrayAdd($CardDeck2,"Big Joker")

_ArrayAdd($CardDeck2,"Placeholder")

EndFunc

Func DrawRandomCard()

$i=Random(0,53)

$CardDrawn=$FullDeck[$i]

GUICtrlSetData($OutputWindow, $CardDrawn & @CRLF & GuiCtrlRead($OutputWindow))

EndFunc

Func DrawFromDeck1()

$NumberOfCardsLeft=UBound($CardDeck1)-1 ;Subtract 1 for the placeholder

$i=Random(0, $NumberOfCardsLeft)

$CardDrawn=$CardDeck1[$i]

_ArrayDelete($CardDeck1,$i)

GUICtrlSetData($OutputWindow, $CardDrawn & @CRLF & GuiCtrlRead($OutputWindow))

If UBound($CardDeck1)=1 Then

InitializeCardDeck1()

GUICtrlSetData($OutputWindow, "Out of Cards. Deck 1 reshuffled." & @CRLF & GuiCtrlRead($OutputWindow))

EndIf

EndFunc

Func IssueCards($NumberOfPlayers)

Dim $CardsPicked[$NumberOfPlayers] ;Create an array to hold the cards picked

$NumberOfCardsLeft=UBound($CardDeck2)-1 ;Subtract 1 for the placeholder

If $NumberOfPlayers > 54 Then

GUICtrlSetData($OutputWindow, $NumberOfPlayers & "?! Thats more players then cards in the deck. Please choose a smaller number." & @CRLF & GuiCtrlRead($OutputWindow))

Return

ElseIf $NumberOfPlayers > $NumberOfCardsLeft Then

InitializeCardDeck2()

GUICtrlSetData($OutputWindow, "- - - - - -" & @CRLF & GuiCtrlRead($OutputWindow))

GUICtrlSetData($OutputWindow, "More players than cards remaining. Deck 2 reshuffled." & @CRLF & GuiCtrlRead($OutputWindow))

EndIf

GUICtrlSetData($OutputWindow, "-----------" & @CRLF & GuiCtrlRead($OutputWindow))

For $i = 0 To $NumberOfPlayers-1 ;Load the card array.

$j=Random(0, $NumberOfCardsLeft)

$CardDrawn=$CardDeck2[$j]

_ArrayDelete($CardDeck2,$j)

$CardsPicked[$i]=$CardDrawn

$NumberOfCardsLeft=UBound($CardDeck2)-1 ;Reset the number of cards left in the deck. Subtract 1 for the placeholder

Next

For $i = $NumberOfPlayers-1 To 0 Step -1

GUICtrlSetData($OutputWindow, "Player " & $i+1 & ": " & $CardsPicked[$i] & @CRLF & GuiCtrlRead($OutputWindow))

Next

If UBound($CardDeck2)=1 Then

InitializeCardDeck2()

GUICtrlSetData($OutputWindow, "Out of Cards. Deck 2 reshuffled." & @CRLF & GuiCtrlRead($OutputWindow))

EndIf

EndFunc

Func DrawFromDeck2()

$NumberOfCardsLeft=UBound($CardDeck2)-1 ;Subtract 1 for the placeholder

$i=Random(0, $NumberOfCardsLeft)

$CardDrawn=$CardDeck2[$i]

_ArrayDelete($CardDeck2,$i)

GUICtrlSetData($OutputWindow, $CardDrawn & @CRLF & GuiCtrlRead($OutputWindow))

If UBound($CardDeck2)=1 Then

InitializeCardDeck2()

GUICtrlSetData($OutputWindow, "Out of Cards. Deck 2 reshuffled." & @CRLF & GuiCtrlRead($OutputWindow))

EndIf

EndFunc

Func fatetable($1,$2,$3) ; choose how probale a question is and it will thell you Yes++/Yes/No/No-- -> more explaination in the Mythic RPG

$results = Random(1,100, 1)

Select

Case $results <= $1

GUICtrlSetData($OutputWindow, "Yes maximum" & @CRLF & GuiCtrlRead($OutputWindow))

Case $results <= $2

GUICtrlSetData($OutputWindow, "Yes" & @CRLF & GuiCtrlRead($OutputWindow))

Case $results < $3

GUICtrlSetData($OutputWindow, "No" & @CRLF & GuiCtrlRead($OutputWindow))

Case Else

GUICtrlSetData($OutputWindow, "No maximum" & @CRLF & GuiCtrlRead($OutputWindow))

EndSelect

endfunc

Link to comment
Share on other sites

hi, use GUICtrlCreateDummy() and wrap your controls with it..

Then use a For/Next loop with GUICtrlSetResizing() eg:

;~ Program: Odds and Evens
;~ Script Compiler: Autoit version: 3
;~ Author: Simon Goodson
;~ Email: zealott@hotmail.com
;~ Date: 7 Nov 2007
;~
;~ Based on: Flanf's Die Roller v1.6
;~ Coded by: Christoph Flandorfer
;~ Created on: 13 Sept 2006

;~ Script Function:
;~ A dice roller and card picker for use in RPGs or whatever

;~ Odds and Evens
;~ --------------
;~ v0.1 Renamed app to "Odds and Evens"
;~ Began redisign of GUI
;~ Adding "Stay on Top" feature
;~ Adding "Roll-up Window" feature
;~ Adding Fate Dice function
;~
;~ Flanf's Dice Roller
;~ -------------------
;- Version 1.6a: Switched the output window around to get more space for the dice buttons
;- Added a tab to perform d1 through d20 wild dice.
;- Added the d20 dice to the S.Worlds tab, mostly for asthetics
;- Moved the card functions to its own section
;- Implemented 3 decks, 1 always containing all the cards, 1 to pick 1 card at a time out, and
;- one to issue multiple cards for combat also with a function to pick singles if needed
;- Moved the sort function so that all the dice results could be sorted or not depending on preference
;- Generated a random number and used it to seed the random table
;- Added a bunch of remarks to help me (Simon) understand the code
;~ Version 1.6: You can now draw Cards WITHOUT Shuffeling under Savage Worlds.
;~ Version 1.5: Marked the Wild Die Result in Savage Worlds.
;~ Version 1.4: The Fate-Table moved from the tabs to the right side and will be always easily available. Massive Changes to the GUI
;~ Version 1.3: Changes in the Output of the Savage Die Rolls (Wild Card & Sort Function). Savage Worlds is now default Tab
;~ Version 1.2: Includes now part of the Fate-Table from the Mythic RPG
;~ Version 1.1: Now with Pokercards (+2 Joker) (Savage Worlds)

#include <GUIConstants.au3>
#include <Array.au3>

;Global $cardsindeck
Global $FullDeck ;Declare 3 arrays to contain card decks
Global $CardDeck1
Global $CardDeck2
InitializeFullDeck() ;Calls the Initialize function to create the cards decks
InitializeCardDeck1()
InitializeCardDeck2()

; Generates a random number between 1 and 1 million and uses it to seed the random number generator
$RandomSeed=random(1,1000000,1)
SRandom($RandomSeed)

; Define the GUI

$GUIHandle= GUICreate("Odds and Evens", 420, 405, -1, -1)

$DummyStart = GUICtrlCreateDummy() ;<-- Added this here for start of controls

GUICtrlCreateGroup("Essentials",259,28,156,173)
$x=22
$BeginningRow=46
$FateButtonWeak= GUICtrlCreateButton("Weak", 265, $BeginningRow, 65, 15)
$FateButtonLow= GUICtrlCreateButton("Low", 265, $BeginningRow+($x*1), 65, 15)
$FateButtonBelowAvg= GUICtrlCreateButton("Below Av.", 265, $BeginningRow+($x*2), 65, 15)
$FateButtonAvg= GUICtrlCreateButton("Average", 265, $BeginningRow+($x*3), 65, 15)
$FateButtonAboveAvg= GUICtrlCreateButton("Above Av.", 265, $BeginningRow+($x*4), 65, 15)
$FateButtonHigh= GUICtrlCreateButton("High", 265, $BeginningRow+($x*5), 65, 15)
$FateButtonExcep= GUICtrlCreateButton("Exceptional", 265, $BeginningRow+($x*6), 65, 15)

$x=30
$BeginningRow2=50
$QuickButtonD2= GUICtrlCreatebutton("d2", 335, $BeginningRow2, 35, 20)
$QuickButtonD3= GUICtrlCreatebutton("d3", 335, $BeginningRow2+($x), 35, 20)
$QuickButtonD4= GUICtrlCreatebutton("d4", 335, $BeginningRow2+($x*2), 35, 20)
$QuickButtonD6= GUICtrlCreatebutton("d6", 335, $BeginningRow2+($x*3), 35, 20)
$QuickButtonD8= GUICtrlCreatebutton("d8", 335, $BeginningRow2+($x*4), 35, 20)

$QuickButtonD10= GUICtrlCreatebutton("d10", 375, $BeginningRow2, 35, 20)
$QuickButtonD12= GUICtrlCreatebutton("d12", 375, $BeginningRow2+($x), 35, 20)
$QuickButtonD20= GUICtrlCreatebutton("d20", 375, $BeginningRow2+($x*2), 35, 20)
$QuickButtonD100= GUICtrlCreatebutton("d100", 375, $BeginningRow2+($x*3), 35, 20)
$QuickButtonDX= GUICtrlCreatebutton("dX", 375, $BeginningRow2+($x*4), 35, 20)

GUICtrlCreateGroup("An Always Full Deck",296,207,119,34)
$DrawRandomCard= GUICtrlCreatebutton("Draw a Random Card", 299, 221, 113, 17)

GUICtrlCreateGroup("Deck 1",296,244,119,53)
$DrawFromDeck1= GUICtrlCreatebutton("Draw a Card", 299, 257, 113, 17)
$ReshuffleDeck1= GUICtrlCreateButton("Reshuffle Deck", 299, 276, 113, 17)

GUICtrlCreateGroup("Deck 2",296,298,119,72)
$IssueCards= GUICtrlCreateButton("Issue X Cards", 299, 312, 113, 17)
$DrawFromDeck2= GUICtrlCreatebutton("Draw a Single Card", 299, 331, 113, 17)
$ReshuffleDeck2= GUICtrlCreateButton("Reshuffle Deck", 299, 350, 113, 17)

$ShowADeck= GUICtrlCreatebutton("Show Deck", 296, 372, 73, 29)
$DisplayHelp= GUICtrlCreatebutton("Help", 371, 372, 45, 29)

$OutputWindow = GUICtrlCreateEdit("", 5, 30, 249, 170)

GUICtrlCreateLabel("Select a" & @crlf & "Number",11,238)
$NumberSelected = GUICtrlCreateList("1", 5,267,55,146,$WS_VSCROLL)
for $i= 2 to 100
GUICtrlSetData($NumberSelected,$i)
next
$ClearButton= GUICtrlCreateButton("Clear Results",5,5,75,20)

$RollUpWindow= GUICtrlCreateButton("Roll Up Window",150,5,105,20)
$RollDownWindow= GUICtrlCreateButton("Roll Down Window",150,5,105,20)
;~ Hide and disable the Roll Down button
GUICtrlSetState($RollDownWindow,$GUI_DISABLE + $GUI_HIDE)

$KeepOnTop= GUICtrlCreateCheckbox("",294,7,15,15)
GUICtrlCreateLabel("Keep Window on Top",310,8)

$SortResults= GUICtrlCreateCheckbox("",5,209,15,15)
GUICtrlCreateLabel("Sort" & @crlf & "Results",23,204)

$tab=GUICtrlCreateTab (67,205,225,197)
$sworlds=GUICtrlCreateTabitem ("S. Worlds")
$MainButtonW=30
$BigButtonW=55
$SmallButtonW=17
$ButtonH=25
$1stCLSide=117
$2ndCLSide=218
$MidCLSide=155
$TopRow=243
$1stRTop=244
$2ndRTop=$TopRow+40
$3rdRTop=$TopRow+80
$4thRTop=$TopRow+120
;First Row
$SWButtonUnsk= GUICtrlCreatebutton("Unskilled", $MidCLSide, $1stRTop, $BigButtonW, $ButtonH)
$SWButtonUnskx= GUICtrlCreatebutton("x", $MidCLSide-$SmallButtonW, $1stRTop, $SmallButtonW, $ButtonH)
$SWButtonUnskw= GUICtrlCreatebutton("w", $MidCLSide+$BigButtonW, $1stRTop, $SmallButtonW, $ButtonH)
;Second Row
$SWButtonD4= GUICtrlCreatebutton("d4", $1stCLSide, $2ndRTop, $MainButtonW, $ButtonH)
$SWButtonD4x= GUICtrlCreatebutton("x", $1stCLSide-$SmallButtonW, $2ndRTop, $SmallButtonW, $ButtonH)
$SWButtonD4w= GUICtrlCreatebutton("w", $1stCLSide+$MainButtonW, $2ndRTop, $SmallButtonW, $ButtonH)

$SWButtonD6= GUICtrlCreatebutton("d6", $2ndCLSide, $2ndRTop, $MainButtonW, $ButtonH)
$SWButtonD6x= GUICtrlCreatebutton("x", $2ndCLSide-$SmallButtonW, $2ndRTop, $SmallButtonW, $ButtonH)
$SWButtonD6w= GUICtrlCreatebutton("w", $2ndCLSide+$MainButtonW, $2ndRTop, $SmallButtonW, $ButtonH)
;Third Row
$SWButtonD8= GUICtrlCreatebutton("d8", $1stCLSide, $3rdRTop, $MainButtonW, $ButtonH)
$SWButtonD8x= GUICtrlCreatebutton("x", $1stCLSide-$SmallButtonW, $3rdRTop, $SmallButtonW, $ButtonH)
$SWButtonD8w= GUICtrlCreatebutton("w", $1stCLSide+$MainButtonW, $3rdRTop, $SmallButtonW, $ButtonH)

$SWButtonD10= GUICtrlCreatebutton("d10", $2ndCLSide, $3rdRTop, $MainButtonW, $ButtonH)
$SWButtonD10x= GUICtrlCreatebutton("x", $2ndCLSide-$SmallButtonW, $3rdRTop, $SmallButtonW, $ButtonH)
$SWButtonD10w= GUICtrlCreatebutton("w", $2ndCLSide+$MainButtonW, $3rdRTop, $SmallButtonW, $ButtonH)
;Forth Row
$SWButtonD12= GUICtrlCreatebutton("d12", $1stCLSide, $4thRTop, $MainButtonW, $ButtonH)
$SWButtonD12x= GUICtrlCreatebutton("x", $1stCLSide-$SmallButtonW, $4thRTop, $SmallButtonW, $ButtonH)
$SWButtonD12w= GUICtrlCreatebutton("w", $1stCLSide+$MainButtonW, $4thRTop, $SmallButtonW, $ButtonH)

$SWButtonD20= GUICtrlCreateButton("d20", $2ndCLSide, $4thRTop, $MainButtonW, $ButtonH)
$SWButtonD20x= GUICtrlCreateButton("x", $2ndCLSide-$SmallButtonW, $4thRTop, $SmallButtonW, $ButtonH)
$SWButtonD20w= GUICtrlCreateButton("w", $2ndCLSide+$MainButtonW, $4thRTop, $SmallButtonW, $ButtonH)

$SavWorldsMod=GUICtrlCreateTabitem ("S.W.- R.R.")
$MainButtonW=30
$SmallButtonW=17
$ButtonH=20
$1stCLSide=87
$2ndCLSide=163
$3rdCLSide=240
$LSideMod=37
$TopRow=230
$1stRTop=$TopRow
$2ndRTop=$TopRow+24
$3rdRTop=$TopRow+49
$4thRTop=$TopRow+73
$5thRTop=$TopRow+98
$6thRTop=$TopRow+122
$7thRTop=$TopRow+147
;First Row
$SWModButtonD1= GUICtrlCreatebutton("d1", $1stCLSide, $1stRTop, $MainButtonW, $ButtonH)
$SWModButtonD1x= GUICtrlCreatebutton("x", $1stCLSide-$SmallButtonW, $1stRTop, $SmallButtonW, $ButtonH)
$SWModButtonD1W= GUICtrlCreatebutton("w", $1stCLSide+$MainButtonW, $1stRTop, $SmallButtonW, $ButtonH)

$SWModButtonD2= GUICtrlCreatebutton("d2", $2ndCLSide, $1stRTop, $MainButtonW, $ButtonH)
$SWModButtonD2x= GUICtrlCreatebutton("x", $2ndCLSide-$SmallButtonW, $1stRTop, $SmallButtonW, $ButtonH)
$SWModButtonD2W= GUICtrlCreatebutton("w", $2ndCLSide+$MainButtonW, $1stRTop, $SmallButtonW, $ButtonH)

$SWModButtonD3= GUICtrlCreatebutton("d3", $3rdCLSide, $1stRTop, $MainButtonW, $ButtonH)
$SWModButtonD3x= GUICtrlCreatebutton("x", $3rdCLSide-$SmallButtonW, $1stRTop, $SmallButtonW, $ButtonH)
$SWModButtonD3W= GUICtrlCreatebutton("w", $3rdCLSide+$MainButtonW, $1stRTop, $SmallButtonW, $ButtonH)
;Second Row
$SWModButtonD4= GUICtrlCreatebutton("d4", $1stCLSide, $2ndRTop, $MainButtonW, $ButtonH)
$SWModButtonD4x= GUICtrlCreatebutton("x", $1stCLSide-$SmallButtonW, $2ndRTop, $SmallButtonW, $ButtonH)
$SWModButtonD4W= GUICtrlCreatebutton("w", $1stCLSide+$MainButtonW, $2ndRTop, $SmallButtonW, $ButtonH)

$SWModButtonD5= GUICtrlCreatebutton("d5", $2ndCLSide, $2ndRTop, $MainButtonW, $ButtonH)
$SWModButtonD5x= GUICtrlCreatebutton("x", $2ndCLSide-$SmallButtonW, $2ndRTop, $SmallButtonW, $ButtonH)
$SWModButtonD5W= GUICtrlCreatebutton("w", $2ndCLSide+$MainButtonW, $2ndRTop, $SmallButtonW, $ButtonH)

$SWModButtonD6= GUICtrlCreatebutton("d6", $3rdCLSide, $2ndRTop, $MainButtonW, $ButtonH)
$SWModButtonD6x= GUICtrlCreatebutton("x", $3rdCLSide-$SmallButtonW, $2ndRTop, $SmallButtonW, $ButtonH)
$SWModButtonD6W= GUICtrlCreatebutton("w", $3rdCLSide+$MainButtonW, $2ndRTop, $SmallButtonW, $ButtonH)
;Third Row
$SWModButtonD7= GUICtrlCreatebutton("d7", $1stCLSide, $3rdRTop, $MainButtonW, $ButtonH)
$SWModButtonD7x= GUICtrlCreatebutton("x", $1stCLSide-$SmallButtonW, $3rdRTop, $SmallButtonW, $ButtonH)
$SWModButtonD7W= GUICtrlCreatebutton("w", $1stCLSide+$MainButtonW, $3rdRTop, $SmallButtonW, $ButtonH)

$SWModButtonD8= GUICtrlCreatebutton("d8", $2ndCLSide, $3rdRTop, $MainButtonW, $ButtonH)
$SWModButtonD8x= GUICtrlCreatebutton("x", $2ndCLSide-$SmallButtonW, $3rdRTop, $SmallButtonW, $ButtonH)
$SWModButtonD8W= GUICtrlCreatebutton("w", $2ndCLSide+$MainButtonW, $3rdRTop, $SmallButtonW, $ButtonH)

$SWModButtonD9= GUICtrlCreatebutton("d9", $3rdCLSide, $3rdRTop, $MainButtonW, $ButtonH)
$SWModButtonD9x= GUICtrlCreatebutton("x", $3rdCLSide-$SmallButtonW, $3rdRTop, $SmallButtonW, $ButtonH)
$SWModButtonD9W= GUICtrlCreatebutton("w", $3rdCLSide+$MainButtonW, $3rdRTop, $SmallButtonW, $ButtonH)
;Fourth Row
$SWModButtonD10= GUICtrlCreatebutton("d10", $1stCLSide, $4thRTop, $MainButtonW, $ButtonH)
$SWModButtonD10x= GUICtrlCreatebutton("x", $1stCLSide-$SmallButtonW, $4thRTop, $SmallButtonW, $ButtonH)
$SWModButtonD10W= GUICtrlCreatebutton("w", $1stCLSide+$MainButtonW, $4thRTop, $SmallButtonW, $ButtonH)

$SWModButtonD11= GUICtrlCreatebutton("d11", $2ndCLSide, $4thRTop, $MainButtonW, $ButtonH)
$SWModButtonD11x= GUICtrlCreatebutton("x", $2ndCLSide-$SmallButtonW, $4thRTop, $SmallButtonW, $ButtonH)
$SWModButtonD11W= GUICtrlCreatebutton("w", $2ndCLSide+$MainButtonW, $4thRTop, $SmallButtonW, $ButtonH)

$SWModButtonD12= GUICtrlCreatebutton("d12", $3rdCLSide, $4thRTop, $MainButtonW, $ButtonH)
$SWModButtonD12x= GUICtrlCreatebutton("x", $3rdCLSide-$SmallButtonW, $4thRTop, $SmallButtonW, $ButtonH)
$SWModButtonD12W= GUICtrlCreatebutton("w", $3rdCLSide+$MainButtonW, $4thRTop, $SmallButtonW, $ButtonH)
;Fifth Row
$SWModButtonD13= GUICtrlCreatebutton("d13", $1stCLSide, $5thRTop, $MainButtonW, $ButtonH)
$SWModButtonD13x= GUICtrlCreatebutton("x", $1stCLSide-$SmallButtonW, $5thRTop, $SmallButtonW, $ButtonH)
$SWModButtonD13W= GUICtrlCreatebutton("w", $1stCLSide+$MainButtonW, $5thRTop, $SmallButtonW, $ButtonH)

$SWModButtonD14= GUICtrlCreatebutton("d14", $2ndCLSide, $5thRTop, $MainButtonW, $ButtonH)
$SWModButtonD14x= GUICtrlCreatebutton("x", $2ndCLSide-$SmallButtonW, $5thRTop, $SmallButtonW, $ButtonH)
$SWModButtonD14W= GUICtrlCreatebutton("w", $2ndCLSide+$MainButtonW, $5thRTop, $SmallButtonW, $ButtonH)

$SWModButtonD15= GUICtrlCreatebutton("d15", $3rdCLSide, $5thRTop, $MainButtonW, $ButtonH)
$SWModButtonD15x= GUICtrlCreatebutton("x", $3rdCLSide-$SmallButtonW, $5thRTop, $SmallButtonW, $ButtonH)
$SWModButtonD15W= GUICtrlCreatebutton("w", $3rdCLSide+$MainButtonW, $5thRTop, $SmallButtonW, $ButtonH)
;Sixth Row
$SWModButtonD16= GUICtrlCreatebutton("d16", $1stCLSide, $6thRTop, $MainButtonW, $ButtonH)
$SWModButtonD16x= GUICtrlCreatebutton("x", $1stCLSide-$SmallButtonW, $6thRTop, $SmallButtonW, $ButtonH)
$SWModButtonD16W= GUICtrlCreatebutton("w", $1stCLSide+$MainButtonW, $6thRTop, $SmallButtonW, $ButtonH)

$SWModButtonD17= GUICtrlCreatebutton("d17", $2ndCLSide, $6thRTop, $MainButtonW, $ButtonH)
$SWModButtonD17x= GUICtrlCreatebutton("x", $2ndCLSide-$SmallButtonW, $6thRTop, $SmallButtonW, $ButtonH)
$SWModButtonD17W= GUICtrlCreatebutton("w", $2ndCLSide+$MainButtonW, $6thRTop, $SmallButtonW, $ButtonH)

$SWModButtonD18= GUICtrlCreatebutton("d18", $3rdCLSide, $6thRTop, $MainButtonW, $ButtonH)
$SWModButtonD18x= GUICtrlCreatebutton("x", $3rdCLSide-$SmallButtonW, $6thRTop, $SmallButtonW, $ButtonH)
$SWModButtonD18W= GUICtrlCreatebutton("w", $3rdCLSide+$MainButtonW, $6thRTop, $SmallButtonW, $ButtonH)
;Seventh Row
$SWModButtonD19= GUICtrlCreatebutton("d19", $1stCLSide+$LSideMod, $7thRTop, $MainButtonW, $ButtonH)
$SWModButtonD19x= GUICtrlCreatebutton("x", $1stCLSide+$LSideMod-$SmallButtonW, $7thRTop, $SmallButtonW, $ButtonH)
$SWModButtonD19W= GUICtrlCreatebutton("w", $1stCLSide+$LSideMod+$MainButtonW, $7thRTop, $SmallButtonW, $ButtonH)

$SWModButtonD20= GUICtrlCreatebutton("d20", $2ndCLSide+$LSideMod, $7thRTop, $MainButtonW, $ButtonH)
$SWModButtonD20x= GUICtrlCreatebutton("x", $2ndCLSide+$LSideMod-$SmallButtonW, $7thRTop, $SmallButtonW, $ButtonH)
$SWModButtonD20W= GUICtrlCreatebutton("w", $2ndCLSide+$LSideMod+$MainButtonW, $7thRTop, $SmallButtonW, $ButtonH)

$Fate=GUICtrlCreateTabitem ("Fate")

$special=GUICtrlCreateTabitem ("Generic")
$ButtonW=50
$HalfButtonW=25
$ButtonH=25
$1stCLSide=83
$2ndCLSide=153
$3rdCLSide=223
$TopRow=241
$1stRTop=$TopRow
$2ndRTop=$TopRow+40
$3rdRTop=$TopRow+80
$4thRTop=$TopRow+120

$SpecialButtonXD2= GUICtrlCreatebutton("x d2", $1stCLSide, $1stRTop, $ButtonW, $ButtonH)
$SpecialButtonXD3= GUICtrlCreatebutton("x d3", $2ndCLSide, $1stRTop, $ButtonW, $ButtonH)
$SpecialButtonXD4= GUICtrlCreatebutton("x d4", $3rdCLSide, $1stRTop, $ButtonW, $ButtonH)
$SpecialButtonXD6= GUICtrlCreatebutton("x d6", $1stCLSide, $2ndRTop, $ButtonW, $ButtonH)
$SpecialButtonXD8= GUICtrlCreatebutton("x d8", $2ndCLSide, $2ndRTop, $ButtonW, $ButtonH)
$SpecialButtonXD10= GUICtrlCreatebutton("x d10", $3rdCLSide, $2ndRTop, $ButtonW, $ButtonH)
$SpecialButtonXD12= GUICtrlCreatebutton("x d12", $1stCLSide, $3rdRTop, $ButtonW, $ButtonH)
$SpecialButtonXD20= GUICtrlCreatebutton("x d20", $2ndCLSide, $3rdRTop, $ButtonW, $ButtonH)
$SpecialButtonXD100= GUICtrlCreatebutton("x d100", $3rdCLSide, $3rdRTop, $ButtonW, $ButtonH)
$SpecialButtonXDY= GUICtrlCreatebutton("x d", $1stCLSide, $4thRTop, $HalfButtonW, $ButtonH)
$SpecialButtonDiePip= GUICtrlCreatebutton("Y", $1stCLSide+$HalfButtonW, $4thRTop, $ButtonW-$HalfButtonW, $ButtonH)
$DnDAttrib= GUICtrlCreatebutton("DnD Attribute Roll", $2ndCLSide, $4thRTop, $2ndCLSide-$1stCLSide+$ButtonW, $ButtonH)
GUICtrlCreateTabitem ("")

$DummyEnd = GUICtrlCreateDummy() ;<-- Added this here for end of controls

GuiSetState ()

For $q = $DummyStart To $DummyEnd ;<-- Added this loop to set DockAll on all controls between start and end
    GUICtrlSetResizing($q, $GUI_DOCKALL) 
Next ;<-- Added this ... that's it no more added    

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()
Select
Case $msg = $DisplayHelp
GUICtrlSetData($OutputWindow,"Help file not written yet, sorry." & @CRLF & GuiCtrlRead($OutputWindow))
Case $msg = $ClearButton
GUICtrlSetData($OutputWindow,"")
Case $msg = $DnDAttrib
DnDAttributes()
Case $msg = $DrawRandomCard
DrawRandomCard()
Case $msg = $DrawFromDeck1
DrawFromDeck1()
Case $msg = $ReshuffleDeck1
InitializeCardDeck1()
GUICtrlSetData($OutputWindow,"Shuffled deck 1" & @CRLF & GuiCtrlRead($OutputWindow))
Case $msg = $IssueCards
IssueCards(GUICtrlRead($NumberSelected)) ;Read the number selection to get the number of players to issue cards to.
Case $msg = $DrawFromDeck2
DrawFromDeck2()
Case $msg = $ReshuffleDeck2
InitializeCardDeck2()
GUICtrlSetData($OutputWindow,"Shuffled deck 2" & @CRLF & GuiCtrlRead($OutputWindow))
Case $msg = $ShowADeck
_ArrayDisplay($FullDeck,"Card Deck")
Case $msg = $QuickButtonD2
easydie(2)
Case $msg = $QuickButtonD3
easydie(3)
Case $msg = $QuickButtonD4
easydie(4)
Case $msg = $QuickButtonD6
easydie(6)
Case $msg = $QuickButtonD8
easydie(8)
Case $msg = $QuickButtonD10
easydie(10)
Case $msg = $QuickButtonD12
easydie(12)
Case $msg = $QuickButtonD20
easydie(20)
Case $msg = $QuickButtonD100
easydie(100)
Case $msg = $QuickButtonDX
easydie(GUICtrlRead($NumberSelected))
Case $msg = $SpecialButtonXD2
multidie(2)
Case $msg = $SpecialButtonXD3
multidie(3)
Case $msg = $SpecialButtonXD4
multidie(4)
Case $msg = $SpecialButtonXD6
multidie(6)
Case $msg = $SpecialButtonXD8
multidie(8)
Case $msg = $SpecialButtonXD10
multidie(10)
Case $msg = $SpecialButtonXD12
multidie(12)
Case $msg = $SpecialButtonXD20
multidie(20)
Case $msg = $SpecialButtonXD100
multidie(100)
Case $msg = $SpecialButtonXDY
if $x = "Y" then
GUICtrlSetData($OutputWindow, "You have to choose a die-type and press the right button" & @CRLF & GuiCtrlRead($OutputWindow))
else
multidie(GUICtrlRead($SpecialButtonDiePip))
endif
Case $msg = $SpecialButtonDiePip
GUICtrlSetData ($SpecialButtonDiePip, GUICtrlRead($NumberSelected))

Case $msg = $RollDownWindow
GUICtrlSetState($RollUpWindow,$GUI_ENABLE + $GUI_SHOW)
GUICtrlSetState($RollDownWindow,$GUI_DISABLE + $GUI_HIDE)
$WinSizeArray= WinGetPos($GUIHandle)
WinMove($GUIHandle,"",$WinSizeArray[0],$WinSizeArray[1],$WinSizeArray[2],$WinSizeArray[3]+375)
Case $msg = $RollUpWindow
GUICtrlSetState($RollDownWindow,$GUI_ENABLE + $GUI_SHOW)
GUICtrlSetState($RollUpWindow,$GUI_DISABLE + $GUI_HIDE)
$WinSizeArray= WinGetPos($GUIHandle)
WinMove($GUIHandle,"",$WinSizeArray[0],$WinSizeArray[1],$WinSizeArray[2],$WinSizeArray[3]-375)

Case $msg = $SWButtonUnsk
savagedie("unskilled")
Case $msg = $SWButtonUnskx ;x dices
savagemultidie("unskilled")
Case $msg = $SWButtonUnskw ;Wild Die
savagewilddie("unskilled")
Case $msg = $SWButtonD4
savagedie(4)
Case $msg = $SWButtonD4x ;x dices
savagemultidie(4)
Case $msg = $SWButtonD4w ;Wild Die
savagewilddie(4)
Case $msg = $SWButtonD6
savagedie(6)
Case $msg = $SWButtonD6x ;x dices
savagemultidie(6)
Case $msg = $SWButtonD6w ;Wild Die
savagewilddie(6)
Case $msg = $SWButtonD8
savagedie(8)
Case $msg = $SWButtonD8x ;x dices
savagemultidie(8)
Case $msg = $SWButtonD8w ;Wild Die
savagewilddie(8)
Case $msg = $SWButtonD10
savagedie(10)
Case $msg = $SWButtonD10x ;x dices
savagemultidie(10)
Case $msg = $SWButtonD10w ;Wild Die
savagewilddie(10)
Case $msg = $SWButtonD12
savagedie(12)
Case $msg = $SWButtonD12x ;x dices
savagemultidie(12)
Case $msg = $SWButtonD12w ;Wild Die
savagewilddie(12)
Case $msg = $SWButtonD20
savagedie(20)
Case $msg = $SWButtonD20x ;x dices
savagemultidie(20)
Case $msg = $SWButtonD20w ;Wild Die
savagewilddie(20)

Case $msg = $SWModButtonD1
savagedie(1)
Case $msg = $SWModButtonD1x ;x dices
savagemultidie(1)
Case $msg = $SWModButtonD1W ;Wild Die
savagewilddie(1)
Case $msg = $SWModButtonD2
savagedie(2)
Case $msg = $SWModButtonD2x ;x dices
savagemultidie(2)
Case $msg = $SWModButtonD2W ;Wild Die
savagewilddie(2)
Case $msg = $SWModButtonD3
savagedie(3)
Case $msg = $SWModButtonD3x ;x dices
savagemultidie(3)
Case $msg = $SWModButtonD3W ;Wild Die
savagewilddie(3)
Case $msg = $SWModButtonD4
savagedie(4)
Case $msg = $SWModButtonD4x ;x dices
savagemultidie(4)
Case $msg = $SWModButtonD4W ;Wild Die
savagewilddie(4)
Case $msg = $SWModButtonD5
savagedie(5)
Case $msg = $SWModButtonD5x ;x dices
savagemultidie(5)
Case $msg = $SWModButtonD5W ;Wild Die
savagewilddie(5)
Case $msg = $SWModButtonD6
savagedie(6)
Case $msg = $SWModButtonD6x ;x dices
savagemultidie(6)
Case $msg = $SWModButtonD6W ;Wild Die
savagewilddie(6)
Case $msg = $SWModButtonD7
savagedie(7)
Case $msg = $SWModButtonD7x ;x dices
savagemultidie(7)
Case $msg = $SWModButtonD7W ;Wild Die
savagewilddie(7)
Case $msg = $SWModButtonD8
savagedie(8)
Case $msg = $SWModButtonD8x ;x dices
savagemultidie(8)
Case $msg = $SWModButtonD8W ;Wild Die
savagewilddie(8)
Case $msg = $SWModButtonD9
savagedie(9)
Case $msg = $SWModButtonD9x ;x dices
savagemultidie(9)
Case $msg = $SWModButtonD9W ;Wild Die
savagewilddie(9)
Case $msg = $SWModButtonD10
savagedie(10)
Case $msg = $SWModButtonD10x ;x dices
savagemultidie(10)
Case $msg = $SWModButtonD10W ;Wild Die
savagewilddie(10)
Case $msg = $SWModButtonD11
savagedie(11)
Case $msg = $SWModButtonD11x ;x dices
savagemultidie(11)
Case $msg = $SWModButtonD11W ;Wild Die
savagewilddie(11)
Case $msg = $SWModButtonD12
savagedie(12)
Case $msg = $SWModButtonD12x ;x dices
savagemultidie(12)
Case $msg = $SWModButtonD12W ;Wild Die
savagewilddie(12)
Case $msg = $SWModButtonD13
savagedie(13)
Case $msg = $SWModButtonD13x ;x dices
savagemultidie(13)
Case $msg = $SWModButtonD13W ;Wild Die
savagewilddie(13)
Case $msg = $SWModButtonD14
savagedie(14)
Case $msg = $SWModButtonD14x ;x dices
savagemultidie(14)
Case $msg = $SWModButtonD14W ;Wild Die
savagewilddie(14)
Case $msg = $SWModButtonD15
savagedie(15)
Case $msg = $SWModButtonD15x ;x dices
savagemultidie(15)
Case $msg = $SWModButtonD15W ;Wild Die
savagewilddie(15)
Case $msg = $SWModButtonD16
savagedie(16)
Case $msg = $SWModButtonD16x ;x dices
savagemultidie(16)
Case $msg = $SWModButtonD16W ;Wild Die
savagewilddie(16)
Case $msg = $SWModButtonD17
savagedie(17)
Case $msg = $SWModButtonD17x ;x dices
savagemultidie(17)
Case $msg = $SWModButtonD17W ;Wild Die
savagewilddie(17)
Case $msg = $SWModButtonD18
savagedie(18)
Case $msg = $SWModButtonD18x ;x dices
savagemultidie(18)
Case $msg = $SWModButtonD18W ;Wild Die
savagewilddie(18)
Case $msg = $SWModButtonD19
savagedie(19)
Case $msg = $SWModButtonD19x ;x dices
savagemultidie(19)
Case $msg = $SWModButtonD19W ;Wild Die
savagewilddie(19)
Case $msg = $SWModButtonD20
savagedie(20)
Case $msg = $SWModButtonD20x ;x dices
savagemultidie(20)
Case $msg = $SWModButtonD20W ;Wild Die
savagewilddie(20)

Case $msg = $FateButtonWeak
fatetable(3,15,84)
Case $msg = $FateButtonLow
fatetable(5,25,86)
Case $msg = $FateButtonBelowAvg
fatetable(7,35,88)
Case $msg = $FateButtonAvg
fatetable(10,50,91)
Case $msg = $FateButtonAboveAvg
fatetable(13,65,94)
Case $msg = $FateButtonHigh
fatetable(15,75,96)
Case $msg = $FateButtonExcep
fatetable(16,85,97)
EndSelect
If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend

;~ ---------------------------------------------------------------------------------------------------------------
;~ --------------------------------------- End of Main Script ----------------------------------------------------
;~ ---------------------------------------------------------------------------------------------------------------

Func easydie($die) ; simple die with output
$results = Random(1,$die, 1)
GUICtrlSetData($OutputWindow, $results & " (d" &$die &")" & @CRLF & GuiCtrlRead($OutputWindow))
EndFunc

Func multidie($die) ; multible dice rolls with output
dim $avArray[GUICtrlRead($NumberSelected)+1] ;This seems like the array is being declared with an extra element, don't know why
$string1=GUICtrlRead($NumberSelected)&"d"&$die ;the number of dice followed by the number of pips
for $i = 1 to GUICtrlRead($NumberSelected)
$avArray[$i-1]=Random(1,$die,1) ;$avArray[$i-1] is because the array element numbering starts at 0
Next
if GUICtrlRead($SortResults)=1 then _ArraySort( $avArray,1) ;Sorts array, 1= descending
$string=$avArray[0] ;Load the first element of the array inro $string
$total=int($avArray[0]) ;Load the first element of the array into $total
for $i = 1 to (GUICtrlRead($NumberSelected)-1)
$string= $string & ", " & $avArray[$i] ;Read the array values into a variable seperated by a comma and a space
$total=$total+int($avArray[$i]) ;Add the values in the array together
Next
GUICtrlSetData($OutputWindow, $string & " (" & "Total: " & $total & " | " &$string1 & ")" & @CRLF & GuiCtrlRead($OutputWindow))
EndFunc

Func DnDAttributes() ; D&D 3 Attribute roller (4d6 keep highest 3)
dim $avArray[4]
dim $total[6]
for $j = 0 to 5 ;Generate 6 different numbers
for $i = 0 to 3 ;Track array elements
$avArray[$i]=Random(1,6,1) ;Generate random values to store in the array.
next
_ArraySort( $avArray,1) ;Sort the array, descneding
$total[$j]=$avArray[0]+$avArray[1]+$avArray[2] ;add the first three (highest) values of the sorted array into the result array
next
_ArraySort($total,1) ;Sort the six results, descending
GUICtrlSetData($OutputWindow, "D&D Attributes: " & $total[0] & ", " & $total[1] & ", " & $total[2] & ", " & $total[3] & ", " & $total[4] & ", " & $total[5] & @CRLF & GuiCtrlRead($OutputWindow))
endfunc

Func savagedie($diex) ; roll again on max, unskilled d4-2
if $diex="unskilled" then ;If the button (die) = unskilled, then set the die to 4 and subtract 2 from the results.
$die=4
$results=-2
$string1="unskilled"
elseif $diex=1 then ;If a 1 is passed, use the formula d2-1 provided in the SW Attribute+ Skill doc to resolve the roll
$die=2
$results=-1
$string1="d"&$diex
else ;if $diex is 2 or more, the die = the value of the button and the results are not modified.
$die=$diex
$results=0
$string1="d"&$diex
endif
Do ;Generate die numbers until the number generated is less than the maximum number of pips on the die. Add the numbers to get the final results
$x=Random(1,$die,1)
$results=$results+$x
until $x<$die
GUICtrlSetData($OutputWindow, $results & " (" & $string1 & ")" & @CRLF & GuiCtrlRead($OutputWindow))
EndFunc

Func savagemultidie($diex) ;Same as savagedie but multiple dies
dim $avArray[GUICtrlRead($NumberSelected)+1]
if $diex="unskilled" then
$die=4
$string1="unskilled"
elseif $diex=1 Then
$die=2
$string1=GUICtrlRead($NumberSelected)&"d"&$diex
else
$die=$diex
$string1=GUICtrlRead($NumberSelected)&"d"&$diex
endif
for $i = 1 to GUICtrlRead($NumberSelected)
if $diex="unskilled" then
$avArray[$i-1]=-2
elseif $diex=1 then
$avArray[$i-1]=-1
else
$avArray[$i-1]=0
endif
Do
$x=Random(1,$die,1)
$avArray[$i-1]=$avArray[$i-1]+$x ;add the numbers to the $avArray variable at element $i-1
until $x<$die
Next
if GUICtrlRead($SortResults)=1 then _ArraySort( $avArray,1)
$string=$avArray[0]
$total=int($avArray[0])
for $i = 1 to (GUICtrlRead($NumberSelected)-1)
$string= $string & ", " & $avArray[$i]
$total=$total+int($avArray[$i])
Next
GUICtrlSetData($OutputWindow, $string & " (" & "Total: " & $total & " | " &$string1 & ")" & @CRLF & GuiCtrlRead($OutputWindow))
Endfunc

Func savagewilddie($diex) ; same as savagedie but roll also an additional d6 (wild die) -> higher roll counts
if $diex="unskilled" then
$die=4
$results1=-2
$results2=-2
$string1="unskilled"
elseif $diex=1 then
$die=2
$results1=-1
$results2=-1
$string1="d"&$diex
else
$die=$diex
$results1=0
$results2=0
$string1="d"&$diex
endif
Do
$x=Random(1,$die,1)
$results1=$results1+$x
until $x<$die
Do
$x=Random(1,6,1)
$results2=$results2+$x
until $x<6
if $results1 >= $results2 then
$string = $results1 & ", " & $results2 & "w (" & $string1 & ")"
else
$string = $results2 & "w, " & $results1 & " (" & $string1 & ")"
endif
GUICtrlSetData($OutputWindow, $string & @CRLF & GuiCtrlRead($OutputWindow))
endfunc

Func InitializeFullDeck() ;Create an array containing a full deck of cards, the placeholder is just window dressing in this deck
$FullDeck = _ArrayCreate("Ace of Spades", "Ace of Diamonds", "Ace of Hearts", "Ace of Clubs")
For $i=2 To 13
Switch $i
Case 2 To 10
$CardValue= $i
Case 11
$CardValue= "Jack"
Case 12
$CardValue= "Queen"
Case 13
$CardValue= "King"
EndSwitch
_ArrayAdd( $FullDeck,$CardValue&" of Spades")
_ArrayAdd( $FullDeck,$CardValue&" of Diamonds")
_ArrayAdd( $FullDeck,$CardValue&" of Hearts")
_ArrayAdd( $FullDeck,$CardValue&" of Clubs")
Next
_ArrayAdd($FullDeck,"Little Joker")
_ArrayAdd($FullDeck,"Big Joker")
_ArrayAdd($FullDeck,"Placeholder")
EndFunc

Func InitializeCardDeck1() ;create a deck of cards, the placeholder is so that there is still an element in the array when all the rest of the cards have been chosen.
$CardDeck1 = _ArrayCreate("Ace of Spades", "Ace of Diamonds", "Ace of Hearts", "Ace of Clubs")
For $i=2 To 13
Switch $i
Case 2 To 10
$CardValue= $i
Case 11
$CardValue= "Jack"
Case 12
$CardValue= "Queen"
Case 13
$CardValue= "King"
EndSwitch
_ArrayAdd( $CardDeck1,$CardValue&" of Spades")
_ArrayAdd( $CardDeck1,$CardValue&" of Diamonds")
_ArrayAdd( $CardDeck1,$CardValue&" of Hearts")
_ArrayAdd( $CardDeck1,$CardValue&" of Clubs")
Next
_ArrayAdd($CardDeck1,"Little Joker")
_ArrayAdd($CardDeck1,"Big Joker")
_ArrayAdd($CardDeck1,"Placeholder")
EndFunc

Func InitializeCardDeck2() ;Same as Deck 1
$CardDeck2 = _ArrayCreate("Ace of Spades", "Ace of Diamonds", "Ace of Hearts", "Ace of Clubs")
For $i=2 To 13
Switch $i
Case 2 To 10
$CardValue= $i
Case 11
$CardValue= "Jack"
Case 12
$CardValue= "Queen"
Case 13
$CardValue= "King"
EndSwitch
_ArrayAdd( $CardDeck2,$CardValue&" of Spades")
_ArrayAdd( $CardDeck2,$CardValue&" of Diamonds")
_ArrayAdd( $CardDeck2,$CardValue&" of Hearts")
_ArrayAdd( $CardDeck2,$CardValue&" of Clubs")
Next
_ArrayAdd($CardDeck2,"Little Joker")
_ArrayAdd($CardDeck2,"Big Joker")
_ArrayAdd($CardDeck2,"Placeholder")
EndFunc

Func DrawRandomCard()
$i=Random(0,53)
$CardDrawn=$FullDeck[$i]
GUICtrlSetData($OutputWindow, $CardDrawn & @CRLF & GuiCtrlRead($OutputWindow))
EndFunc

Func DrawFromDeck1()
$NumberOfCardsLeft=UBound($CardDeck1)-1 ;Subtract 1 for the placeholder
$i=Random(0, $NumberOfCardsLeft)
$CardDrawn=$CardDeck1[$i]
_ArrayDelete($CardDeck1,$i)
GUICtrlSetData($OutputWindow, $CardDrawn & @CRLF & GuiCtrlRead($OutputWindow))
If UBound($CardDeck1)=1 Then
InitializeCardDeck1()
GUICtrlSetData($OutputWindow, "Out of Cards. Deck 1 reshuffled." & @CRLF & GuiCtrlRead($OutputWindow))
EndIf
EndFunc

Func IssueCards($NumberOfPlayers)
Dim $CardsPicked[$NumberOfPlayers] ;Create an array to hold the cards picked
$NumberOfCardsLeft=UBound($CardDeck2)-1 ;Subtract 1 for the placeholder
If $NumberOfPlayers > 54 Then
GUICtrlSetData($OutputWindow, $NumberOfPlayers & "?! Thats more players then cards in the deck. Please choose a smaller number." & @CRLF & GuiCtrlRead($OutputWindow))
Return
ElseIf $NumberOfPlayers > $NumberOfCardsLeft Then
InitializeCardDeck2()
GUICtrlSetData($OutputWindow, "- - - - - -" & @CRLF & GuiCtrlRead($OutputWindow))
GUICtrlSetData($OutputWindow, "More players than cards remaining. Deck 2 reshuffled." & @CRLF & GuiCtrlRead($OutputWindow))
EndIf
GUICtrlSetData($OutputWindow, "-----------" & @CRLF & GuiCtrlRead($OutputWindow))
For $i = 0 To $NumberOfPlayers-1 ;Load the card array.
$j=Random(0, $NumberOfCardsLeft)
$CardDrawn=$CardDeck2[$j]
_ArrayDelete($CardDeck2,$j)
$CardsPicked[$i]=$CardDrawn
$NumberOfCardsLeft=UBound($CardDeck2)-1 ;Reset the number of cards left in the deck. Subtract 1 for the placeholder
Next
For $i = $NumberOfPlayers-1 To 0 Step -1
GUICtrlSetData($OutputWindow, "Player " & $i+1 & ": " & $CardsPicked[$i] & @CRLF & GuiCtrlRead($OutputWindow))
Next
If UBound($CardDeck2)=1 Then
InitializeCardDeck2()
GUICtrlSetData($OutputWindow, "Out of Cards. Deck 2 reshuffled." & @CRLF & GuiCtrlRead($OutputWindow))
EndIf
EndFunc

Func DrawFromDeck2()
$NumberOfCardsLeft=UBound($CardDeck2)-1 ;Subtract 1 for the placeholder
$i=Random(0, $NumberOfCardsLeft)
$CardDrawn=$CardDeck2[$i]
_ArrayDelete($CardDeck2,$i)
GUICtrlSetData($OutputWindow, $CardDrawn & @CRLF & GuiCtrlRead($OutputWindow))
If UBound($CardDeck2)=1 Then
InitializeCardDeck2()
GUICtrlSetData($OutputWindow, "Out of Cards. Deck 2 reshuffled." & @CRLF & GuiCtrlRead($OutputWindow))
EndIf
EndFunc

Func fatetable($1,$2,$3) ; choose how probale a question is and it will thell you Yes++/Yes/No/No-- -> more explaination in the Mythic RPG
$results = Random(1,100, 1)
Select
Case $results <= $1
GUICtrlSetData($OutputWindow, "Yes maximum" & @CRLF & GuiCtrlRead($OutputWindow))
Case $results <= $2
GUICtrlSetData($OutputWindow, "Yes" & @CRLF & GuiCtrlRead($OutputWindow))
Case $results < $3
GUICtrlSetData($OutputWindow, "No" & @CRLF & GuiCtrlRead($OutputWindow))
Case Else
GUICtrlSetData($OutputWindow, "No maximum" & @CRLF & GuiCtrlRead($OutputWindow))
EndSelect
endfunc

Cheers

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...