Text box randomly selects object name, how change the named objects animation?

I have a repeat timer as a CONDITION that every 2 minutes triggers a text box to randomly select an object name from a list of objects (the text box is set to use the function "choose::randomstring("object1, obj2, etc). Every 2 minutes when the text box lists a different object name I want to change that objects animation. How can I do this?

Hi @Ken2100,

Put all the objects from the list in a group. Use a For each “group” event and add this to it:

Compare strings: group.ObjectName() = textbox.Text() → change animation of “group”

1 Like

Thanks for the advice, question:

  1. I couldn’t find the “for each” function, can you give me a screen shot of exactly what it looks like

  2. When I did the compare string function it changed ALL of the animations of the objects in the group, I only want to change the animation of the object in the group that’s actually called, not the entire group.

This is why you need to put the condition / action in the For Each event.

The ObjectName() will not pick the object but it only returns true or false. The for each event loops through each instance of object and picks it, so if condition is true, then it will be true for the picked instance of object.

Is there a way to refer to a group of groups? For example, if I have 3 different groups of objects, each group has 2 objects in it, and I’m setting up an event that checks each group to see if the correct object animation has been changed (by player). Is there a “For Each” function where I can say For Each group in this list of groups check abc and if true do xyz?

No, this is not possible. You need to create a new group and include all these objects in it, and do for each new_group.

How do I assign object variable values to children of scene array variables (the way it was similarly done in the gdevelop ready made game “tic tac toe”)?

  1. I have 10 objects and each object has an object variable. I also have a Grid array that has 10 children. I’m trying to write an event that matches the 10 children of my Grid array to each of my 10 object variables.

I would like that each time an object animation changes, a number value is assigned to a child of my Grid array. So that for example, when object 1 changes animation the value of child 1 of my Grid array is changed to 100.

I’m doing this so that I can use simple math to determine when certain object animations are changed. So that for example, if player selects four objects and one of them is incorrect, if they have also selected the object called “1 Wrong” (which is object 10 and child 10)that allows them one mistake, and now they are considered as making the correct selection even though they initially made a mistake.

I want to use simple math to check because each childs value is changed to 100. Meaning if I check it with the equation “child 1+child 2+child 3+child 4+ child 10 is greater than 400” they are correct. If they haven’t selected child 10 this equation will only give 400 and the game can easily determine that they are incorrect, because either you have 400 or greater than 400.

Trying to repeat this (Screen shots below)
I want to be able to add the values of the variables to check if player selection of objects is correct, that way I can make the one free mistake option “1 wrong” an odd number and easily check for that.

For example if each variable value is changed to 100 when object animation is changed, and “1 wrong” variable value is changed to 1 when it’s object animation is changed, the game can check if the 4 variable values added plus the “1 wrong” variable value is equal to 400 or 301(bc “1 Wrong” wasn’t selected it will have a zero variable value).






Please do not repost the same question in multiple threads. Thank you