Jump to content

Need help with GUI Label


Recommended Posts

Here is my script.

#include <GUIConstants.au3>

#region - Global

Global $FrontGUI

Global $Width = 700

Global $Height = 500

Global $Filemenu

Global $Newgameitem

Global $Exititem

Global $ButtonA

Global $ButtonB

Global $ButtonC

Global $questlabel

Global $CombatGUI

Global $ButtonAttack

Global $CharactersetupGUI

Global $msg

Global $Newcount

Global $Count

Global $QuestA

Global $QuestB

Global $QuestC

#endregion

#Region - RPG GUI Create

$FrontGUI = GUICreate ("RPG",$width, $Height)

$Filemenu = GuiCtrlCreateMenu ("File")

$Newgameitem = GUICtrlCreateMenuitem ("New Game", $Filemenu)

$Exititem = GuiCtrlCreateMenuitem ("Exit", $Filemenu)

$ButtonA = GUICtrlCreateButton ("A.", 100,440,70,20)

$ButtonB = GUICtrlCreateButton ("B.", 365,440,70,20)

$ButtonC = GUICtrlCreateButton ("C.", 630,440,70,20)

$Count = IniRead ("Character.ini", "Counter", "count", "0" )

$QuestA = IniRead ("QuestIni.", "QuestA",$Count,"error")

$Questlabel = GUICtrlCreateLabel ($QuestA,10,10,500, 400)

GuiSetState(@SW_SHOW)

#endregion

#region - Combat GUI Create

$CombatGUI = GUICreate ("Combat", $width, $Height)

$ButtonAttack = GUICtrlCreateButton ("Attack.", 100,500,70,20)

GuiSetState(@SW_HIDE)

#endregion

#region - Character Setup GUI Create

$CharactersetupGUI = GUICreate ("Character Setup", $width, $Height)

GuiSetState(@SW_HIDE)

#endregion

#Region - GUI SelectLoop

While 1

$msg = GUIGetMsg()

Select

Case $msg = -3 ;$GUI_EVENT_CLOSE

ExitLoop

Case $msg = $Newgameitem

GUISetState(@SW_HIDE,$FrontGUI)

GUISetState(@SW_SHOW,$CharactersetupGUI)

GUISetState(@SW_HIDE,$CombatGUI)

Case $msg = $exititem

ExitLoop

Case $msg = $ButtonA

$Newcount = IniRead ("Character.ini", "Counter", "count", "0" ) + 1

Iniwrite ( "Character.ini", "Counter", "count", $Newcount )

$Count = IniRead ("Character.ini", "Counter", "count", "0" )

$QuestA = IniRead ("QuestIni.", "QuestA",$Count,"error")

$Questlabel = GUICtrlCreateLabel ($QuestA,10,10,500, 400)

Case $msg = $ButtonB

$Newcount = IniRead ("Character.ini", "Counter", "count", "0" ) + 1

Iniwrite ( "Character.ini", "Counter", "count", $Newcount )

$Count = IniRead ("Character.ini", "Counter", "count", "0" )

$QuestB = IniRead ("QuestIni.", "QuestB",$Count,"error")

$Questlabel = GUICtrlCreateLabel ($QuestB,10,10,500, 400)

Case $msg = $ButtonC

$Newcount = IniRead ("Character.ini", "Counter", "count", "0" ) + 1

Iniwrite ( "Character.ini", "Counter", "count", $Newcount )

$Count = IniRead ("Character.ini", "Counter", "count", "0" )

$QuestA = IniRead ("QuestIni.", "QuestC",$Count,"error")

$Questlabel = GUICtrlCreateLabel ($QuestA,10,10,500, 400)

EndSelect

WEnd

#EndRegion

#region - Functions

Func _A()

If $Questlabel = "combat" then

GUISetState(@SW_HIDE,$FrontGUI)

GUISetState(@SW_HIDE,$CharactersetupGUI)

GUISetState(@SW_SHOW,$CombatGUI)

Else GUISetState(@SW_SHOW,$FrontGUI)

GUISetState(@SW_HIDE,$CharactersetupGUI)

GUISetState(@SW_HIDE,$CombatGUI)

EndIf

EndFunc

#endregion

Here is the INI file named Character.ini

[character]

maxlife=20

life=10

def=9

tohit=8

dam=7

[Counter]

count=0

Here is the INI file named Quest.ini.

[QuestA]

0=Welcome to my RPG. Choose a button. Either button A,B or C and see what the result is.

1=a1

2=a2

3=combat

4=a4

5=a5

6=a6

7=a7

8=a8

9=a9

10=a10

11=a11

12=a12

13=a13

14=a14

15=a15

16=a16

[QuestB]

1=b1

2=b2

3=combat

4=b4

5=b5

6=b6

7=b7

8=b8

9=b9

10=b10

11=b11

12=b12

13=b13

14=b14

15=b15

16=b16

[QuestC]

1=c1

2=c2

3=combat

4=c4

5=c5

6=c6

7=c7

8=c8

9=c9

10=c10

11=c11

12=c12

13=c13

14=c14

15=c15

16=c16

The problem is that The Gui label reads (error) and not (Welcome to my RPG. Choose a button. Either button A,B or C and see what the result is.) I want it to read that at the start of the program( IF the $Count = 0) and then to read the other lines in the Quest Ini file as the buttons are pushed. The line it is to read depends on the value of $Count = IniRead ("Character.ini", "Counter", "count", "0" ) and what button is push. So if the 3rd button push is the B button then I want the label to read b3 like it is wrote in the Ini file Quest under the section QuestB, key 3($Count would equal 3 becuase of the Ini write.). So ever time a button is pushed I want the label to read different. That is the 1st problem I have. The 2nd problem is that I want the GUI named combat to come up and the first GUI to hide when the $Questlabel equals combat from the Quest Ini file. I want to use a key word in the Quest Ini(Using the label) to change the Gui that it shows to the Combat Gui.

Please help. I been rewriting this script again and again and I seem to be getting nowhere with it.

.

Link to comment
Share on other sites

Search for "QuestIni." and replace with "Quest.ini"

Create all your labels at the very beginning. Then use the function GuiCtrlSetData to change the label text.

Edit: As for your other problems, I don't know what to tell you.

Edited by CyberSlug
Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
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...