Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (alibaba, vicknick), 1,492 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
event_type and passing into functions #450984
04/26/15 13:55
04/26/15 13:55
Joined: Apr 2005
Posts: 1,988
Canadian, Eh
DLively Offline OP
Serious User
DLively  Offline OP
Serious User

Joined: Apr 2005
Posts: 1,988
Canadian, Eh
Code:
function dothis(var passinto){
	if (event_type == EVENT_IMPACT){		
		beep();
                wait(passinto);
	}	
}
action elevator_move(){
	my.emask |= ENABLE_IMPACT;
	my.event = dothis(5);
}



Note: The above is merely an example


I would like to pass some variables into my event functions. Can this be done? when i pass into them right now, the event stops.


A8 Pro 8.45.4
YouTube: Create Games For Free
Free Resources: www.CGForFree.com
Re: event_type and passing into functions [Re: DLively] #450985
04/26/15 14:02
04/26/15 14:02
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
MasterQ32 Offline
Expert
MasterQ32  Offline
Expert

Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
No this is not possible. Not directly to be exact.
Event functions get the "my" pointer of the entity which triggered the event.
so to pass your 5 to the event, do this:
Code:
function dothis(var passinto){
	if (event_type == EVENT_IMPACT){		
		beep();
                wait(my.skill80);
	}	
}
action elevator_move(){
	my.emask |= ENABLE_IMPACT;
	my.event = dothis;
	my.skill80 = 5;
}



Visit my site: www.masterq32.de
Re: event_type and passing into functions [Re: MasterQ32] #450987
04/26/15 14:48
04/26/15 14:48

M
Malice
Unregistered
Malice
Unregistered
M



Btw if you are going to do so much waiting you should call out of the even and maybe lock the event.

Orginal Code by Uhrwerk
Code:
/*
 * Stops the entity from receiving events of type e_type
 * until no instances of f are running for that entity.
 *
 * f: The function to be waited for.
 * e_type: The type of events to be disabled.
 */
void event_lock(void* f,fixed e_type)
{
	if (!my)
		return;
	
	my->emask &= ~e_type;
	
	while (proc_status2(f,me) != 0)
		wait(1);
	
	my->emask |= e_type;
}


function this_event()
{
  if(event_type == EVENT_IMPACT)
  {
    beep();
    event_lock(this_event, ENABLE_IMPACT);
    wait(my.skill88); 
  }
}

// OR
function call_out_to_wait(ENTITY* event_ent)
{
 ENTITY ent_event_ent =event_ent;
 wait(my.skill88);
  ...do more stuff....;
}

function this_event()
{
   if(event_type == EVENT_IMPACT);
   {
     beep();
     call_out_to_wait(you); 
   }
}


Re: event_type and passing into functions [Re: ] #450988
04/26/15 14:50
04/26/15 14:50
Joined: Apr 2005
Posts: 1,988
Canadian, Eh
DLively Offline OP
Serious User
DLively  Offline OP
Serious User

Joined: Apr 2005
Posts: 1,988
Canadian, Eh
@malice: As I said, Thats merely an example. I would never use such a useless code... wink Also, thanks for the example.

Thanks MasterQ32. I had known that much. But it would have been cool not to have to use skills to do that.

Last edited by DLively; 04/26/15 14:55. Reason: made small addition

A8 Pro 8.45.4
YouTube: Create Games For Free
Free Resources: www.CGForFree.com
Re: event_type and passing into functions [Re: DLively] #450989
04/26/15 15:21
04/26/15 15:21

M
Malice
Unregistered
Malice
Unregistered
M



Well egg on my face. blush confused


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1