Frictional Games Forum (read-only)

Full Version: Making Puzzle Items Consumable
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I want to make a puzzle item consumable, meaning that if it is clicked on in the inventory it immediately causes an effect (much like a can of oil or health potion, though the effect would be done through script). However I cannot find a callback that would trigger when the item double clicked (so that the player holds it out in front of him). My idea was that I would use script to remove the item when it was clicked in this manner, so that it would appear to have been drunk.
You might be able to use this: void SetEntityCallbackFunc(string& asName, string& asCallback)

Callback syntax: void MyFunc(string &in asEntity, string &in type)
Type depends on entity type and includes: “OnPickup”, “Break”, “OnIgnite”, etc

Perhaps OnUse would work? Other than that you might have to tinker in the model editor.
nope, doesn't work. Sad I have no idea how to use the model editor at all, but either way I need it to be able to run code.
Try it with a health potion and see if code works, model editor part is easier.
The problem with a health potion is that I don't want the number next to the icon in the menu. I got it to work so that the script runs as soon as the object is picked up, so that might have to do.
maybe try looping GetEntityExists("namehere") if it doesn't exist, assume it has been consumed.
for example
Code:
void OnPickup(string &in asEntity , string &in asType)
{
if(asType=="OnPickup"){ // Player has picked up the potion
AddTimer("EntityExists" , 0.1f , "DoesEntityExist");
}
}

void DoesEntityExist(string &in asTimer)
{
if (GetEntityExists("")){
// player hasn't drank the potion
AddTimer "loop" , 0.1f , "DoesEntityExist");
}

else {
// player has drank it! - remove the timers and end the loop! do what you want to do here!
}
}