From: Harry Kakueki Date: 2007-11-06T14:18:09+09:00 Subject: Re: Affecting variables inside a while loop that are initialised outside its scope On 11/6/07, Rawn wrote: > > I'd like to change the value of Victory to 1 when "search" is typed > into the prompt, thus causing the while loop to end, ending the > script. This may be the completly wrong way to go about doing this but > atleast tell me how to do what I want before you school me in the > proper way of doing things ; ) > thanks in advance > > > # Not tested but first try these modifications. inventory = Array.new discovered = Array.new victory = 0 # small v. Ruby sees Victory as constant. puts "You are in a dim room. You can just make out a door by the light shining through the cracks." while victory < 1 inputcommand = gets.chomp! if inputcommand == "search" # use == not = victory += 1 # or victory = victory + 1 end end Harry -- A Look into Japanese Ruby List in English http://www.kakueki.com/ruby/list.html