Jump to content

Catch an error and stop it from exiting


Go to solution Solved by Damein,

Recommended Posts

Sorry I know there's a way to do this but I can't think of what else to search for and am at a loss.

I want to be able to catch an error message like

"Array variable has incorrect number of subscripts or subscript dimension range exceeded."

And tell the script to do something else if this occurs and not stop the script entirely. 

THanks!

MCR.jpg?t=1286371579

Most recent sig. I made

Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic

Link to comment
Share on other sites

I'm sorry but I don't understand how that helps.

If I place If @error below the line it error's out at nothing happens. I don't see how I can utilize SetError either since before it gets to that line it will error out.

$Card2ToMoveData = $Player1Cards[$Card2ToMove]

That's the line of code it error's out at if $Player1Cards[$Card2ToMove] doesn't exist.

IE: If I call $Card2ToMoveData = 13 but the array doesn't go to 13 it will cause the error. I wan't to catch that.

MCR.jpg?t=1286371579

Most recent sig. I made

Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic

Link to comment
Share on other sites

Fix the code so that the erroneous condition never occurs!

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

 

IE: If I call $Card2ToMoveData = 13 but the array doesn't go to 13 it will cause the error. I wan't to catch that.

 

Look into Ubound and dont let any loops go above it

The below will keep your loop from exceeding the number of items in your array

Use the -1 because Ubound counts from 1 to xxx where an array counts from 0 - xxx

For $i = 0 to Ubound( $Card2ToMoveData) - 1

Next

Link to comment
Share on other sites

I'm sorry but I don't understand how that helps.

If I place If @error below the line it error's out at nothing happens. I don't see how I can utilize SetError either since before it gets to that line it will error out.

$Card2ToMoveData = $Player1Cards[$Card2ToMove]

That's the line of code it error's out at if $Player1Cards[$Card2ToMove] doesn't exist.

IE: If I call $Card2ToMoveData = 13 but the array doesn't go to 13 it will cause the error. I wan't to catch that.

Are you using this for a card game bot? Your code strongly suggest you are. Thread reported for a moderator to review.

Edited by MBALZESHARI
Link to comment
Share on other sites

  • Moderators

Damein,

Any response to MBALZESHARI's post? :huh:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

I'm sorry, I was asleep :)

No, nothing like that. It's for a card game made in AutoIt.

Here is the full code.

The game is called Tichu, a very fun game!

 

Card Module to give player's a new hand

#include <Array.au3>

Func _CreateHands()
Global $FoundCard = 0

Dim $Cards[57], $Card[57], $Player1Cards[0], $Player2Cards[0], $Player3Cards[0], $Player4Cards[0]
For $i = 1 To 56
    $Cards[$i] = "0"
Next

$Card[1] = "2C"
$Card[2] = "2S"
$Card[3] = "2D"
$Card[4] = "2H"
$Card[5] = "3C"
$Card[6] = "3S"
$Card[7] = "3D"
$Card[8] = "3H"
$Card[9] = "4C"
$Card[10] = "4S"
$Card[11] = "4D"
$Card[12] = "4H"
$Card[13] = "5C"
$Card[14] = "5S"
$Card[15] = "5D"
$Card[16] = "5H"
$Card[17] = "6C"
$Card[18] = "6S"
$Card[19] = "6D"
$Card[20] = "6H"
$Card[21] = "7C"
$Card[22] = "7S"
$Card[23] = "7D"
$Card[24] = "7H"
$Card[25] = "8C"
$Card[26] = "8S"
$Card[27] = "8D"
$Card[28] = "8H"
$Card[29] = "9C"
$Card[30] = "9S"
$Card[31] = "9D"
$Card[32] = "9H"
$Card[33] = "10C"
$Card[34] = "10S"
$Card[35] = "10D"
$Card[36] = "10H"
$Card[37] = "JC"
$Card[38] = "JS"
$Card[39] = "JD"
$Card[40] = "JH"
$Card[41] = "QC"
$Card[42] = "QS"
$Card[43] = "QD"
$Card[44] = "QH"
$Card[45] = "KC"
$Card[46] = "KS"
$Card[47] = "KD"
$Card[48] = "KH"
$Card[49] = "AC"
$Card[50] = "AS"
$Card[51] = "AD"
$Card[52] = "AH"
$Card[53] = "Dog"
$Card[54] = "Dragon"
$Card[55] = "Bird"
$Card[56] = "Phoenix"

While $FoundCard < 14
    $Random = Random(1, 56, 1)
    If $Cards[$Random] = "0" Then
        _arrayAdd($Player1Cards, $Card[$Random])
        $FoundCard += 1
        $Cards[$Random] = "1"
    EndIf
WEnd

$FoundCard = 0

While $FoundCard < 14
    $Random = Random(1, 56, 1)
    If $Cards[$Random] = "0" Then
        _arrayAdd($Player2Cards, $Card[$Random])
        $FoundCard += 1
        $Cards[$Random] = "1"
    EndIf
WEnd

$FoundCard = 0

While $FoundCard < 14
    $Random = Random(1, 56, 1)
    If $Cards[$Random] = "0" Then
        _arrayAdd($Player3Cards, $Card[$Random])
        $FoundCard += 1
        $Cards[$Random] = "1"
    EndIf
WEnd

$FoundCard = 0

While $FoundCard < 14
    $Random = Random(1, 56, 1)
    If $Cards[$Random] = "0" Then
        _arrayAdd($Player4Cards, $Card[$Random])
        $FoundCard += 1
        $Cards[$Random] = "1"
    EndIf
WEnd
EndFunc

;~ _ArrayDisplay($Player1Cards)
;~ _ArrayDisplay($Player2Cards)
;~ _ArrayDisplay($Player3Cards)
;~ _ArrayDisplay($Player4Cards)

The current code that I have made up, haven't gotten very far.

#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#include ".\Skins\Hex.au3"
#include "_UskinLibrary.au3"
#include "Cards Module.au3"


_Uskin_LoadDLL()
_USkin_Init(_Hex(True))

Opt("GUIOnEventMode", 1)


Global $Player1Cards, $Player2Cards, $Player3Cards, $Player4Cards
Global $CurrentGui, $MainGui, $HandGui, $CardCount

Dim $Player1Card[20], $Player1Cards[20]

_DealCards()

_CreateGui()

Func _CreateGui()
    $CurrentGui = "MainGui"
    $MainGui = GuiCreate("Tichu", 800,500)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
    GuiSetFont(11)

    $DisplayTeamAName = GuiCtrlCreateInput("", 5,5,140,20, BitOr($ES_READONLY, $ES_Center))
    $DisplayTeamAPoints = GuiCtrlCreateInput("0", 50, 30, 40,20, BitOr($ES_ReadOnly, $ES_Center))
    $DisplayTeamBName = GuiCtrlCreateInput("", 655,5,140,20, BitOr($ES_READONLY, $ES_Center))
    $DisplayTeamBPoints = GuiCtrlCreateInput("0", 705, 30, 40,20, BitOr($ES_ReadOnly, $ES_Center))

    GuiCtrlCreateLabel("Player 1:", 0, 380)
    GuiCtrlCreateLabel("Player 2:", 0, 410)
    GuiCtrlCreateLabel("Player 3:", 0, 440)
    GuiCtrlCreateLabel("Player 4:", 0, 470)

    $DisplayPlayer1Name = GuiCtrlCreateInput("Prophete", 60, 378, 100,20, BitOr($ES_ReadOnly, $ES_Center))
    $DisplayPlayer2Name = GuiCtrlCreateInput("Prophete", 60, 408, 100,20, BitOr($ES_ReadOnly, $ES_Center))
    $DisplayPlayer3Name = GuiCtrlCreateInput("Prophete", 60, 438, 100,20, BitOr($ES_ReadOnly, $ES_Center))
    $DisplayPlayer4Name = GuiCtrlCreateInput("Prophete", 60, 468, 100,20, BitOr($ES_ReadOnly, $ES_Center))

    GuiCtrlCreatePic(@ScriptDIr & "/Images/TichuBackOfCard.Bmp", 350, 30, 80,130)
    GuiCtrlCreatePic(@ScriptDIr & "/Images/TichuBackOfCard.Bmp", 350, 340, 80,130)
    GuiCtrlCreatePic(@ScriptDIr & "/Images/TichuBackOfCard.Bmp", 30, 200, 80,130)
    GuiCtrlCreatePic(@ScriptDIr & "/Images/TichuBackOfCard.Bmp", 680, 200, 80,130)

    $DisplayPlayer1CardsRemaining = GuiCtrlCreateInput("14 Cards Left", 340, 3,100, 20, BitOr($ES_ReadOnly, $ES_Center))
    $DisplayPlayer2CardsRemaining = GuiCtrlCreateInput("14 Cards Left", 340, 475,100, 20, BitOr($ES_ReadOnly, $ES_Center))
    $DisplayPlayer3CardsRemaining = GuiCtrlCreateInput("14 Cards Left", 20, 335,100, 20, BitOr($ES_ReadOnly, $ES_Center))
    $DisplayPlayer4CardsRemaining = GuiCtrlCreateInput("14 Cards Left", 670, 335,100, 20, BitOr($ES_ReadOnly, $ES_Center))

    GuiCtrlCreatePic(@ScriptDIr & "/Images/TichuPlayingFIeld.bmp", 200, 180, 380,140)
    GuiCtrlCreatePic(@ScriptDIr & "/Images/Bomb.bmp", 200, 180, 380,140)

    $PlayButton = GuiCtrlCreateButton("Hand", 240, 470, 80,30)
    GuiCtrlSetOnEvent(-1, "_HandGUI")
    $PassButton = GuiCtrlCreateButton("Pass", 465, 470, 80,30)
    GuiSetState()
EndFunc

Func _HandGUI()
    $CurrentGui = "Hand"
    $HandGui = GuiCreate("Hand", 800,400)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
    GuiSetBkColor(0xFFFFFF)
    GuiSetFont(11)

    $Cards = _ArrayToString($Player1Cards, "|")
    $SplitCards = StringSplit($Cards, "|")

    $CardCount = $SplitCards[0]


    $X = 15
    For $i = 0 To $CardCount - 1
                If $i = 9 Then
            $X = 185
        EndIf
        If $i < 9 Then
    $Player1Card[$i] = GuiCtrlCreatePic(@ScriptDir & "/Images/Deck/" & $Player1Cards[$i] & ".bmp", $X, 20, 80,130)
            $X += 85
        Else
    $Player1Card[$i] = GuiCtrlCreatePic(@ScriptDir & "/Images/Deck/" & $Player1Cards[$i] & ".bmp", $X, 170, 80,130)
    $X += 85
        EndIf
    Next

    $X = 50
    For $i = 0 To 8
        GuiCtrlCreateLabel($i, $X,0, 80,20)
        GuiCtrlSetFont(-1, 12)
        $X += 85
    Next
    $X = 215
    For $i = 9 To 13
        GuiCtrlCreateLabel($i, $X, 150, 80, 20)
        GuiCtrlSetFont(-1, 12)
        $X += 85
    Next

    $MoveCard = GuiCtrlCreateButton("Move Card", 10,360,120,40)
    GuiCtrlSetOnEvent(-1, "_MoveCard")
    $TradeCards = GuiCtrlCreateButton("Trade Cards", 10,360,120,40)
    GuiCtrlSetOnEvent(-1, "_TradeCards")
    $RemoveCard = GuiCtrlCreateButton("Remove Card", 300,360,120,40)
    GuiCtrlSetOnEvent(-1, "_RemoveCard")
    GuiSetState()

EndFunc

Func _TradeCards()
    $TradePlayer1 = InputBox("Trade Cards", "Please input the player you would like to trade with." & @CRLF & @CRLF & "IE: 1, 2 or 3")
    $TradePlayer1Card = InputBox("Trade Cards", "Please input the card you would like to trade." & @CRLF & @CRLF & "0 being position 1 - 13")
    $TradePlayer2 = InputBox("Trade Cards", "Please input the player you would like to trade with." & @CRLF & @CRLF & "IE: 1, 2 or 3")
    $TradePlayer2Card = InputBox("Trade Cards", "Please input the card you would like to trade." & @CRLF & @CRLF & "0 being position 1 - 13")
    $TradePlayer3 = InputBox("Trade Cards", "Please input the player you would like to trade with." & @CRLF & @CRLF & "IE: 1, 2 or 3")
    $TradePlayer3Card = InputBox("Trade Cards", "Please input the card you would like to trade." & @CRLF & @CRLF & "0 being position 1 - 13")
EndFunc


Func _RemoveCard()
    _ArrayDelete($Player1Cards, 3)
        GuiDelete($HandGui)
    _HandGui()
EndFunc

Func _MoveCard()
    $Card1ToMove = InputBox("Move Card", "Please type a number from 0-13 of the position of the first card to move." & @CRLF & "0 being position 1.")
    $Card2ToMove = InputBox("Move Card", "Please type a number from 0-13 of the position of the second card to move." & @CRLF & "0 being position 1.")
    $Card1ToMoveData = $Player1Cards[$Card1ToMove]
    $Card2ToMoveData = $Player1Cards[$Card2ToMove]
    If $Card2ToMoveData = "" Then
        SetError(1)
        Else
    _ArraySwap($Player1Cards[$Card1ToMove], $Player1Cards[$Card2ToMove])
    GuiDelete($HandGui)
    _HandGui()
EndIf
EndFunc



Func _DealCards()
    _CreateHands()
EndFunc


Func _Exit()
    If $CurrentGui = "Hand" Then
        GuiDelete($HandGui)
        $CurrentGui = "MainGui"
    ElseIf $CurrentGui = "MainGui" Then
    Exit
EndIf
EndFunc

While 1
    Sleep(10)
WEnd

There's a bunch of images and stuff related but that should be enough to prove that :P

And thanks Shane for the info, I'll look into that.

Edited by Damein

MCR.jpg?t=1286371579

Most recent sig. I made

Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic

Link to comment
Share on other sites

  • Moderators

Damein,

Fine. I hope you are refreshed after your "internal eyelid inspection" and ready to resume coding. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

I'm sorry, I was asleep :)

No, nothing like that. It's for a card game made in AutoIt.

Here is the full code.

The game is called Tichu, a very fun game!

 

Card Module to give player's a new hand

#include <Array.au3>

Func _CreateHands()
Global $FoundCard = 0

Dim $Cards[57], $Card[57], $Player1Cards[0], $Player2Cards[0], $Player3Cards[0], $Player4Cards[0]
For $i = 1 To 56
    $Cards[$i] = "0"
Next

$Card[1] = "2C"
$Card[2] = "2S"
$Card[3] = "2D"
$Card[4] = "2H"
$Card[5] = "3C"
$Card[6] = "3S"
$Card[7] = "3D"
$Card[8] = "3H"
$Card[9] = "4C"
$Card[10] = "4S"
$Card[11] = "4D"
$Card[12] = "4H"
$Card[13] = "5C"
$Card[14] = "5S"
$Card[15] = "5D"
$Card[16] = "5H"
$Card[17] = "6C"
$Card[18] = "6S"
$Card[19] = "6D"
$Card[20] = "6H"
$Card[21] = "7C"
$Card[22] = "7S"
$Card[23] = "7D"
$Card[24] = "7H"
$Card[25] = "8C"
$Card[26] = "8S"
$Card[27] = "8D"
$Card[28] = "8H"
$Card[29] = "9C"
$Card[30] = "9S"
$Card[31] = "9D"
$Card[32] = "9H"
$Card[33] = "10C"
$Card[34] = "10S"
$Card[35] = "10D"
$Card[36] = "10H"
$Card[37] = "JC"
$Card[38] = "JS"
$Card[39] = "JD"
$Card[40] = "JH"
$Card[41] = "QC"
$Card[42] = "QS"
$Card[43] = "QD"
$Card[44] = "QH"
$Card[45] = "KC"
$Card[46] = "KS"
$Card[47] = "KD"
$Card[48] = "KH"
$Card[49] = "AC"
$Card[50] = "AS"
$Card[51] = "AD"
$Card[52] = "AH"
$Card[53] = "Dog"
$Card[54] = "Dragon"
$Card[55] = "Bird"
$Card[56] = "Phoenix"

While $FoundCard < 14
    $Random = Random(1, 56, 1)
    If $Cards[$Random] = "0" Then
        _arrayAdd($Player1Cards, $Card[$Random])
        $FoundCard += 1
        $Cards[$Random] = "1"
    EndIf
WEnd

$FoundCard = 0

While $FoundCard < 14
    $Random = Random(1, 56, 1)
    If $Cards[$Random] = "0" Then
        _arrayAdd($Player2Cards, $Card[$Random])
        $FoundCard += 1
        $Cards[$Random] = "1"
    EndIf
WEnd

$FoundCard = 0

While $FoundCard < 14
    $Random = Random(1, 56, 1)
    If $Cards[$Random] = "0" Then
        _arrayAdd($Player3Cards, $Card[$Random])
        $FoundCard += 1
        $Cards[$Random] = "1"
    EndIf
WEnd

$FoundCard = 0

While $FoundCard < 14
    $Random = Random(1, 56, 1)
    If $Cards[$Random] = "0" Then
        _arrayAdd($Player4Cards, $Card[$Random])
        $FoundCard += 1
        $Cards[$Random] = "1"
    EndIf
WEnd
EndFunc

;~ _ArrayDisplay($Player1Cards)
;~ _ArrayDisplay($Player2Cards)
;~ _ArrayDisplay($Player3Cards)
;~ _ArrayDisplay($Player4Cards)

The current code that I have made up, haven't gotten very far.

#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#include ".\Skins\Hex.au3"
#include "_UskinLibrary.au3"
#include "Cards Module.au3"


_Uskin_LoadDLL()
_USkin_Init(_Hex(True))

Opt("GUIOnEventMode", 1)


Global $Player1Cards, $Player2Cards, $Player3Cards, $Player4Cards
Global $CurrentGui, $MainGui, $HandGui, $CardCount

Dim $Player1Card[20], $Player1Cards[20]

_DealCards()

_CreateGui()

Func _CreateGui()
    $CurrentGui = "MainGui"
    $MainGui = GuiCreate("Tichu", 800,500)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
    GuiSetFont(11)

    $DisplayTeamAName = GuiCtrlCreateInput("", 5,5,140,20, BitOr($ES_READONLY, $ES_Center))
    $DisplayTeamAPoints = GuiCtrlCreateInput("0", 50, 30, 40,20, BitOr($ES_ReadOnly, $ES_Center))
    $DisplayTeamBName = GuiCtrlCreateInput("", 655,5,140,20, BitOr($ES_READONLY, $ES_Center))
    $DisplayTeamBPoints = GuiCtrlCreateInput("0", 705, 30, 40,20, BitOr($ES_ReadOnly, $ES_Center))

    GuiCtrlCreateLabel("Player 1:", 0, 380)
    GuiCtrlCreateLabel("Player 2:", 0, 410)
    GuiCtrlCreateLabel("Player 3:", 0, 440)
    GuiCtrlCreateLabel("Player 4:", 0, 470)

    $DisplayPlayer1Name = GuiCtrlCreateInput("Prophete", 60, 378, 100,20, BitOr($ES_ReadOnly, $ES_Center))
    $DisplayPlayer2Name = GuiCtrlCreateInput("Prophete", 60, 408, 100,20, BitOr($ES_ReadOnly, $ES_Center))
    $DisplayPlayer3Name = GuiCtrlCreateInput("Prophete", 60, 438, 100,20, BitOr($ES_ReadOnly, $ES_Center))
    $DisplayPlayer4Name = GuiCtrlCreateInput("Prophete", 60, 468, 100,20, BitOr($ES_ReadOnly, $ES_Center))

    GuiCtrlCreatePic(@ScriptDIr & "/Images/TichuBackOfCard.Bmp", 350, 30, 80,130)
    GuiCtrlCreatePic(@ScriptDIr & "/Images/TichuBackOfCard.Bmp", 350, 340, 80,130)
    GuiCtrlCreatePic(@ScriptDIr & "/Images/TichuBackOfCard.Bmp", 30, 200, 80,130)
    GuiCtrlCreatePic(@ScriptDIr & "/Images/TichuBackOfCard.Bmp", 680, 200, 80,130)

    $DisplayPlayer1CardsRemaining = GuiCtrlCreateInput("14 Cards Left", 340, 3,100, 20, BitOr($ES_ReadOnly, $ES_Center))
    $DisplayPlayer2CardsRemaining = GuiCtrlCreateInput("14 Cards Left", 340, 475,100, 20, BitOr($ES_ReadOnly, $ES_Center))
    $DisplayPlayer3CardsRemaining = GuiCtrlCreateInput("14 Cards Left", 20, 335,100, 20, BitOr($ES_ReadOnly, $ES_Center))
    $DisplayPlayer4CardsRemaining = GuiCtrlCreateInput("14 Cards Left", 670, 335,100, 20, BitOr($ES_ReadOnly, $ES_Center))

    GuiCtrlCreatePic(@ScriptDIr & "/Images/TichuPlayingFIeld.bmp", 200, 180, 380,140)
    GuiCtrlCreatePic(@ScriptDIr & "/Images/Bomb.bmp", 200, 180, 380,140)

    $PlayButton = GuiCtrlCreateButton("Hand", 240, 470, 80,30)
    GuiCtrlSetOnEvent(-1, "_HandGUI")
    $PassButton = GuiCtrlCreateButton("Pass", 465, 470, 80,30)
    GuiSetState()
EndFunc

Func _HandGUI()
    $CurrentGui = "Hand"
    $HandGui = GuiCreate("Hand", 800,400)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
    GuiSetBkColor(0xFFFFFF)
    GuiSetFont(11)

    $Cards = _ArrayToString($Player1Cards, "|")
    $SplitCards = StringSplit($Cards, "|")

    $CardCount = $SplitCards[0]


    $X = 15
    For $i = 0 To $CardCount - 1
                If $i = 9 Then
            $X = 185
        EndIf
        If $i < 9 Then
    $Player1Card[$i] = GuiCtrlCreatePic(@ScriptDir & "/Images/Deck/" & $Player1Cards[$i] & ".bmp", $X, 20, 80,130)
            $X += 85
        Else
    $Player1Card[$i] = GuiCtrlCreatePic(@ScriptDir & "/Images/Deck/" & $Player1Cards[$i] & ".bmp", $X, 170, 80,130)
    $X += 85
        EndIf
    Next

    $X = 50
    For $i = 0 To 8
        GuiCtrlCreateLabel($i, $X,0, 80,20)
        GuiCtrlSetFont(-1, 12)
        $X += 85
    Next
    $X = 215
    For $i = 9 To 13
        GuiCtrlCreateLabel($i, $X, 150, 80, 20)
        GuiCtrlSetFont(-1, 12)
        $X += 85
    Next

    $MoveCard = GuiCtrlCreateButton("Move Card", 10,360,120,40)
    GuiCtrlSetOnEvent(-1, "_MoveCard")
    $TradeCards = GuiCtrlCreateButton("Trade Cards", 10,360,120,40)
    GuiCtrlSetOnEvent(-1, "_TradeCards")
    $RemoveCard = GuiCtrlCreateButton("Remove Card", 300,360,120,40)
    GuiCtrlSetOnEvent(-1, "_RemoveCard")
    GuiSetState()

EndFunc

Func _TradeCards()
    $TradePlayer1 = InputBox("Trade Cards", "Please input the player you would like to trade with." & @CRLF & @CRLF & "IE: 1, 2 or 3")
    $TradePlayer1Card = InputBox("Trade Cards", "Please input the card you would like to trade." & @CRLF & @CRLF & "0 being position 1 - 13")
    $TradePlayer2 = InputBox("Trade Cards", "Please input the player you would like to trade with." & @CRLF & @CRLF & "IE: 1, 2 or 3")
    $TradePlayer2Card = InputBox("Trade Cards", "Please input the card you would like to trade." & @CRLF & @CRLF & "0 being position 1 - 13")
    $TradePlayer3 = InputBox("Trade Cards", "Please input the player you would like to trade with." & @CRLF & @CRLF & "IE: 1, 2 or 3")
    $TradePlayer3Card = InputBox("Trade Cards", "Please input the card you would like to trade." & @CRLF & @CRLF & "0 being position 1 - 13")
EndFunc


Func _RemoveCard()
    _ArrayDelete($Player1Cards, 3)
        GuiDelete($HandGui)
    _HandGui()
EndFunc

Func _MoveCard()
    $Card1ToMove = InputBox("Move Card", "Please type a number from 0-13 of the position of the first card to move." & @CRLF & "0 being position 1.")
    $Card2ToMove = InputBox("Move Card", "Please type a number from 0-13 of the position of the second card to move." & @CRLF & "0 being position 1.")
    $Card1ToMoveData = $Player1Cards[$Card1ToMove]
    $Card2ToMoveData = $Player1Cards[$Card2ToMove]
    If $Card2ToMoveData = "" Then
        SetError(1)
        Else
    _ArraySwap($Player1Cards[$Card1ToMove], $Player1Cards[$Card2ToMove])
    GuiDelete($HandGui)
    _HandGui()
EndIf
EndFunc



Func _DealCards()
    _CreateHands()
EndFunc


Func _Exit()
    If $CurrentGui = "Hand" Then
        GuiDelete($HandGui)
        $CurrentGui = "MainGui"
    ElseIf $CurrentGui = "MainGui" Then
    Exit
EndIf
EndFunc

While 1
    Sleep(10)
WEnd

There's a bunch of images and stuff related but that should be enough to prove that :P

And thanks Shane for the info, I'll look into that.

 

Nice work! Keep it up! :thumbsup:

Edited by MBALZESHARI
Link to comment
Share on other sites

  • Solution

Thanks for the pass and I figured a way out to do what I needed via

$Cards = _ArrayToString($Player1Cards, "|")
    $SplitCards = StringSplit($Cards, "|")

    $CardCount = $SplitCards[0]
    If $Card1ToMove > $CardCount - 1 Then
        MsgBox(48, "Error", "That card no longer exists, please use a different combination of cards.")
    ElseIf $Card2ToMove > $CardCount - 1 Then
        MsgBox(48, "Error", "That card no longer exists, please use a different combiniation of cards.")
    Else

MCR.jpg?t=1286371579

Most recent sig. I made

Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic

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...