Help needed on Call Statement with Goto labels
Wednesday, April 22, 2015 - 23:47
I need to use lots of call statements now to make everything all come together and interact in the game but because
I don't know the correct batch syntax to code the goto routine to use an environment variable to remember the last
place in the code where the call statement was being made from. I can't get the game code parts to interact.
Does anyone know the batch code syntax to allow me to return back again to the correct place in the code where
I made the call statement from? If I can get this right, then I can get the game to call up the codeblocks I need
or the game uses regularly without me having to make unecessary multiple copies of it throughout
all the code.
I think the best answer can be found here:
http://ss64.com/nt/call.html
If you would prefer to stick with goto that page was here:
http://ss64.com/nt/goto.html
I am not very experienced with the command line, but I think this looks like a cool website.
Ok I've read the information that was given: I'll try Goto :EOF, put that at the end of my change weapons menu code, it should just return me back to the last known game location after exiting the menu.
Tozan - You store the return goto name as a variable - then use goto %VARNAME% to return to that location.
I gave you very similar examples in our previous conversation - but I know how you like things done for you - so I created another example called returnEg.bat and put it into the same dropbox location as before.
Code will loop until the random number generates the number 4 as that will go to the 'finalbattle' room - and exits.
The other 'rooms' return back to the random number picker (using the variable) - although 1 room I made go to a different room which then returned to the number picker.
This example shows variable room selection (via a random number generator/loop) and dynamic returning via a goto variable.
UPDATE:
DID you look at the funcEg.bat example I made for you previously?
That also provides an example of how to do it - it shows exactly how to set a variable and use it for a goto.
If you understand the purpose of funcEg.bat - you can make some pretty useful reusable (function like) code.
Between returnEg.bat and funcEg.bat you have multiple working examples to play with.
When it comes to changing the weapons in the game, the user moves non linear throughout all the screens in the game from region to region. its not done at random so if I'm in Trollmountain23c. and call up Change weapons menu up from that location, the game should just pop me back into trollmountain23c after finishing using with the Change weapons menu, the same if I'm in swamp05 or Dark Forest6, or any other game area location. I don't want the game to just pop me back into a random area but to return me back instead to the same area or whatever game region or screeen area I happen to be in at the time.
So I think for batch code I have to use goto :EOF to make the game return me back into my last known location
Please study those examples. They really really do exactly what you have just descibed.
The examples show this concept:
:trollmountainCode
myVariableName = trollmountainCode
...do some stuff...
goto someOtherSpotInYourCode[Eg your menu]
...
OTHER STUFF
...
:someOtherSpotInYourCode[Eg your menu]
... do some stuff ...
goto %myVariableName% <----- This will return to the top of this post.
--------------------
Both examples (funcEg.bat and returnEg.bat) show how this can be done, each in a different way.
The returnEg.bat shows an example almost identical to what you described. The random number generator is ONLY USED to show you that this is all dynamic - so that it calls different sections in the code - yet returns back to where it started!
UPDATE: Yay, finally worked out how to remove the massively excessive spacing between lines when posting on this forum.
GRAPHICS: This game only maintains the graphics when no other windows are in the way and that is more that just irritating.. SO what should the undead skeleton use for health instead of hearts? i dunno.
Now the hard part is trying to find a name for the game and then it do a title screen logo the pine trees look a little strange. because i didn't know how to get all the sky part out of the tree branches. Unless someone can help me do that so it blends in more to load the pine pic so they can remove all the sky for me.. I may finish the snow region or just shelf this project for a while.