Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
5 registered members (Dico, AndrewAMD, TipmyPip, NewbieZorro, Grant), 15,791 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Clueless regarding actions and events #152310
09/06/07 16:49
09/06/07 16:49
Joined: Aug 2007
Posts: 26
S
SteveA Offline OP
Newbie
SteveA  Offline OP
Newbie
S

Joined: Aug 2007
Posts: 26
I am struggling with the implementation of events and actions. I am obviously missing a major concept.

I am trying to get collision events for entities. I see examples like this in the docs:

function bounce_event()
{
switch (event_type)
{
case EVENT_BLOCK:
ent_playsound(my,whamm,50);
vec_to_angle(my.pan,bounce); // change direction
return;
case EVENT_ENTITY:
ent_playsound(my,boingg,50); // play a different sound
vec_to_angle(my.pan,bounce); // change direction
return;
}
}

action bounceball()
{
my.emask |= (ENABLE_BLOCK | ENABLE_ENTITY); my.event = bounce_event;
while(1)
{
c_move(me,vector(5*time_step,0,0),nullvector,0); wait(1);
}
}

And there are even simpler examples of actions and events like this:

action rotate_plane()
{
while (1)
{
my.pan = my.pan + 0.1;
wait (1);
}
}

function main()
{
video_mode = 7;
level_load ("work10.wmb");
wait(2); // wait until the level is loaded
vec_set(camera.x,vector(-500, 0, 100)); // place the camera at x = -500, y = 0, z = 100
}

However <blush>, I don’t understand how the actions (e.g., bounceball and rotate_plane in these examples) get associated with my entity (e.g., _MyEntity). Can actions only be associated with entities from within WED or can they be associated with entities from C-Lite? I’m sorry my question is so vague… I am very new to GameStudio.

Currently I do this in main (very paraphrased):

level_load("MyWord.wmb");
wait (2);

_MyEntity = ent_create ("MyEntity.mdl", vector(0, 0, 0), NULL);


I don’t understand (no sh*t) how to have a function called when a specific event happens to _MyEntity.

Thanks!

Steve

Re: Clueless regarding actions and events [Re: SteveA] #152311
09/07/07 03:25
09/07/07 03:25
Joined: Aug 2007
Posts: 26
S
SteveA Offline OP
Newbie
SteveA  Offline OP
Newbie
S

Joined: Aug 2007
Posts: 26
Answering my own question: Apparently I can't assign the event handling function from my source file, so I added my existing source file to the level (wmp) by choosing File | Map Properties | Script, added Action functions to my source file, added the models in the level. In the action functions I grab pointers to "me" so I can still access the entities from the source code.


Gamestudio download | 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