Hy!
In my game I have a lump of dirt that the player can interact with. The first time the player interacts with the dirt he gets an item. Next time he tries to interact he doesn't get anything.
Now I could use for example
if (cEgo.HasInventory(aItem)==false)
{
cEgo.AddInventory(aInventoryItem);
}
The problem is that the player disposes of the item later in the game and he could get a new item from the dirt when he does. How can I prevent that?
Search for Game.DoOnceOnly in the manual or use a boolean variable.
I'll try...
EDIT: I'm looking at it and I don't really understand how this script works. I'll try some more but I may have to check back with you on this one.
So I found this in the manual:
if (Game.DoOnceOnly("open cupboard")) {
GiveScore(5);
}
How do I rework this to work with my item? I'm guessing something like this:
if (Game.DoOnceOnly("interact with object")) {
cEgo.AddInventory(aItem);
}
But what is the interact with object actually suppose to be? And how do I make the character say something else after he already interacted with the object already?
Parameter in DoOnceOnly is just a unique string of your own choice that is "tagged" to this particular action, or a linked set of actions (if you can only do one of them in game).
if (Game.DoOnceOnly("interact with object"))
cEgo.AddInventory(aItem);
else
cEgo.Say("I can't do this again");
Also: use [ code = ags ], not just [ code ] to post script examples.
EDIT: Never mind... Solved it! Thank you :).
Remove the { at the end of line 3. and the } on line 7.