Page 1 of 1

Triggering event

PostPosted: Sat May 09, 2015 7:59 am
by lverona
Let's say I have a certain script triggered by pressing a button. If I want the same thing to happen on a click, is there a way to just "point" to that script or "simulate a button press" without taking the script and duplicating it?

Re: Triggering event

PostPosted: Sat May 09, 2015 9:21 am
by koala
lverona wrote:Let's say I have a certain script triggered by pressing a button. If I want the same thing to happen on a click, is there a way to just "point" to that script or "simulate a button press" without taking the script and duplicating it?
Could you simulate pressing a button when that click happens?

Re: Triggering event

PostPosted: Sat May 09, 2015 10:18 am
by lcl
Or maybe it would be easier to functionalize that code and then call the function whenever you need to.

Re: Triggering event

PostPosted: Sat May 09, 2015 5:02 pm
by lverona
lcl wrote:Or maybe it would be easier to functionalize that code and then call the function whenever you need to.



Oh, I wish. But gE has a bug in that in the Global code it does not see actor variables, unless you call the function with these parameters commented before a function and this is simply not reliable if the function does a lot of things.

Re: Triggering event

PostPosted: Sat May 09, 2015 5:02 pm
by lverona
koala wrote:
lverona wrote:Let's say I have a certain script triggered by pressing a button. If I want the same thing to happen on a click, is there a way to just "point" to that script or "simulate a button press" without taking the script and duplicating it?
Could you simulate pressing a button when that click happens?


How?

Re: Triggering event

PostPosted: Sat May 09, 2015 6:49 pm
by koala
It is really easier to do what lcl suggested. Can you access actors variables something like this:
Code: Select all
char name[30];

getclone(name)->actor_variable;

Re: Triggering event

PostPosted: Sun May 10, 2015 9:29 am
by lverona
I don't see how it's "easier". It will not help me. When I press a button, I start a script that is long and does many things.

Is there a way to programaticaly "press" a button?

Re: Triggering event

PostPosted: Sun May 10, 2015 11:38 am
by koala
lverona wrote:Is there a way to programaticaly "press" a button?
I don't know about that.
You could make third actor that will activate that script when created. That actor will be created either when you press the button, or click happens.

Re: Triggering event

PostPosted: Sun May 10, 2015 12:05 pm
by lcl
Or you could place the code in an activation event and then caal SendActivationEvent() whenever you want the code to activate.

But really koala's suggestion of using getclone() to fix the problem in Global Code is what I'd do.

Re: Triggering event

PostPosted: Tue Jul 28, 2015 11:36 pm
by bat78
You can not programmatically "simulate" Mouse Button Down/Up event, and there is no reasonable way to do so.

You can "point to a script" using the Activation Events.