Add actor to list

zerosimms

  • Posts: 690
I've hit a stumbling block on my game. I need to be able to create some actors, using the 'create actor' block but I also need them to be added to a list so that I can kill them at a later point using the 'kill' block.
Or...
Be able to back track more than once using the 'kill last actor created'.

That would be an awesome feature and would allow me to finish up my game :-)

coleislazy

  • *
  • Posts: 2607
I think it should be clarified that you CAN add an actor to a list, since a List attribute will accept all types. It is retrieving the actor as an Actor attribute that is the problem.

This should be resolved in an upcoming update (not sure which/when).

zerosimms

  • Posts: 690
Your beard is wise, mine is not :-) Thanks

Luyren

  • *
  • Posts: 1795
For retrieving, create an actor attribute. The, using the "for each item in list" block, loop through all items. Use the "[for self, set [_ActorAttribute] to [current item] for behavior [your behavior]" inside the loop, add an if statement to check if it has value and is alive, and then do whatever you want with it.
I have my Stencyl resources available here: https://luyren.itch.io/

jarowe

  • Posts: 29
The interesting problem I am having with this technique is that when I create an Actor Attribute.  I simply cannot select my actor because my actor is created from a spawner.  Is there anyway around this? 

jarowe

  • Posts: 29
Here is what I am getting after reading your explanation Luyren.

I am not necessarily understanding it however.  And also am confused at what "behavior" needs to be?

Luyren

  • *
  • Posts: 1795
Here is what I am getting after reading your explanation Luyren.

I am not necessarily understanding it however.  And also am confused at what "behavior" needs to be?
With 2.0, you can use the item block that comes within the for each item in list block as an actor block. This means that, if you want to kill all actors in the list:

For each item on list
> If [item] is alive
>>Kill [item]
>>remove [item] from list
I have my Stencyl resources available here: https://luyren.itch.io/

Hectate

  • *
  • Posts: 4643
The interesting problem I am having with this technique is that when I create an Actor Attribute.  I simply cannot select my actor because my actor is created from a spawner.  Is there anyway around this?
At the point that the spawner creates the actor, you need to immediately (the very next block after the "create actor..." one) use the "Set [MyActorAttribute] to [Last Created Actor]" block. That will save a reference to that new actor in the attribute that you want to use.
:
:
Patience is a Virtue,
But Haste is my Life.
Proud member of the League of Idiotic Stencylers; doing things in Stencyl that probably shouldn't be done.

jarowe

  • Posts: 29


For each item on list
> If [item] is alive
>>Kill [item]
>>remove [item] from list
[/quote]

This is what I have so far.  And the For each item on list isn't working. 
I am trying to make it, when the gems are still at the left.  If I click and drag on the matching gems that it will add them to a list and then when I release my string of matching gems that I have selected will be killed.

jarowe

  • Posts: 29
I am noticing when I draw my list to the screen, that nothing is being added to my Blue List when I am dragging over the Blue Gems.  However when I [add 'last created actor' to list] it shows that it is adding them to the Blue List.  So something is going wrong for me on the clicking on actor to add to list.  I am not sure why when I click on them they aren't added to the Blue List?

jarowe

  • Posts: 29
I have narrowed my problem down to this:

If x-speed of self  >= -3

For some reason when I adding that rule it doesn't work.  Without that I have it working great right now.  However I still wish there were a way for it to not kill right away on 4 Gems.  But otherwise let me collect as many as I can and upon my release kill all i selected if they match.