"Self" block

Aasimar

  • *
  • Posts: 605
Hi guys,

I have an issue using the "Self" block on iOS.
On flash, it seems to get the name of the actor, without anything.
On iOS, it seems to get the name of the instance of the actor :

03/12/11 16:46:58,126 AppScaffold: Actor: RandomBlock3 4

The real actor name is "RandomBlock3".

How I can get the real actor name on iOS, maybe using code ?
Maybe using a crop text fonction ?

Thanks

Jon

  • *
  • Posts: 17524
You're using this just to get the name of the Actor Type? Why don't you get the actor type instead and print that out?

Aasimar

  • *
  • Posts: 605
Because on iOS, get the actortype gives this :

04/12/11 19:57:10,905 AppScaffold: <ActorType: 0x93e8e60>

You think I can use this ref ?

Jon

  • *
  • Posts: 17524
What are you trying to do with the Actor Type? Are you displaying it or using it to perform some logic?

Aasimar

  • *
  • Posts: 605
My idea is to generate some stuff depends of the name of the actor where the behavior is.
I sent to you this project by email there is 2 or 3 days.

Like this :

Jon

  • *
  • Posts: 17524
Comparing Actor Types is safer than trying to compare the names directly. Try something like this.


Aasimar

  • *
  • Posts: 605
Yes, it was my first approach, the only problem is I use only ONE behavior for all the generated blocks.
So, I can't define the actor type because I don't know what is the block generated.

I have this :

X blocks with the same behavior "GenerateItem"
In "GenerateItem" I need to detect the actor type and with this name, I can generate the stuff I want on it.

If it's block1, do this,
If it's block2, do this,
etc.

With your technique, I need to make 1 behavior for 1 block. If I have 20 blocks, I need 20 behaviors

« Last Edit: December 04, 2011, 12:53:13 pm by Aasimar »

Aasimar

  • *
  • Posts: 605
Maybe a visuel helps.

http://goo.gl/qs0L8

All the whites blocks are generated, with differents width.
On the blocks, I can't generate the same style of actors (trees, monsters, etc), so, I need to detect the block and generate differently depends of the size of them, or another parameter.

(In Flash it's all good, the problem is only on iOS.)

« Last Edit: December 04, 2011, 01:12:48 pm by Aasimar »

coleislazy

  • *
  • Posts: 2607
You could probably get the name, then split it based on the semi-colon, then split the 5th item in that list again on the blank space, then get the first item in that list. Its kind of an annoying work-around, but as long as the format is consistent, that should work.

Aasimar

  • *
  • Posts: 605
ActorType returns <ActorType: 0x93e8e60>
Self returns Actor: RandomBlock3 4

I need RandomBlock3

Both can't use the text options, like "find character at position" or something else.
I need code, arg, I need brain.

coleislazy

  • *
  • Posts: 2607
ActorType returns <ActorType: 0x93e8e60>
Self returns Actor: RandomBlock3 4

I need RandomBlock3

Both can't use the text options, like "find character at position" or something else.
I need code, arg, I need brain.

Use the "split text into words" block on the "self" block. It will return a list, from which you would take item #1 to get the actor type "RandomBlock3".

Aasimar

  • *
  • Posts: 605
Hmm, I think I have tried this yesterday, I'm not sure, but the Self block isn't dockable into the other block, maybe I need to get it into an attribute before. I'll test this tonight, I'm at work.

Thanks dude !

If It's not good, I think I'll cheat and get the width of the block, the only problem is to make blocks with differents sizes (for now it's not important, but after this I'll make blocks with same size but with differents properties, like snow, ice, etc.)

It's a little complicate :

Scene generates blocs
Blocs generates trees
Blocs generates monsters
trees generate grass
etc.

I want this game is totaly random.

coleislazy

  • *
  • Posts: 2607
If you can't drop "Self" directly into the "split" block, you can put it into the "as text" block first. Otherwise, you could try setting a text attribute to "Self".


Aasimar

  • *
  • Posts: 605
Yeah, after many tries and some modifications (numbers aren't really good), I used RandomblockA, RandomblockB, etc.

With a do only on iOS like : "Set GetName to Character at position X in Self as text".

Perfectly good, thanks !