Previously due to lots of help from forum members especially @Keith_1357 I was able to create a dynamic player choose screen. Now i want the varying player character to appear on the following scene. But it doesnt work. Here are the, global, scene and object variable screens along with relevant event sheet parts.
If you want to save the name and tower between scenes, you could set them to global variables.
Setting the them in the variable screen as child.tower and child.name literally sets them to “child.tower” and “child.name” not to the values in the corresponding variables. Plus, the child variables are scene variable not global.
To use name and tower in other scenes, you could create 2 global variables with those names and set them from the 1st scene. Either when the selection buttons are clicked or the button to start the next scene.
If you want to access the array though, you would need to put the array’s index number into a global variable that’s a number.
If the global variables was player you would get the array values with
Or using the new variable method, if the variables are declared with any initial value in the global variable screen you could simplify it because you don’t need to use the GlobalVariable part for them.
basically i need the condition, global.name[id] and the action, create object global.tower[id]. i cant figure out the expressions for the same. can u help?
If you assign the array’s element or index to a global variable. You can use that variable to get the tower and name and any other child of that array element.
This would act like the previous examples. create buttons , assign the name to the button and the element or index number to the button variable named Index.
When he button is clicked, it sets the global variable PlayerID to the button variable. That variable can be used to get the tower or name. In my test project, I just added the name and tower to a text object.
I’m not sure where tower index fits in. If you set the playerIndex to the array index then you can retrieve the values from that element using that variable.
(simplified code, unless you use he new system, you need the GlobalVariableString(). and other variable evwnts)
I think it should be GlobalVariableString(Global…
The children Tower and Name are strings, so you need to use the string version. As witten it’s trying to get a string as a number and then convert it to a string.
The index is a number but the children of the array of structures is a string. When it can’t convert the string to a number, I belive it defaults to 0 which is the convert to a string equivalent to using “0”.
I’m also unsure about PlayerIndex inside the braces or brackets. The new variable syntax should work with just [PlayerIndex] as long as PlayerIndex is in the Global Variable screen. Otherwise, it’s [GlobalVariable(PlayerIndex)]
Sorry, I missed the closing parenthasis. Move that last ) to the end. I’ll edit my last post. It’s tough to tell when you’re typing on a phone. That’s why I like to test my answers.