for example, I have a menu with about 4 different options to "go to" another menu. i want to be able to jump to each menu regardless of where it is in the code.
...
best way to for me to explain this is to show an example and hope someone recognizes something like it.
MainPage
puts '1. Inventory'
puts '2. Stats'
puts '3. Map'
variable1 = gets.chomp
if variable1 = '1'
goto InvPage
else
if variable1 = '2'
goto StatPage
else
if variable1 = '3'
goto MapPage
else
puts "Please make a different selection.'
#### ALSO I NEED TO KNOW WHAT GOES (presumably) HERE IN CASE OF THIS PROBLEM. PROBLEM BEING ENTERING AN INVALID CHOICE.
end
end
end
The key things to note here being "goto" being a command i made up telling the program to go to the chosen location and continuing the script. Inv/Stat/MapPage being the marker to "goto"
also, as mentioned above in the code, i have a similar situation causing me grief right now
a1 = ' ' puts 'Now then, how much would you like to start with?' puts '1. $50,000' puts '2. $80,000' puts '3. $120,000' puts '4. $200,000' a1 = gets.chomp if a1 == '1' cash = 50000 else if a1 == '2' cash = 80000 else if a1 == '3' cash = 120000 else if a1 == '4' cash = 200000 else puts 'Sorry, could you please re enter your decision?' end end end end
right now, if i type anything other than 1,2,3, or 4 it says "Sorry, could you please re enter your decision?" and continues the script normally, causing you to start the game broke. Which is a big issue.
i believe if i can get this "goto" thing to work, i could simply put a "page" or "paragraph" number/name above each paragraph, and put "goto page##" underneath "puts 'Sorry, could you please re enter your decision?'"
lastly, im very sorry if I'm spamming this forum, not my intentions, if it would be prefered i have no problem opening a single thread and continually post my questions in there. all i really have is you guys for support, or other forums, i have no one around me who knows any sort of coding, and i find it very hard to sit down and read a guide and remember anything i just read, i need to do it hands on and take my own notes in order to retain any knowledge.

New Topic/Question
Reply




MultiQuote




|