[ Solved ] Actor By Name custom block

1MrPaul1

  • *
  • Posts: 1285
I need to create many different things from list attribute in many different places, so it hard always use code, text and actor attributes for creating actor by means of this AS3 code _CurrActor = getActorTypeByName(_Actorname);
And actor creating it's a core of my game that must to became as complex rpg. And if in future I will need to use not AS3 code but code for iOs or C++ I'm affraid that it will be too hard to change this code in all places.
So, may be it's possible to make global custom block that will create temp text and actor atribute than convert it to actor and return as actor type?
I tried but without programing knowledges it's just impossible. my block won't return code, won't to set up text attributes and actor types...
In screenshoot you can see what I mean

« Last Edit: March 30, 2012, 03:31:08 am by 1MrPaul1 »

rob1221

  • *
  • Posts: 9474
Custom block variables use TWO underscores, not one.  Also, I think the "CurrActor" isn't necessary.  Simply use "getActorTypeByName(__Actorname);" and the custom block will accept the name as input and return an actor type.  Oh, I'm also not sure if this will work as a global custom block.  If not, try a regular custom block.

« Last Edit: March 29, 2012, 11:44:45 pm by rob1221 »

1MrPaul1

  • *
  • Posts: 1285
Can you make an example please? I always have errors, don't know where to place code and what from where to return

captaincomic

  • *
  • Posts: 6108
What rob said. So the block in the screenshot is a custom block (not a global custom block).
And make sure you select Actor Type as return type.

1MrPaul1

  • *
  • Posts: 1285
I did the same things but always have errors because I always used just one underscore before the "name" attribute and I understand now what means Robs words about TWO underscores in custom blocks.
Now this custom block works well! Thank you very much! You guys saved me!