I am trying to make a random role and it just doesn't work. I tried making it pick a role until it found one that wasn't taken, but it says there are too many nests in the error box in game. How should I do this?
Through debugs I found that it is not changing my role value for some reason.
Edit: I made a new smaller trigger that also does not work, but it seems better so I'll post a picture of it too. This one doesn't say that there are too many nests, but it says could not get property from parameter. Not really sure what that means since I don't think it has any parameters.
I tried using a while statement in the second trigger from my first post cause that was the only difference between mine and your example. There's no error message for it now, but it won't pick a role, I think it is because of my timer update. It gives me an error message saying could not get 'triggerControl from parameter in DialogControlSetPropertyAsText.
I suggest you make a variable which saves the hero value.
Do something like:
VariablesHeroint=0<Integer>HEROISTAKEN=False<Boolean[MAXIMUMNUMBEROFHEROESHERE]>ConditionsActionsVariable-SetHeroint=(Randomintegerbetween0OR1DEPENDINGONWHICHYOURSYSTEMSTARTSandMAXIMUMNUMBEROFHEROESHERE)General-Repeat(Actions)foreverActionsGeneral-If(Conditions)thendo(Actions)elsedo(Actions)IfHEROISTAKEN[Heroint]==FalseThenVariable-SetHEROISTAKEN[Heroint]=TrueTrigger-RunDOWHATEVERITISYOUDOTOSPAWNUNITS(CheckConditions,Don't Wait until it finishes)General-BreakGeneral-SkipremainingactionsElseVariable-SetHeroint=(Randomintegerbetween0OR1DEPENDINGONWHICHYOURSYSTEMSTARTSandMAXIMUMNUMBEROFHEROESHERE)
It is a little sloppy but with a few more lines of code that suit your fancy you could also stop the trigger from trying to randomize to the same number. I just don't feel like doing actual coding right now.
I am largely inactive, but I am still around. Feel free to poke me if you need some help, just be warned that I only really come back if I need help and/or if I'm posting a new map/library.
Well currently, I have this picture I posted below. I think it's almost the same thing, but I'm not sure if it is what's wrong because I'm getting an error message from the function in the post above yours.
There's no error message for it now, but it won't pick a role, I think it is because of my timer update. It gives me an error message saying could not get 'triggerControl from parameter in DialogControlSetPropertyAsText.
"'triggerControl from parameter in DialogControlSetPropertyAsText." means one of the variables someplace messed up and ur getting nothing or 0 look at which line the error occurs at and paste it from ctrl + 11 or try to do it urself if u can.
As i said before, yes this is a random role, but not unique. with 2 players there is a 1 in 8 chance of having the same role, with 8 theirs a very good chance 2 or more people will not have a unique role.
look at your trigger, lets say player 1 gets 8 as it's random number, what stops player 2 when going down this script to get 8 as well?
What stops it is that I disable the role they get right after it sets the role to be the random integer. Then when they next player's role gets randomly picked, it should see it as disabled and skip over it.
As for the line number, it says near line 2529 in libNtve_gf_SetDialogItemText() in TriggerLibs in NativeLibs.Galaxy
If it is doing this because it has no value, or because it has a value of 0. The variable is just a dialog item set to no dialog item, then I set it to last created dialog item and set to show the remaining time of a timer once I create it. So I'm not sure if that is relevant to the problem.
Also the total error message looks like this: Scri: Trigger error in auto_gf_UpdateStartUpTimer_Trigger Func': Could not get 'triggerControl from parameter in DialogControlSetPropertyAsText' (Value: 11)? Near line 2529 in libNtve_gf_SetDialogItemText() in TriggerLibs in NativeLibs.galaxy
Update Start-Up Timer is the name of my function, so that's what that part is in case you didn't know.
Well it seems that this was not the problem, because I got the random role to work. However, it only works when you click on the role. If someone does not click a role and just stays at random which is the default, nothing happens, which is weird cause I told it to run at the beginning of the role selection.
Generally speaking, picking random numbers and then checking to see if it's already taken or not is bad practice, because hypothetically speaking, you could run into a really long search for a working number. It's not likely, but it's possible to guess all taken numbers for hours on end.
What I would suggest is to store the values into an array, shuffle them, and then draw from the array. That way, you're guaranteed to get a unique number every time you draw from it, and you only need to draw from it when you want to.
For example:
//this fills an array with the available values to choose fromGeneral-Pickeachintegerfrom1toMaxChoices,anddo(Actions)ActionsVariable-SetL_ChoicesArray[(Pickedinteger)]=(Pickedinteger)//this shuffles the values in the array by picking each field in the array and swapping it with a random field value throughout the entire arrayGeneral-Pickeachintegerfrom1toMaxChoices,anddo(Actions)ActionsVariable-SetL_RandomInteger=(Randomintegerbetween1andMaxChoices)-------CommentVariable-SetL_Freecell=L_ChoicesArray[L_RandomInteger]Variable-SetL_ChoicesArray[L_RandomInteger]=L_ChoicesArray[(Pickedinteger)]Variable-SetL_ChoicesArray[(Pickedinteger)]=L_Freecell
Now that the values in the array are shuffled, whenever you need a random unique number all you need to do is grab at the array. Depending on how you have your map set up there are a few different ways to do that. If everyone is going to have a randomized hero every single time then all you would need to do is loop through each player and use the value in the array that matches their player number (or number in player group (active players)). Pick each player and do:
This is basically the same thing. In mine, I pick a random integer, store it to a variable, then set the role to equal that variable. And after reading yours, it does the same thing. The difference being that mine checks to see if the role is taken by someone already, while yours does not. I need this, as players are not necessarily going to pick random. I only want this for the players who pick random. However, random will be the default role, so if they do not pick anything, it will give them a random role in case the player happens to be afk or something. After trying to do all of this, I finally got it to work, but it only works if you select a role and then go back to selecting random, it will not work from the default that I set up. I'm thinking about just leaving it and getting someone to make me a better looking role selection, but it's always hard to give up on so much work.
I am trying to make a random role and it just doesn't work. I tried making it pick a role until it found one that wasn't taken, but it says there are too many nests in the error box in game. How should I do this?
Through debugs I found that it is not changing my role value for some reason.
Edit: I made a new smaller trigger that also does not work, but it seems better so I'll post a picture of it too. This one doesn't say that there are too many nests, but it says could not get property from parameter. Not really sure what that means since I don't think it has any parameters.
New to the Editor? Need a tutorial? Click Here
Want data assets? Click Here
Nested means that the trigger is out of control generating infinite loops. looking a your code u have some contained loops that r fine.
looking at your code, you can get a taken role, u need a while loop or a system that randomly picks from available roles. heres and example
pick each player { While (role Taken){ randomly set player into a role } }
@SoulTaker916: Go
I tried using a while statement in the second trigger from my first post cause that was the only difference between mine and your example. There's no error message for it now, but it won't pick a role, I think it is because of my timer update. It gives me an error message saying could not get 'triggerControl from parameter in DialogControlSetPropertyAsText.
New to the Editor? Need a tutorial? Click Here
Want data assets? Click Here
@fishy77: Go
I suggest you make a variable which saves the hero value.
Do something like:
It is a little sloppy but with a few more lines of code that suit your fancy you could also stop the trigger from trying to randomize to the same number. I just don't feel like doing actual coding right now.
@Yaksmanofage: Go
Well currently, I have this picture I posted below. I think it's almost the same thing, but I'm not sure if it is what's wrong because I'm getting an error message from the function in the post above yours.
New to the Editor? Need a tutorial? Click Here
Want data assets? Click Here
"'triggerControl from parameter in DialogControlSetPropertyAsText." means one of the variables someplace messed up and ur getting nothing or 0 look at which line the error occurs at and paste it from ctrl + 11 or try to do it urself if u can.
As i said before, yes this is a random role, but not unique. with 2 players there is a 1 in 8 chance of having the same role, with 8 theirs a very good chance 2 or more people will not have a unique role.
look at your trigger, lets say player 1 gets 8 as it's random number, what stops player 2 when going down this script to get 8 as well?
@SoulTaker916: Go
What stops it is that I disable the role they get right after it sets the role to be the random integer. Then when they next player's role gets randomly picked, it should see it as disabled and skip over it.
As for the line number, it says near line 2529 in libNtve_gf_SetDialogItemText() in TriggerLibs in NativeLibs.Galaxy
If it is doing this because it has no value, or because it has a value of 0. The variable is just a dialog item set to no dialog item, then I set it to last created dialog item and set to show the remaining time of a timer once I create it. So I'm not sure if that is relevant to the problem.
Also the total error message looks like this: Scri: Trigger error in auto_gf_UpdateStartUpTimer_Trigger Func': Could not get 'triggerControl from parameter in DialogControlSetPropertyAsText' (Value: 11)? Near line 2529 in libNtve_gf_SetDialogItemText() in TriggerLibs in NativeLibs.galaxy
Update Start-Up Timer is the name of my function, so that's what that part is in case you didn't know.
New to the Editor? Need a tutorial? Click Here
Want data assets? Click Here
@fishy77: Go
I was wrong its not zero or nothing its (value: 11) and it is not acceptable to whatever is using it. probably means that theirs an array that is 10
@SoulTaker916: Go
Well it seems that this was not the problem, because I got the random role to work. However, it only works when you click on the role. If someone does not click a role and just stays at random which is the default, nothing happens, which is weird cause I told it to run at the beginning of the role selection.
New to the Editor? Need a tutorial? Click Here
Want data assets? Click Here
Generally speaking, picking random numbers and then checking to see if it's already taken or not is bad practice, because hypothetically speaking, you could run into a really long search for a working number. It's not likely, but it's possible to guess all taken numbers for hours on end.
What I would suggest is to store the values into an array, shuffle them, and then draw from the array. That way, you're guaranteed to get a unique number every time you draw from it, and you only need to draw from it when you want to.
For example:
Now that the values in the array are shuffled, whenever you need a random unique number all you need to do is grab at the array. Depending on how you have your map set up there are a few different ways to do that. If everyone is going to have a randomized hero every single time then all you would need to do is loop through each player and use the value in the array that matches their player number (or number in player group (active players)). Pick each player and do:
@playpong: Go
This is basically the same thing. In mine, I pick a random integer, store it to a variable, then set the role to equal that variable. And after reading yours, it does the same thing. The difference being that mine checks to see if the role is taken by someone already, while yours does not. I need this, as players are not necessarily going to pick random. I only want this for the players who pick random. However, random will be the default role, so if they do not pick anything, it will give them a random role in case the player happens to be afk or something. After trying to do all of this, I finally got it to work, but it only works if you select a role and then go back to selecting random, it will not work from the default that I set up. I'm thinking about just leaving it and getting someone to make me a better looking role selection, but it's always hard to give up on so much work.
New to the Editor? Need a tutorial? Click Here
Want data assets? Click Here