[SOLVED] Problem with "Create object from name" in a Function

So I have no problem with this event in the event editor of the scene, but if I use it in an Action Function it doesn’t create anything:

image_2021-02-03_001028

It should create a wall of brick of random color (that happen when I am not using the Function) and Object_Target_1 is a Group of Sprite where I pick randomly an Object to create it from 3 (for now).

I’ve been doing something that can’t be done in a Function or there is something that I am doing wrong?

Open the debugger and check your instances and variables

Is your global structure set up?
Is the name of the globalvariable(bricks_all.0/1/2) equal to your object names?

Yes, it’s set up!
The same event, in the event editor of the Scene instead that in a Action Function, works without problem.

I don’t understand What ure saying.
How can you run events in the editor?

Do you mean the events work in preview but not in a custum function?

The custum function needs parameters

Maybe I am using wrong words but for “editor” I mean the events of a Scene (I have only 1 Scene for now); the one in blue here:

image_2021-02-03_014454

“Game” it’s the name of the Scene; there, the same events, works well.

If I create a Function (“Stage_Creation” in the image) where I put the same events and I call that from the Events of the Scene, it doesn’t work!

did you define the parameters?

Yes! I’ve tried Any Object and Sprite!

you need to use the functions syntax

I am using only scene variable.

i tested it, and it worked by using not the itemgroup of the scene, but the sprites of the scene as parameters inside a group of the function.


2 Likes

Thanks a lot! I didn’t think about it; maybe I can use this idea!
Really thanks.

Solved! A bit tricky but possible! Thanks again!