Not sure what I am missing here


#1

I have most of this working. The idea is for the player is to choose a room to explore, a random description will popup. Then the description will be locked in for the remainder of the current game. I have the random room working but I can’t seem to lock it in to place. I have placed the code below, hope you’ll can figure out what I am doing wrong. Thank you.

First off the player choose a room.


*choice
-#First door on the left
--*goto l1

So they have made the choice now it goes to


*label l1
*gosub rl1
*comment this checks to see if the room has been seleceted or not.
*rand dlone 1 4
*comment this is after it has returned if the room has not been explored. It will then go to if statement from the random number and choose the description of the room.
*if (dlone=1)
-*goto room1
*elseif (dlone=2)
-*goto room2
*comment It does this up to room4


*label rl1
*if (rl1="a")
-*return
*comment rl1 is set to a at the start. So if it is "a" they have not explored the room.
*elseif (rl1="b")
-*goto room1
*comment so if they have explored the room it will be set b, c, d, or e


*comment if the room has not been explored then this is what it looks like.
*label room2
*set loc "a"
*comment loc is always set to a for the first door on the left.
*set rl1 "c"
*comment this should lock the room in for the description.
*set dl1 "Open"
*comment this shows the door has been opened.
(Here is where the player discovers what is in the room.)
*gosub scare_1
*this is a check that works fine and rather not give the details out on right at the moment.
*page_break Explore further
*goto exploring
*comment this takes you bake to the choices for the rooms.


#2

Did you intentionally leave out the label for room1?
And what exactly is your issue, is it re-randomizing the description everytime or locking it to the same (wrong) one?


#3

Yes I did not post the whole code to save space. I figured you would get the idea, and if not then I would just place an abby so you could see the whole thing if need be. And yes the room description does not lock down, it re-randomizing.


#4

@Lordirish, I can’t tell exactly what is wrong here, but it might have something to do with the fact that you are not performing a *return from the rl1 subroutine when the rl1 variable has some value other than “a”. You’re doing a *goto command to break out of the subroutine, but unless you use a *return command, CS doesn’t know that you’ve broken out of the subroutine. So if at some point you come upon a *return command that wasn’t preceded by a *gosub command, you’d be returned to the line after the *gosub rl1 command, which then proceeds to do the randomization again. I can’t tell from the code provided if this is what’s happening, but I also don’t see anything else that might be causing what you’re seeing.


#5

@eposic
That makes a lot of sense will change it over when I get time and try it out. Thanks for spotting that.


#6

I managed to fix it. All I had to do is move two lines of code.
*label rl1 *if (rl1="a") *return
I moved this to the very end so it would cycle through the rooms then it would go back and set a room if unexplorded. Tested many times seems to work perfect. Thanks for your help all.


#7

After much testing I have discovered that now the first room locks into place everytime. So scraping the code and starting over. I aleast learned how not to do it. This time I will try it with true false and see if I can make it work.


#8

Lol I should have done that from the start. Works very well now to start filling in all the rooms.


#9

I have been at this for six hours, only taking small breaks here on the boards. After looking at the code for chapter one I am half temped to dump the whole thing. I have learned so much from you guys and would like to make the best version possible. Otherwise I will have to put some ugly patches in and chase a lot of bugs I am sure. For now no changes will show. If I do decide to rewrite the whole thing I will leave the older version up untill I have completed the new version. Guess I will sleep on it my eyes are bugging out on me lol to much code.


#10

Quick edit: Changed out all the < code> for < pre> (thanks @eposic, even if you didn’t realize I was looking over your shoulder).

Edit to my edit: I didn’t even realize this was resolved. : p


#11

Hehe, you’re welcome @Reaperoa. :-"