Triggering event

Non-platform specific questions.

Triggering event

Postby lverona » Sat May 09, 2015 7:59 am

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?
lverona
 
Posts: 221
Joined: Tue Apr 24, 2012 11:54 am
Score: 1 Give a positive score

Re: Triggering event

Postby koala » Sat May 09, 2015 9:21 am

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?
Phascolarctos cinereus
YouTube: Marko Radivojevic
Google+: Marko Radivojevic
User avatar
koala
 
Posts: 301
Joined: Thu Mar 26, 2015 7:03 pm
Location: Serbia
Score: 30 Give a positive score

Re: Triggering event

Postby lcl » Sat May 09, 2015 10:18 am

Or maybe it would be easier to functionalize that code and then call the function whenever you need to.
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: Triggering event

Postby lverona » Sat May 09, 2015 5:02 pm

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.
lverona
 
Posts: 221
Joined: Tue Apr 24, 2012 11:54 am
Score: 1 Give a positive score

Re: Triggering event

Postby lverona » Sat May 09, 2015 5:02 pm

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?
lverona
 
Posts: 221
Joined: Tue Apr 24, 2012 11:54 am
Score: 1 Give a positive score

Re: Triggering event

Postby koala » Sat May 09, 2015 6:49 pm

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;
Phascolarctos cinereus
YouTube: Marko Radivojevic
Google+: Marko Radivojevic
User avatar
koala
 
Posts: 301
Joined: Thu Mar 26, 2015 7:03 pm
Location: Serbia
Score: 30 Give a positive score

Re: Triggering event

Postby lverona » Sun May 10, 2015 9:29 am

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?
lverona
 
Posts: 221
Joined: Tue Apr 24, 2012 11:54 am
Score: 1 Give a positive score

Re: Triggering event

Postby koala » Sun May 10, 2015 11:38 am

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.
Phascolarctos cinereus
YouTube: Marko Radivojevic
Google+: Marko Radivojevic
User avatar
koala
 
Posts: 301
Joined: Thu Mar 26, 2015 7:03 pm
Location: Serbia
Score: 30 Give a positive score

Re: Triggering event

Postby lcl » Sun May 10, 2015 12:05 pm

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.
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: Triggering event

Postby bat78 » Tue Jul 28, 2015 11:36 pm

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.
The future of "Game-Editor" here
User avatar
bat78
 
Posts: 816
Joined: Sun Dec 14, 2008 9:13 pm
Location: Bulgaria, Sofia
Score: 88 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron