"[anything] as actor" block


  • Posts: 6
I want to create an actor, then have it tell all other actors of a certain type that it exists and allow them to refer to it specifically.

You can't create a game (global) attribute of type actor, but each actor can have a custom attribute of type actor. I can get that first actor to distribute itself to common "set actor value" blocks for all actors of the specified type. But I need to use the "get actor value" block, read its results, and convert it to an actor, so I can use the setter method.

I know that's hard to read. Let's see if I can type an example:

[to distribute the actor to all actors of a specified type:]
always {
for (all actors of type Bolt) {
set actor value (energyBar) for (the actor) to (Self); }

[to receive that actor and store it:]
(Assume elecBar is a custom attribute of type actor.)
when created {
set actor value (energyBar) for (Self) to (Self);
(energyBar is constantly being updated to the first actor after creation)
set attribute elecBar to ((get actor value (energyBar) for (Self)) as actor);

And then elecBar will always refer to that first actor, even though it is an attribute of type actor which is created by a totally separate actor. But I really need a "(anything) as actor" block to get it done, I think. Either that, or global attributes of type actor.


  • Posts: 6
It occurs to me that I could possibly get around it if I use the "for all actors of type Energy Bar" block, because there's only one:

for (all actors of type Energy Bar) {
set attribute elecBar to (the actor);

But I still think the "[anything] as actor" block would be nice.


  • Posts: 62
I want to add to this too because often when I have multiple enemies (say enemy1, enemy2, enemy3, etc.) all named as attributes I can't reference them by saying

[enemy + [attribute:enemyNum]]
 (using a text + text block)

and that can make trying to reference enemies much more difficult or just impossible in a loop.