[Behavior] Any Actor of Type


  • Posts: 591
Yes, I've made another behavior. This one isn't really complicated, but I suppose that it might save a bit of time which you would otherwise spend on snapping "for each actor of type" block just to do something for a single actor.

Anyway, I'm so lazy that I'll just copy-paste a description:
Scene behavior containing two Custom Blocks: one for getting any actor of type, and another for any actor of group. IT MUST BE ATTACHED TO THE SCENE! I tried using Global Custom Blocks, but they seem to dislike "for each actor of something" loops. ;-;

"any actor of type" block can be used:
 - to refer to an actor which is known to be single, e.g. player, without using "for each actor of type" loop or attributes
 - in blocks which use property common for all actors of type. I suppose that "type of [any actor of type [Something]]" isn't a particularly useful example. ^^'

I don't really know what "any actor of group" block can be used for, but I decided to add that anyway.

Any doubts? ^^'

ipe 369

  • Posts: 1001
I don't quite get it... Is there any difference between this and just doing a loop? Surely just doing a loop would be easier, i'm not sure i understand what this is :P


  • Posts: 591
Doing a loop would be annoying and it would make the behaviors space cluttered with wrappers which are not really that needed. Also, sometimes I might need only one actor of given type (e.g. to get an image for animation, which is common for all actors of type), and I could have the given part of logic executed many time instead, if I were using the loop.

But yes, the main reason is that I want it to be generally prettier and I would have something like:
Code: [Select]
trigger event [MoveLeft] in behavior [Movement] for [any actor of type [Player]]rather than something as large and ugly and in wider context harder to read:
Code: [Select]
for each [actor of type] [Player]
  trigger event [MoveLeft] in behavior [Movement] for [actor of type]
The change here is purely visual, yes, but thanks to that the whole logic looks cleaner and it doesn't give an impression that I perform something on potentially multiple actors.