Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Making Puzzle Items Consumable
Homicide13 Offline
Senior Member

Posts: 323
Threads: 41
Joined: Nov 2010
Reputation: 14
#1
Making Puzzle Items Consumable

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.

08-15-2011, 02:09 AM
Find
MrBigzy Offline
Senior Member

Posts: 616
Threads: 18
Joined: Mar 2011
Reputation: 8
#2
RE: Making Puzzle Items Consumable

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.
08-15-2011, 03:40 AM
Find
Homicide13 Offline
Senior Member

Posts: 323
Threads: 41
Joined: Nov 2010
Reputation: 14
#3
RE: Making Puzzle Items Consumable

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.

(This post was last modified: 08-15-2011, 05:32 AM by Homicide13.)
08-15-2011, 05:31 AM
Find
Tanshaydar Offline
From Beyond

Posts: 3,085
Threads: 17
Joined: Mar 2009
Reputation: 67
#4
RE: Making Puzzle Items Consumable

Try it with a health potion and see if code works, model editor part is easier.

08-15-2011, 09:04 AM
Website Find
Homicide13 Offline
Senior Member

Posts: 323
Threads: 41
Joined: Nov 2010
Reputation: 14
#5
RE: Making Puzzle Items Consumable

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.

08-15-2011, 04:17 PM
Find
DRedshot Offline
Senior Member

Posts: 374
Threads: 23
Joined: Jun 2011
Reputation: 11
#6
RE: Making Puzzle Items Consumable

maybe try looping GetEntityExists("namehere") if it doesn't exist, assume it has been consumed.
for example
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!
}
}

08-15-2011, 04:40 PM
Find




Users browsing this thread: 1 Guest(s)