03-14-2012, 03:58 AM
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:
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.
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);
}
{
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);
}
}
{
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.
