Jump to content

Recommended Posts

Posted (edited)

I'm trying to make a game in AutoIt (Just for fun and practice) anyway I have a form that asks for username and character name then should write both to an ini file, but it only writes one to the ini file and then exits out of the program.

Any help would be awesome.

(note this is only a portion of my code if you need to see it all I can post it )

Global $fPath = @ScriptDir & "\Data\Path"


Func gamestart()

#Region ### START mm GUI section ### Form=
$mm = GUICreate("MainMenu", 238, 199, 337, 189)
$tName = GUICtrlCreateInput("", 64, 64, 113, 21)
$uName = GUICtrlCreateInput("", 64, 120, 113, 21)
GUICtrlCreateLabel("ToonName", 90, 40, 57, 17)
GUICtrlCreateLabel("UserName", 91, 96, 54, 17)
$Enter = GUICtrlCreateButton("Enter", 90, 151, 57, 41)
GUISetState(@SW_SHOW)
#EndRegion ### END mm GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            GUIDelete($mm)
         Case $Enter
            $iniTName = GUICtrlRead($tName)
            $iniUName = GUICtrlRead($uName)
            MsgBox(1,"test", $iniTName & @LF & $iniUName)
            DirCreate($fPath)
            IniWrite($fPath & "\" & "InFo","Name","ToonName",$iniTName)
            MsgBox(1,"","wrote" & " " & $iniTName);for debugging
            IniWrite(fPath & "\" & "InFo","Name","UserName",$iniUName)
            MsgBox(1,"","wrote" & " " & $iniUName);for debugging
EndFunc

    EndSwitch
WEnd

 

 

Edited by TwistedXion
Posted

Hi @TwistedXion,

I think you've missed to check our forum rules in your way when posting game automation.:sweating:

Programming is "To make it so simple that there are obviously no deficiencies" or "To make it so complicated that there are no obvious deficiencies" by C.A.R. Hoare.

  • Moderators
Posted (edited)

TwistedXion,

Move the EndFunc line to after the WEnd - at the moment you end the function immediately you write the first set of ini elements.

Might I suggest installing the SciTE4AutoIt3 package (look under the "AutoIt Resources" menu) - that way you automatically get a whole slew of utilities to help you code, including Au3Check which would have picked up on this error.

M23

Edit: There is no problem with this thread as the OP has stated that the game is being created and coded in AutoIt, something which we actively encourage.

Edited by Melba23

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:

  Reveal hidden contents

 

Posted

Not sure if that make's any difference.

Programming is "To make it so simple that there are obviously no deficiencies" or "To make it so complicated that there are no obvious deficiencies" by C.A.R. Hoare.

  • Moderators
Posted

KickStarter15,

See my edit above.

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:

  Reveal hidden contents

 

Posted

 

  On 7/17/2017 at 10:20 AM, Melba23 said:

TwistedXion,

Move the EndFunc line to after the WEnd - at the moment you end the function immediately you write the first set of ini elements.

Might I suggest installing the SciTE4AutoIt3 package (look under the "AutoIt Resources" menu) - that way you automatically get a whole slew of utilities to help you code, including Au3Check which would have picked up on this error.

M23

Expand  

Okay, that make's sense.:D

Programming is "To make it so simple that there are obviously no deficiencies" or "To make it so complicated that there are no obvious deficiencies" by C.A.R. Hoare.

Posted
  On 7/17/2017 at 10:20 AM, Melba23 said:

TwistedXion,

Move the EndFunc line to after the WEnd - at the moment you end the function immediately you write the first set of ini elements.

Expand  
1

I had actually picked up on that myself but it still terminates after the first iniwrite  

  • Moderators
Posted

TwistedXion,

So post what you have now.

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:

  Reveal hidden contents

 

Posted

If I need it I can post everything I have so far

but here is everything pertaining to the func and the ini file

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#RequireAdmin

Global $fPath = @ScriptDir & "\Data\Path"
gamestart()

Func gamestart()

#Region ### START mm GUI section ### Form=
$mm = GUICreate("MainMenu", 238, 199, 337, 189)
$tName = GUICtrlCreateInput("", 64, 64, 113, 21)
$uName = GUICtrlCreateInput("", 64, 120, 113, 21)
GUICtrlCreateLabel("ToonName", 90, 40, 57, 17)
GUICtrlCreateLabel("UserName", 91, 96, 54, 17)
$Enter = GUICtrlCreateButton("Enter", 90, 151, 57, 41)
GUISetState(@SW_SHOW)
#EndRegion ### END mm GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            GUIDelete($mm)
         Case $Enter
            $iniTName = GUICtrlRead($tName)
            $iniUName = GUICtrlRead($uName)
            MsgBox(1,"test", $iniTName & @LF & $iniUName)
            DirCreate($fPath)
            IniWrite($fPath & "\" & "InFo","Name","ToonName",$iniTName)
            Sleep(1000)
            MsgBox(1,"","wrote" & " " & $iniTName)
            IniWrite(fPath & "\" & "InFo","Name","UserName",$iniUName)
            Sleep(1000)
            MsgBox(1,"","wrote" & " " & $iniUName)


    EndSwitch
WEnd
EndFunc

 

Posted (edited)

the msg boxes are only for debugging so I could see how far the script was getting and if it was actually getting the input or not, it's getting all the info and displaying it in the msg box it just does not write the 2ed iniwrite to the inifile but it does the 1st one 

Edited by Melba23
Removed quote
  • Moderators
Posted

TwistedXion,

Try adding a leading $ to the path in the second IniWrite. Again a problem that would have been picked up by Au3Check (as it was for me just now)

And when you reply, please use the "Reply to this topic" button at the top of the thread or the "Reply to this topic" editor at the bottom rather than the "Quote" button which just pads the thread unnecessarily.

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:

  Reveal hidden contents

 

  • Moderators
Posted

TwistedXion,

So go and download SciTE4AutoIt3 - it saves a lot of those kind of moments......

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:

  Reveal hidden contents

 

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
  • Recently Browsing   0 members

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