Taking an object for the first time vs taking after dropping

psymann
31 Mar 2013, 20:51Hello all,
I'm continuing my attempt to make my first adventure...
My current hurdle is to do with taking things.
I have a picture that starts off life on the wall.
The first time I take it, I want to have a message saying "You rip the picture off the wall."
But then I might want to drop it and pick it up again later, in which case I want to have a message just saying "You pick up the picture."
I tried going to the Inventory tab, and using Run Script, and using a flag, saying if the flag was set to "Taken" then I just pick it up, but if not, then I rip it off the wall and then set the flag to Taken. But it doesn't quite work
The code-ificated version of it looks like this:
if (GetBoolean(Picture, "Taken")) {
msg ("You pick up the picture.")
AddToInventory (Picture)
}
else {
msg ("You rip the picture off the wall.")
AddToInventory (Picture)
SetObjectFlagOn (Picture, "Taken")
}
When I test it out, and do "take picture", it seems to run through the IF statement twice.
So the first time I 'take picture', it does:
"You rip the picture off the wall."
"You pick up the picture."
And then if I drop it, and take it again, it now says:
"You pick up the picture."
"You pick up the picture."
So it's clearly doing something right since it's realised I don't want to rip it twice, but for some reason it's doing the taking bit twice each time.
Any idea why?
Thanks,
psymann
I'm continuing my attempt to make my first adventure...
My current hurdle is to do with taking things.
I have a picture that starts off life on the wall.
The first time I take it, I want to have a message saying "You rip the picture off the wall."
But then I might want to drop it and pick it up again later, in which case I want to have a message just saying "You pick up the picture."
I tried going to the Inventory tab, and using Run Script, and using a flag, saying if the flag was set to "Taken" then I just pick it up, but if not, then I rip it off the wall and then set the flag to Taken. But it doesn't quite work

The code-ificated version of it looks like this:
if (GetBoolean(Picture, "Taken")) {
msg ("You pick up the picture.")
AddToInventory (Picture)
}
else {
msg ("You rip the picture off the wall.")
AddToInventory (Picture)
SetObjectFlagOn (Picture, "Taken")
}
When I test it out, and do "take picture", it seems to run through the IF statement twice.
So the first time I 'take picture', it does:
"You rip the picture off the wall."
"You pick up the picture."
And then if I drop it, and take it again, it now says:
"You pick up the picture."
"You pick up the picture."
So it's clearly doing something right since it's realised I don't want to rip it twice, but for some reason it's doing the taking bit twice each time.
Any idea why?
Thanks,
psymann

jaynabonne
31 Mar 2013, 21:06It would be helpful if you could post your aslx file. It might be something else (e.g. a comma in the name).

psymann
31 Mar 2013, 21:27Ah, you've helped me solve it in a way I didn't expect.
I could see that I could look at the code for a particular bit of the program, but until you referred to posting a whole file, hadn't realised that there was a way to see the whole thing in code all at once.
And when I did that, I discovered a strange thing - I had erroneously added the code originally as an "After take" event, and then realised my mistake and changed to put it as a script on the "Take" event - doing all this on normal view. When I chose the "Take" event script, it removed the "After take" part from the screen so I assumed it had been removed (or commented-out at least) from the code.
As it turned out, although the "After take" bit wasn't showing on normal view, it was still in the code, so my action of "Take" which was doing the right thing was followed by my original non-working-properly "After take" event which I couldn't see was there until I viewed the code.
Meh, what a confusion!
Anyway, this one works now, thanks for the help since without the prod in the ribs at the right angle that would have driven me mad for a good long while
Thanks muchly!
psymann
I could see that I could look at the code for a particular bit of the program, but until you referred to posting a whole file, hadn't realised that there was a way to see the whole thing in code all at once.
And when I did that, I discovered a strange thing - I had erroneously added the code originally as an "After take" event, and then realised my mistake and changed to put it as a script on the "Take" event - doing all this on normal view. When I chose the "Take" event script, it removed the "After take" part from the screen so I assumed it had been removed (or commented-out at least) from the code.
As it turned out, although the "After take" bit wasn't showing on normal view, it was still in the code, so my action of "Take" which was doing the right thing was followed by my original non-working-properly "After take" event which I couldn't see was there until I viewed the code.
Meh, what a confusion!
Anyway, this one works now, thanks for the help since without the prod in the ribs at the right angle that would have driven me mad for a good long while

Thanks muchly!
psymann

jaynabonne
31 Mar 2013, 21:31Glad it worked out. 

sonic102
31 Mar 2013, 21:42I knew it was that! That happened to me, like, a hundred times.