I am creating a puzzle where you have to use an item on a tree in order to get something. I have it set up with the whole active inventory thing but what do I do to make it so you can do it only once. I know it has something to do with Game.DoOnlyOnce but I'm not sure what I should put in the (). If I put cTree2_UseInv() wouldn't it make it so I couldn't do anything else with the tree? I'm a little confused here.
cTree2_UseInv() I believe is the correct approach.
When you say:
Quote from: metalmario991 on Sun 09/08/2015 23:14:22
If I put cTree2_UseInv() wouldn't it make it so I couldn't do anything else with the tree?
This makes me a little confused if I'm honest. If you had a function:
function cTree2_UseInv()
{
if(player.ActiveInventory == iMyInvItem)
{
// do stuff here
}
}
This would allow you to do other things to the tree as well, so the answer to your question (in a way) is no.
You might have meant something else, so just in case, here are some things you can do:
-----
Remove the item after use to stop a player using the item on the tree multiple times:
function cTree2_UseInv()
{
if(player.ActiveInventory == iMyInvItem)
{
// do stuff
player.LoseInventory(iMyInvItem);
}
}
-----
Perhaps you meant using more than one item?
function cTree2_UseInv()
{
if(player.ActiveInventory == iMyInvItem)
{
// do stuff
}
if(player.ActiveInventory == iMyOtherInvItem)
{
// do other stuff for other item
}
}
-----
Perhaps you mean you could do other interactions?
Well for that you would simply add more events like cTree2_Look etc via the character properties window.
I hope that helps!
You just have to put a unique string in there.
if (Game.DoOnceOnly("use thing on tree"))
If it's only a specific item you should use only once, it would be something like:
cTree2_UseInv() {
if (player.ActiveInventory == iAxe){
if (Game.DoOnceOnly("use axe on tree")) CutDownTree;
else player.Say("I already did that");
}
else etc.
}