Jump to content

Recommended Posts

Posted

Hello i was checking small program to select number i put a number and if it is the correct the program end.

i changed to this:

#AutoIt3Wrapper_Change2CUI=y

#include <WinAPI.au3>
#NoTrayIcon

Local $nScore = 0
ConsoleWrite("Bienvenido a Omar (The game)" & @CRLF)

While (True)
 Local $nRandom = Random(0, 10, 1)
 ConsoleWrite($nRandom)
 Local $nGuess = _ConsoleInput("Adivina el número: ")
 If @error Then ExitLoop

 If Not (IsInt($nGuess)) Then
  ConsoleWrite("ERROR! No es un número" & @CRLF)
 Else
  If ($nGuess = $nRandom) Then
   ConsoleWrite("¡Acertaste!" & @CRLF)
   $nScore = $nScore + 1
  Else
   ConsoleWrite("¡Fallaste!" & @CRLF)
  EndIf
 EndIf

 ConsoleWrite("Tu puntuación: " & $nScore & @CRLF)
WEnd

Func _ConsoleInput($sPrompt) ;https://www.autoitscript.com/forum/topic/107951-help-with-_winapi_createfile-function-and-raw-mode/?do=findComment&comment=761205
    If Not @Compiled Then Return SetError(1, 0, 0) ; Not compiled

    ConsoleWrite($sPrompt)

    Local $tBuffer = DllStructCreate("char"), $nRead, $sRet = ""
    Local $hFile = _WinAPI_CreateFile("CON", 2, 2)

    While 1
        _WinAPI_ReadFile($hFile, DllStructGetPtr($tBuffer), 1, $nRead)
        If DllStructGetData($tBuffer, 1) = @CR Then ExitLoop
        If $nRead > 0 Then $sRet &= DllStructGetData($tBuffer, 1)
    WEnd

    _WinAPI_CloseHandle($hFile)
    Return $sRet
EndFunc

But when i enter the number, never is saved so all time will show the first sentence.

 

Capture.PNG

Posted
2 hours ago, SoyArcano said:

 If Not (IsInt($nGuess)) Then   ConsoleWrite("ERROR! No es un número" & @CRLF)  Else   If ($nGuess = $nRandom) Then    ConsoleWrite("¡Acertaste!" & @CRLF)    $nScore = $nScore + 1   Else    ConsoleWrite("¡Fallaste!" & @CRLF)   EndIf  EndIf  ConsoleWrite("Tu puntuación: " & $nScore & @CRLF) WEnd

I think you missed the forum rules here. These words used are for gaming "Acertaste!" Eng. Trans. (You hit!), "Fallaste!" Eng. Trans. (You failed!)

2 hours ago, SoyArcano said:

ConsoleWrite("Bienvenido a Omar (The game)" & @CRLF)

Sorry but if this is a game related then might not do any support.:o

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.

  • Jos locked this topic
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

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