Background info for the problem: I am writing a text adventure game where the player has multiple paths to choose at each intersection/ problem.

Problem: I am attempting to use a variable from another path, which may not of been called upon. Is there anyway to call this variable before or skip a line of code?

This is the section of my code I am talking about

   38     input "What do you do? 'A' to continue, 'B' to run away" , BAB$
   39     if BAB$ == "A" then
   40       if BCP$ == "B" then
   41         print "The hunters see you return"
   42         print "When they ask if you found the prisoner, you respond by saying that you havent seen him"
   43         print "The hunters decide that this venture isnt worth it, and decide to leave, taking you with them"
   44         wait 30
   45         print "You escape shortly after the rest of the group leaves the area"
   46         print "You are now a free man"
   47         wait 200
   48         clear
   49         cls
   50         goto 100
   51       else
   52         goto 55
   53       endif

Have any questions about my wording? Just ask!

有帮助吗?

解决方案

The simplest answer to this question is to just initialise the variable at the start of the program:

BAB$ = ""
BCP$ = ""

That way, when you hit line 40, either BCP$ will have a value of "" or have a value of something else.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top