The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 906 - File: showthread.php PHP 7.2.24-0ubuntu0.18.04.17 (Linux)
File Line Function
/showthread.php 906 errorHandler->error



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
Conditional function activation?
Damascus Offline
Senior Member

Posts: 646
Threads: 118
Joined: Mar 2012
Reputation: 29
#1
Conditional function activation?

I'm having a lot of trouble keeping functions from activating until a certain condition is fulfilled. My first example is trying to activate a grunt after the player goes down a hallway, picks up a hammer, and comes back down the same hallway. I've tried to use an "if" statement, but every time I try, the function activates the first time you go down the hallway, and fails to work properly since you're not holding the right item. Then when you come back out, it doesn't reactivate a second time.

Here are the two scripts I've tried:
Spoiler below!
void CollideActivateLiveGrunt(string &in asParent, string &in asChild, int alState)
{
if(HasItem("stone_hammer_1"))
{
SetEntityActive("servant_grunt_1", true);
}
}

void OnStart()
{
AddEntityCollideCallback("Player", "PlayerFake", "CollideActivateLiveGrunt", true, 1);
}

Spoiler below!
void CollideActivateLiveGrunt(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("servant_grunt_1", true);
}

void OnStart()
{
if(HasItem("stone_hammer_1"))
{
AddEntityCollideCallback("Player", "PlayerFake", "CollideActivateLiveGrunt", true, 1);
}
}

Another problem is having a lever display two different messages depending on whether you've used an item on it yet or not. But, as soon as you touch it, it wastes both functions before you use the item on it and won't display the second message after you use the item.

(This post was last modified: 03-14-2012, 05:06 AM by Damascus.)
03-14-2012, 03:58 AM
Find


Messages In This Thread
Conditional function activation? - by Damascus - 03-14-2012, 03:58 AM



Users browsing this thread: 1 Guest(s)