help needed!! transfering actor variables :(

Non-platform specific questions.

help needed!! transfering actor variables :(

Postby sonicfire » Fri Apr 15, 2011 10:50 am

hi folks!

can anyone help me with this one? basically i´m trying to pass a colour variable between three actors so to say.
i cant think of a better way to do this. in this "game" currently it should detect colours and destroy connected
diamonds (of the same colour). however in my routine it only works with the blue diamonds
(guess because it starts with "0" which is colour blue, so the variable isnt passed correctly and thus always zero).

can anyone have a look? i dont know why my variable passing
Code: Select all
actorxyz->ia_mycol = ia_mycol;

doesnt work :(

thanks so much in advance!!
Attachments
diamondo.rar
i create a temparr actor, which gets color value from the clicked diamon. then it passes it to four actors that move in all four directions to check the colour of the neighbour diamonds. but somewhere something isnt right :(
(209.78 KiB) Downloaded 59 times
sonicfire
 
Posts: 425
Joined: Wed Nov 01, 2006 9:34 pm
Location: berlin germany
Score: 16 Give a positive score

Re: help needed!! transfering actor variables :(

Postby sonicfire » Fri Apr 15, 2011 1:16 pm

ok, got it, had to move some actor variable related stuff into a TIMER! instead of "in the creation event".
(so execute something around 20ms later).

there was once a problem with this also, using load and savevars, when used in create actor event.

ok, problem solved :) weird, but solved.
sonicfire
 
Posts: 425
Joined: Wed Nov 01, 2006 9:34 pm
Location: berlin germany
Score: 16 Give a positive score

Re: help needed!! transfering actor variables :(

Postby skydereign » Fri Apr 15, 2011 8:55 pm

This problem is due to the event ordering gE uses. When you call CreateActor, it will stop the current script and create the actor (which means it will run the create actor script before you can set any variables). Same goes for Activation Events. Of course the actor isn't drawn until the draw events start. Anyways, you don't have to use a timer in your case, and most cases actually. I usually use the creator actor reference, which is extremely useful. In temparr's create actor event, add this code to the top.
Code: Select all
ia_mycol = creator.ia_mycol;
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest