Few questions,spaces,key binding,reading settings from file.

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
silent
Posts: 44
Joined: 28 Oct 2011 14:40

Few questions,spaces,key binding,reading settings from file.

#1 Post by silent » 02 Jan 2012 09:47

Hai,i wanna make some game with arrows/or custom settings controls but i dont know how to bind keys for program
I thought about making it like that

Code: Select all

if %key% ==W goto TURNLEFT

But i need to write that W to turn left,i want just to press it. (also,whats a code to make it automatically turning left after using the key,cos i dont want to make 50 :TURNLEFT(1-50) :D

Spaces--
Is there any way to remove tha spaces problem ? When someone has made space using the batch,it automatically crashes.I would also like to make a Auto Admin apply batch file to my samp server,but theres problem with those spaces.
Reading settings from *.txt file--
In the game i want to make default control settings and for this i would use

Code: Select all

:CUSETTINGS
echo Write key with that you want to turn left:

set /p kleft=

if %kleft% ==goto :CUSETTINGSRIGHT

:CUSETTINGSRIGHT
cls
echo Now set key with you want to turn right

set /p kright=

if %kright% ==goto SAVESETTINGS

:SAVESETTINGS
cls
echo Saving your custom settings.

echo %kleft% >> "settings.txt"
echo %kright% > "settings.txt"
echo Done...
ping localhost -n 2>nul
cls
goto :MENU


I dont know how to do it properly,help me :D
Thanks in advance

aGerman
Expert
Posts: 4732
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Few questions,spaces,key binding,reading settings from f

#2 Post by aGerman » 02 Jan 2012 12:46

silent wrote:i wanna make some game

Welcome to the worst language to write a game.


silent wrote:with arrows

No way.


silent wrote:/or custom settings controls but i dont know how to bind keys for program
I thought about making it like that

Code: Select all

if %key% ==W goto TURNLEFT

Write a subroutine and use call :TURNLEFT. GOTO :EOF would let the process return to the point where the subroutine was called.


silent wrote:Spaces--
Is there any way to remove tha spaces problem ? When someone has made space using the batch,it automatically crashes.

Enclose it in quotation marks.

silent wrote:I would also like to make a Auto Admin apply batch file to my samp server,but theres problem with those spaces.

:?


silent wrote:

Code: Select all

if %kleft% ==goto :CUSETTINGSRIGHT

perhaps

Code: Select all

if "%kleft%"=="" goto :CUSETTINGSRIGHT



silent wrote:

Code: Select all

echo %kleft% >> "settings.txt"

perhaps

Code: Select all

>>"settings.txt" echo %kleft%


Regards
aGerman

Post Reply