I'm not a skillful programmer by any means, but everyone's got to start somewhere. I've been trying to make a (very) basic maze-type in ruby, but I'm having difficulty with the while loop not exiting.
Room layout is an upside down t:
5 2 103 4
Going north twice from the center should change @loc to 5, say "End", and exit the loop:
elsif @loc == 2
@loc = 5
puts "End"
But it returns to the beginning of the while loop, stranding the player.
EDIT: there's some confusion about the code, so I'm removing the block and pointing you to http://pastebin.com/EFWVBAhn
cmd.go_northyou're accessing the@locfield ofcmd, not of whatever your maze class is. But we can't tell until we see the code.@loc's value isn't changing? Try checking the value of that variable at the beggining of the statement with aputsor something.@locis never5. But you haven't posted the code where@locchanges, so it's hard to say what the problem is.