Sign in to follow this  
Followers 0
RazerM

GUIGetMsg() trouble

3 posts in this topic

#1 ·  Posted (edited)

I am making a Deal or No Deal game in AutoIt (Uk version). It deletes the corresponding money input when a button is pressed however it keeps deleting one input on startup

;===============================================================================
;
; Program Name:   Deal Or No deal
; Description:: Replication of popular gameshow
; Requirement(s):  AutoIt beta
; Author(s):       RazerM
;
;===============================================================================
;
#include <GUIConstants.au3>
#include <array.au3>
#include <string.au3>

$title = "Deal or No Deal"
GUICreate($title, 600, 500)
Dim $blue[11] = [0.01, 0.10, 0.50, 1, 5, 10, 50, 100, 250, 500, 750]
Dim $red[11] = [1000, 3000, 5000, 10000, 15000, 20000, 35000, 50000, 75000, 100000, 250000]
Dim $boxes[23]
Dim $control[25]
Dim $labels[1] = ["delete"]

For $i = 0 To 10
 $control[$i] = GUICtrlCreateInput("£" & $blue[$i], 10, 25*$i+10, 100, -1, $ES_CENTER)
 _ArrayAdd($labels, $control[$i])
 GUICtrlSetBkColor(-1, 0x0000ff)
 GUICtrlSetColor(-1, 0xffffff)
 $control[$i+10] = GUICtrlCreateInput("£" & _StringReverse(StringReplace(_StringReverse($red[$i]), "000", "000,")), 490, 25*$i+10, 100, -1, $ES_CENTER)
 _ArrayAdd($labels, $control[$i+10])
 GUICtrlSetBkColor(-1, 0xff0000)
 GUICtrlSetColor(-1, 0xffffff)
Next
_ArraySortRand($labels)
$delete = _ArraySearch($labels, "delete")
_ArrayDelete($labels, $delete)
$i = 1
For $y = 0 To 3
 For $x = 1 To 5
  $boxes[$i] = GUICtrlCreateButton($i, 75*$x+45, 45*$y+10, 60, 40)
  $i += 1
 Next
Next
$boxes[21] = GUICtrlCreateButton(21, 195, 190, 60, 40)
$boxes[22] = GUICtrlCreateButton(22, 345, 190, 60, 40)
$status = GUICtrlCreateLabel("Pick Your Box", 10, 285, 580, 40)
GUICtrlSetFont($status, 30)
GUICtrlSetState($status, $GUI_FOCUS)
GUISetState()

While 1
 $msg = GUIGetMsg()
 Switch $msg
  Case $GUI_EVENT_CLOSE
   Exit
;~  Case 
;~  Case 
;~  Case 
;~  Case 
 EndSwitch
 For $i = 0 To 21
  If $msg = $boxes[$i] Then
   GUICtrlDelete($labels[$i])
  EndIf
 Next
WEnd

Func _ArraySortRand(ByRef $array)
 $iUbound = UBound($array)
 For $i = 0 To ($iUbound-1)*3
  _ArraySwap($array[Random(0, $iUbound-1, 1)], $array[Random(0, $iUbound-1, 1)])
 Next
EndFunc

edit:

tags have messed up the indentation
Edited by RazerM

My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I am making a Deal or No Deal game in AutoIt (Uk version). It deletes the corresponding money input when a button is pressed however it keeps deleting one input on startup

CODE
;===============================================================================

;

; Program Name: Deal Or No deal

; Description:: Replication of popular gameshow

; Requirement(s): AutoIt beta

; Author(s): RazerM

;

;===============================================================================

;

#include <GUIConstants.au3>

#include <array.au3>

#include <string.au3>

$title = "Deal or No Deal"

GUICreate($title, 600, 500)

Dim $blue[11] = [0.01, 0.10, 0.50, 1, 5, 10, 50, 100, 250, 500, 750]

Dim $red[11] = [1000, 3000, 5000, 10000, 15000, 20000, 35000, 50000, 75000, 100000, 250000]

Dim $boxes[23]

Dim $control[25]

Dim $labels[1] = ["delete"]

For $i = 0 To 10

$control[$i] = GUICtrlCreateInput("£" & $blue[$i], 10, 25*$i+10, 100, -1, $ES_CENTER)

_ArrayAdd($labels, $control[$i])

GUICtrlSetBkColor(-1, 0x0000ff)

GUICtrlSetColor(-1, 0xffffff)

$control[$i+10] = GUICtrlCreateInput("£" & _StringReverse(StringReplace(_StringReverse($red[$i]), "000", "000,")), 490, 25*$i+10, 100, -1, $ES_CENTER)

_ArrayAdd($labels, $control[$i+10])

GUICtrlSetBkColor(-1, 0xff0000)

GUICtrlSetColor(-1, 0xffffff)

Next

_ArraySortRand($labels)

$delete = _ArraySearch($labels, "delete")

_ArrayDelete($labels, $delete)

$i = 1

For $y = 0 To 3

For $x = 1 To 5

$boxes[$i] = GUICtrlCreateButton($i, 75*$x+45, 45*$y+10, 60, 40)

$i += 1

Next

Next

$boxes[21] = GUICtrlCreateButton(21, 195, 190, 60, 40)

$boxes[22] = GUICtrlCreateButton(22, 345, 190, 60, 40)

$status = GUICtrlCreateLabel("Pick Your Box", 10, 285, 580, 40)

GUICtrlSetFont($status, 30)

GUICtrlSetState($status, $GUI_FOCUS)

GUISetState()

While 1

$msg = GUIGetMsg()

Switch $msg

Case $GUI_EVENT_CLOSE

Exit

;~ Case

;~ Case

;~ Case

;~ Case

EndSwitch

For $i = 0 To 21

If $msg = $boxes[$i] Then

GUICtrlDelete($labels[$i])

EndIf

Next

WEnd

Func _ArraySortRand(ByRef $array)

$iUbound = UBound($array)

For $i = 0 To ($iUbound-1)*3

_ArraySwap($array[Random(0, $iUbound-1, 1)], $array[Random(0, $iUbound-1, 1)])

Next

EndFunc

edit:
tags have messed up the indentation

In this code segment:

For $i = 0 To 10
     $control[$i] = GUICtrlCreateInput("£" & $blue[$i], 10, 25*$i+10, 100, -1, $ES_CENTER)
     _ArrayAdd($labels, $control[$i])
     GUICtrlSetBkColor(-1, 0x0000ff)
     GUICtrlSetColor(-1, 0xffffff)
     $control[$i+10] = GUICtrlCreateInput("£" & _StringReverse(StringReplace(_StringReverse($red[$i]), "000", "000,")), 490, 25*$i+10, 100, -1, $ES_CENTER)
     _ArrayAdd($labels, $control[$i+10])
     GUICtrlSetBkColor(-1, 0xff0000)
     GUICtrlSetColor(-1, 0xffffff)
Next

When $i = 0 you write to $control[0] with the first GUICtrlCreateInput() and then write to $control[10] with the second. When $i = 10 you overwrite $control[10] with the first, and write to $control[20] with the second. I'll bet that's not intentional.

:D

P.S. Woo Hoo! [ autoit ] tags are working again! :D

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Thanks never realised. I also corrected the other problem aswell.


My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.

Share this post


Link to post
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
Sign in to follow this  
Followers 0