you need to rearrange it.. you don't need flags depending on what you do.. but I can use it as an example of flags later.
This is what you want :
// you should always use the definitions
#include "defines.txt"
#define myflag f50
if(said("take", "object")) // only do this if the player has said "take object"
{
if(has("object")) // check if he's taken it already
{
print("you already did that.");
}
else // if he hasn't...
{
if(posn(o0,.........)) // check if he's in the right position
{
// he is, put object in inventory, increase score
print("you do this and find a .....");
get("object");
score += 3;
}
else // player not in correct position
{
print("You are not close enough");
}
}
}
Assuming the player will have this item for the rest of the game, this code works hopefully.. you can use this in your game..
What happens if the player drops the object somewhere else and then goes back to where he came. If he tries to pick up the object again, the game will allow him! The reason for this is because it's just checking if he has it in his inventory.. not if he's picked it up before.
However, notice how the get() and has() commands act like a flag? the flag is set if the player has an object and reset if he doesn't. Only two states. So if you wanted to, you could use a flag instead. This flag can stay set, even if he drops the object later on.
// you should always use the definitions
#include "defines.txt"
#define taken_object f50
if(said("take", "object")) // only do this if the player has said "take object"
{
if(isset(taken_object )) // *** check myflag. if myflag is set, then the player has taken object already
{
print("you already did that.");
}
else // if he hasn't...
{
if(posn(o0,.........)) // check if he's in the right position
{
// he is, put object in inventory, increase score
print("you do this and find a .....");
set(taken_object); // *****
get("object");
score += 3;
}
else // player not in correct position
{
print("You are not close enough");
}
}
}
Notice the two places that I marked with *** ? those are the bits that I changed. See how the flag contains the fact that the player has or hasn't got the object?
Commands used:
set(flag number); - sets a flag to 1
reset(flag number); - resets a flag to 0
isset(flag number) - true if flag ==1, false if flag == 0
- Nick