Play/Stop record player issues

Hi Guys, Please help with what seems like a simple issue im having with a game. In the game you find a record player. Now when you play and stop the record it responds correctly but when it is already stopped or already playing it does not state "It is already playing" or "It is already stopped" even using flags and "if" commands.

Please see code below :

play sound ("soundbyte here.mp3", false, false)
SetObjectFlagOn (record, "on")
if (GetBoolean(record, "on")) {
msg ("You listen to the recording for a bit. A lovely piece of clasical music.")
}
else {
msg ("It is already playing.")
}

stop sound
SetObjectFlagOff (record, "on")
if (not GetBoolean(record, "on")) {
msg ("You place record back in its sleeve.")
}
else {
msg ("It has already stopped.")
}

Please see in game what happens :

> look at gramaphone
A gramaphone record player in a small wooden cabinet.
It contains a record.

> play record
You listen to the recording for a bit. A lovely piece of clasical music.

> play record
You listen to the recording for a bit. A lovely piece of clasical music.

> stop record
You place record back in its sleeve.

> stop record
You place record back in its sleeve.

What am i forgetting? Please help. Hope you see the issue without me having to send entire game.

Much appreciated.

jaynabonne
Try these instead:

To play:

if (GetBoolean(record, "on")) {
msg ("It is already playing.")
} else {
SetObjectFlagOn (record, "on")
play sound ("soundbyte here.mp3", false, false)
msg ("You listen to the recording for a bit. A lovely piece of clasical music.")
}


To stop:

if (GetBoolean(record, "on")) {
SetObjectFlagOff (record, "on")
stop sound
msg ("You place record back in its sleeve.")
} else {
msg ("It has already stopped.")
}


The way you have the code in yours, you are always setting the flag before you check the flag.

SetObjectFlagOn (record, "on")
if (GetBoolean(record, "on")) {

It will never be anything other than what you set it to. You need to check before setting, to see what it already is.

HegemonKhan
oops, sorry, Jay, I just realized that the 'on' (in the SetObjectFlagOff) is its boolean attribute name (as the 'GetObjectFlagOff' itself will change the boolean value). I deleted my post. sorry about that. I got confused.

jaynabonne
I got a little confused myself when I was first doing it. Perhaps an attribute like "playing" would be clearer. :)

Thanks alot guys for all your help. I will try it out.

Yes it works. Thanks a lot. For now that's it - but there will be more...

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums