I just realized that the ButtonComponent does not have an activate() function. A LockComponent doesn't have one either. That means we cannot programmatically have these components activate. However, a lever does have one, toggle().
Does anyone know how I can get these to activate? I tried manually adding a controller since these don't have one and that didn't do anything. You can call activate on the controller but does not make the button activate. I also experimented with forcing the "press" animation. That didn't do anything either.
UPDATE:
Did some more testing on this. The problem boils down to that I do not know how to "fire" a hook via script. Specifically a "click" of a button. I can work around this problem but I would like to know if its possible. Seems that only the player can make a "Clickable" event happen. Even firing the "activate" hook via script would be closer and I don't know how to do that. I know activate is called somehow after onClick fires.
Can click or activate hooks be called via script?
Can click or activate hooks be called via script?
Last edited by MrChoke on Wed Nov 12, 2014 5:03 pm, edited 1 time in total.
Re: Can clickng a button be called via script?
All activating a button does is send out a signal to its Connectors, same with a lock. There is no need to activate a button because you could just activate the things the button would yourself. The only reason the lever can be toggled is because it can be either up or down, which makes a slight difference in the game world.
Re: Can clickng a button be called via script?
Yes, I agree I can call whatever the onActivate() is doing directly. The reason why I wanted the button's activate() though is to get a monster to do it. I know the Trickster can do it. Of course he has a bunch of animations to show what he does. But part of what he does is press the button or use the lock. This has the same visuals and sound that the player would get if he does it. And the onActivate() hooks fire as well. If I want to have another monster do it, I'd have to setup all of the animations for him. But couldn't I call something on the button or lock to at least let it do the same thing it does for the player? That is what I am looking for.sps999 wrote:All activating a button does is send out a signal to its Connectors, same with a lock. There is no need to activate a button because you could just activate the things the button would yourself. The only reason the lever can be toggled is because it can be either up or down, which makes a slight difference in the game world.
Re: Can clickng a button be called via script?
If you can't figure out anything else, you can play the animation and sound along with doing whatever it's meant to do when you play the animation on the monster's side.
If you can't get anything else working, this should be functional. 
Code: Select all
wall_button_1.animation:play("press");
wall_button_1:playSound("button");

Re: Can clickng a button be called via script?
Yes those work, thanks. The sound is actually called "button", not "press" but it works. Neither triggers the activate hook though. But it closer.jxjxjf wrote:If you can't figure out anything else, you can play the animation and sound along with doing whatever it's meant to do when you play the animation on the monster's side.
If you can't get anything else working, this should be functional.Code: Select all
wall_button_1.animation:play("press"); wall_button_1:playSound("button");
Re: Can click or activate hooks be called via script?
Bump, because I changed the subject instead of writing a new post.