Needing a Bit of OOP Helpage

NOTE: I HATE A LOT OF YOUR ZZT GAMES, SO WATCH OUT!

Moderators: Commodore, Zenith Nadir

Post Reply
Amano Jaku
newcomer
Posts: 3
Joined: Wed Dec 13, 2006 6:05 am

Needing a Bit of OOP Helpage

Post by Amano Jaku »

I've played a lot of ZZT and am trying to make my own game. It's going to involve lots of item-Flags, but I've come up against a snag right from the gate.

There's a door which is supposed to check for a flag (RxK1), which stands for a keycard. If the flag's set, then the door is supposed to open. If not, the door tells him to go find the damn card.

For some reason, the program works backwards. When the flag isn't set, the door opens. When it is set, the door tells you to find the keycard. This confuses me to no end.. I can't seem to figure out why it's working backwards. I've even looked at other programs that use similar situations, but I don't see why mine works the other way around.

Code: Select all

#cycle 1
#end
:touch
#if not RxL1 then nocard
#lock
(text about swiping the card)
(movement and #char stuff)
#unlock
#end
:nocard
(text about needing to get the damn card)
#end
Isn't it a total letdown when you're wiping your butt and the toilet paper stops but your hand doesn't?
User avatar
Commodore
fgsdfs
Posts: 2471
Joined: Wed Mar 12, 2003 5:44 pm
Location: :noitacoL
Contact:

Post by Commodore »

not sure if this would exactly help the problem but the #if command could be better written like this:

#if not RxL1 #nocard

"then" is not necessary and maybe (I don't remember) the # is needed. At least that's the way I do it.

Also make sure you haven't set more than 9 flags. That can really screw things up.
*POW* *CLANK* *PING*
Amano Jaku
newcomer
Posts: 3
Joined: Wed Dec 13, 2006 6:05 am

Post by Amano Jaku »

Hmm. Just tried that, changing it to:

Code: Select all

#if not RxL1 #nocard
but it still does the same. When the flag is NOT set, the door opens, but when the flag IS set, the door stays shut. I don't have more than nine flags 'cus this is the starting map.. this is what frustrates me so much. I've got all this game waiting to be made and I'm stuck at the very beginning.

Thank you for the help, though.
Isn't it a total letdown when you're wiping your butt and the toilet paper stops but your hand doesn't?
Nixon
Ordinery
Posts: 48
Joined: Sat Dec 16, 2006 10:41 am

Post by Nixon »

I tested your code and got rid of stuff you didn't need, it seemed to work fine, I used another object to set and clear the flag. So I dunno what your doing, maybe you misnamed the flag in another object.

Code: Select all

#end
:touch
#if not RxL1 nocard
you do have the card
#end
:nocard
You have NO card
#end

Code: Select all

#end
:touch
#if RxL1 i
#if not RxL1 #set RxL1
Its set
#end
:i
#clear RxL1
Not set
#end
gingermuffins
Posts: 371
Joined: Fri Sep 01, 2006 1:30 am

Post by gingermuffins »

a 2nd # isn't needed in an if statement if you're just calling a label and not issuing a command. Also flags are case insensitive, so RxL1 is the same as rxl1.

Code: Select all

#if not rxl1 nocard
this is kind of useless, but you can fit 8 consecutive flag checks onto one line like this:

Code: Select all

#if a#if b#if c#if d#if e#if f#if g#if h x
bustaballs
1 full minit uv 1 secend mesiges
Posts: 62
Joined: Sat May 20, 2006 11:15 pm
Location: Nadir's mom

Post by bustaballs »

Wait.. what does cycle do again?


Sorry.. I just woke up.
User avatar
Commodore
fgsdfs
Posts: 2471
Joined: Wed Mar 12, 2003 5:44 pm
Location: :noitacoL
Contact:

Post by Commodore »

changes the speed an object executes commands, higher number = slower object.
*POW* *CLANK* *PING*
User avatar
Dr. Dos
OH YES! USE VINE WHIP! <3
Posts: 1772
Joined: Tue Mar 11, 2003 12:00 am
Location: Washington

Post by Dr. Dos »

Changes speed between Spin cycle and Rinse cycle.
Visit the Museum of ZZT
Follow Worlds of ZZT on Twitter

Apologies for the old post you may have just read.
bustaballs
1 full minit uv 1 secend mesiges
Posts: 62
Joined: Sat May 20, 2006 11:15 pm
Location: Nadir's mom

Post by bustaballs »

I was looking through some of my old code today and I noticed that I used a alot of #lock and #unlock and I don't remember why. They were pretty much stand-alone objects that didn't really have any commands going to or coming from other objects. I remember I had to use the commands to get the things to work like I wanted them to. Anyone know why?
User avatar
Commodore
fgsdfs
Posts: 2471
Joined: Wed Mar 12, 2003 5:44 pm
Location: :noitacoL
Contact:

Post by Commodore »

prevent an errant :touch message perhaps? It's good practice to do that though. It's not a problem unless you really get desperate for the extra memory.
*POW* *CLANK* *PING*
Amano Jaku
newcomer
Posts: 3
Joined: Wed Dec 13, 2006 6:05 am

Post by Amano Jaku »

I added #lock/#unlock commands because the door is one of those nifty "swinging" animated doors, and I didn't want a mis-touch to cause it to swing further out into the hallway and break off the wall.

And it turns out that I had screwed up my coding in a totally different object. I'd made one designed to Set or Clear the flag needed for that door so I could test wether the door worked right or not. But I'd forgotten to put an #end before the :touch part. So every time I started the game, it would automatically Set the RxL1 flag.

Thanks for your help, everyone. =D
Isn't it a total letdown when you're wiping your butt and the toilet paper stops but your hand doesn't?
User avatar
Commodore
fgsdfs
Posts: 2471
Joined: Wed Mar 12, 2003 5:44 pm
Location: :noitacoL
Contact:

Post by Commodore »

(insert appropriate sherlock holmes quote here)
*POW* *CLANK* *PING*
Post Reply