(solved) func_button scripting problem


(Hell Mariachi) #1

Hi,
I did a search on func_button but couldn’t get my problem to go away.

  1. Can func_button be directly connected to its own script?
    (i.e. scriptname buttonscript)

  2. If so, when the button is pressed, what is the default subroutine name?
    (‘activate’ does not seem to work - I have a dummy ‘wm_announce’ that never gets printed which confirms that this routine is never activated)

I am using the button to toggle a hurt_trigger. Previously I just had the func_button target the hurt_trigger which worked fine but I want to use scripting so that I can add messages and affect some other entities.

Thanks,
HM


(-SSF-Sage) #2

Posting your entities and the script might help… Did you also put the script to yourmapname.script to the maps folder. And do you have script_multiplayer with scriptname game_manager?

//+your scripts

And did you try this:


game_manager
{
spawn
{
wait 200
setstate hurt invisible //targetname of the trigger_hurt
}
}
button //buttons scriptname
{
	spawn
	{
	wait 50
	}
	
	activate
	{
	setstate hurt default
	wait 200
	setstate hurt invisible 
	}	
}

So you make a trigger_hurt and this make it appear and then disappear. You can’t link trigger_x to a func_button afaik, but you can link a target_x.


(kamikazee) #3

No, you can’t do so directly.

You still need to point it to a target_script_trigger in order to call the script.

A func_invisible_user, on the other hand, is supposed to call the activate event routine.


(-SSF-Sage) #4

Ahh right. I used this for func_invisible_user. Well why don’t you change it then? //edit I’m making func_button a func_invisible_user and the other way… :smiley:


(Flippy) #5

Connect the func_button to a target_script_trigger (so the arrow points at the latter).
Give the target_script_trigger the following values (key - value):
scriptname - button
target - pressed

(It should already have a targetname)

Then when you press the func_button, the target_script_trigger will fire the “pressed” event in the “button” scriptblock.

Like so:


button   //scriptblock name
{
    spawn //event
    {
    }

   trigger pressed //don't forget "trigger ..."
   {
       ...
   }
}

(Hell Mariachi) #6

Thanks for all the help.

Conclusions:
a script cannot be directly called by the func_button with a scriptname designation in the func_button entity window

Solutions - tried both and both work.

  1. func_button targets script_trigger, script_trigger targets subroutine that is named in the script_trigger entity window.

or

  1. func_invisible_user has a scriptname designator, that script has an ‘activate’ subroutine. - put script commands in that subroutine

method 2 however doesn’t have the button moving in and out


(-SSF-Sage) #7

…by default.You can ofcourse make the button’s brush (the actual button which does look like the button, not the trigger) to move by scriot.


(-SSF-Sage) #8

Lol I just noticed I put there wrong piece of script. However it doesn’t matter anymore… XD