I'm trying to create a basic mini-game where theres a grid of numbers and one empty spot and the goal is to get all the numbers in a row. The problem I'm having is the randomizing trigger and I can't figure out what I'm doing wrong. I'd appreciate any help.
Type "Start" to run the randomizer, its pretty basic all and all, but I only had like 15 minutes...
I was trying to get some kinda chat string so you could just type the size of the grid you want in order to start it, but I ran out of time. It generates 9 random numbers that never repeat and prints them into the chat.
Two important parts... the first trigger runs a loop based on the grid size, all it does is run the lottery trigger and >>>Waits until it finishes<<<
The second trigger just keeps running over and over until it finds a value it hasn't found before and then prints it to the chat.
I could have made it alot fancier, but this will be completely random and you can easily control the grid size. Hope it works for you.
Edit: It is throwing everything into the global data table because I am lazy, you will want to have an actual array or at least clear the data table so it can run more then once if you actually were to use it.
@akaGrimm: Go
You need to confine the buttons to your dialog, so when the random int is selected to greater than the X or Y. Also the buttons are stacking so you need a way to check If the spot has been taken or if the integer is taken. )
the map above gave me a stack error, you dont have a way to check if all the spots are filled so its overflowing if its selected more than once
The "overflow" you found is just the map isn't clearing the data table, I didn't make it with the intentions of being used over and over, just to give an idea of how to randomize with triggers. In and actual game you would probably just clear the data table once the minigame was won or lost so it could generate a new one.
The data table will never hold more then the exact size of the grid being generated. So you can always tell if all the spots are filled because when the For Each loop finishes is when all of the spots are filled... the loop wont finish until there is a integer value for each position. Which is convenient because there is no point in proceeding with the minigame until you have a full grid anyway.
Edit: Because I am a sucker, I added in that one single action that allows it to generate over and over again without that "overflow" just for you.
It was pointless to have anything there since it served no purpose, however it was also required for the trigger to function. So I named it intuitively that so anyone newer to trigger editing who happened past it wouldn't think that it was related to the Grid Size variable because it wasn't related at all.
And while I am not angry, I just don't understand why you would point out that it is causing a stack overflow... I even said in my original reply that I was lazy and didn't put the data table clearing in. It was only intended as an example to help him figure it out not as a tutorial. Perhaps it was just too complex for you... In the future I will attempt to dumb down any other examples I do like I have done with this one in order to help you figure them out =)
I didnt see the edit so i apoligize but you still missed my point, PointlessbutRequired isnt needed at all, it can be removed and Grid Size can be used in its place. I don't appreciate you insulting me either but that isn't the point of this thread
Sorry for the late response and sorry for the rather vague explanation. I was doing things a bit different than you. I created a dialog box and was randomly swapping two different dialog item's locations. I originally was thinking about just recording the x / y offset of the dialog items but I'd like there to be one empty spot with no dialog item.
I think I know what the problem is now, but not why the problem is there in the first place.
I already have a customizable dialog box that has buttons equal to the area of the box - 1 for one empty slot. I'm then randomizing which two dialog items get swapped. I have it so if one of the randomized spots is the empty location, it won't try to move a dialog item that's not there. The problem is the times it doesn't work right, it's because it thinks a spot is being used by the empty location. I have it so if the x / y cord != the empty spot's cord, do not move a dialog box, and I even removed the random int range so it can't by chance even move that location.
Would you be able to look at my trigger to tell me where it is I messed up?
@akaGrimm: Go You need to confine the buttons to your dialog, so when the random int is selected to greater than the X or Y. Also the buttons are stacking so you need a way to check If the spot has been taken or if the integer is taken.
Say you have an 8X8 and you select 10, multiply and you are setting the coordinates to a constant plus 10 x Variable but the maximum dialog width is constant + 8 x Variable, and your buttons are stacking which means an integer has been selected twice. So the problems are setting the integer and moving the dialog buttons
I think you haven't taken a look at my map because what your describing isn't what's in it. I know the problem, I'm just not sure why I'm having it. Below are the generalized steps I'm taking (assuming the grid is selected for 4x4)
1) I'm creating a grid of boxes 4x4 and filling in with 15 dialog items with text labeled 1 through 15 (last location is an empty spot, no dialog item)
2) I'm storing a x / y coordinate for each dialog item
3) I want to randomly swap two dialog boxes
4) I generate 2 random numbers in a range 0 through 15 (so it includes the empty spot as a possible swap location)
5) I use local ints to help swap the two coordinate values for both boxes
6) I have two if/then/else for both swap actions, if one of the locations != current location of the empty spot, move the dialog item, else do nothing. This is suppose to make it so it doesn't try to swap a non-existent dialog item.
The problem I have is the if/then/else. Some reason it seems to think if either the x OR y is the same as the empty spot's cord, do nothing. If I remove the conditions all together, it works fine. I want to know what the problem is, this is really bugging me.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
I'm trying to create a basic mini-game where theres a grid of numbers and one empty spot and the goal is to get all the numbers in a row. The problem I'm having is the randomizing trigger and I can't figure out what I'm doing wrong. I'd appreciate any help.
Dropbox Link
@akaGrimm: Go You need to confine the buttons to your dialog, so when the random int is selected to greater than the X or Y. Also the buttons are stacking so you need a way to check If the spot has been taken or if the integer is taken. )
the map above gave me a stack error, you dont have a way to check if all the spots are filled so its overflowing if its selected more than once
@AstralCV: Go
dont get so angry he is generating it multiple times in his map and needs it
Also, why did you clear the entire data table(he could be using or will use it in the future)? PointlessbutRequired isnt needed just use Grid Size
@AstralCV: Go
I didnt see the edit so i apoligize but you still missed my point, PointlessbutRequired isnt needed at all, it can be removed and Grid Size can be used in its place. I don't appreciate you insulting me either but that isn't the point of this thread
Sorry for the late response and sorry for the rather vague explanation. I was doing things a bit different than you. I created a dialog box and was randomly swapping two different dialog item's locations. I originally was thinking about just recording the x / y offset of the dialog items but I'd like there to be one empty spot with no dialog item.
I think I know what the problem is now, but not why the problem is there in the first place.
I already have a customizable dialog box that has buttons equal to the area of the box - 1 for one empty slot. I'm then randomizing which two dialog items get swapped. I have it so if one of the randomized spots is the empty location, it won't try to move a dialog item that's not there. The problem is the times it doesn't work right, it's because it thinks a spot is being used by the empty location. I have it so if the x / y cord != the empty spot's cord, do not move a dialog box, and I even removed the random int range so it can't by chance even move that location.
Would you be able to look at my trigger to tell me where it is I messed up?
Say you have an 8X8 and you select 10, multiply and you are setting the coordinates to a constant plus 10 x Variable but the maximum dialog width is constant + 8 x Variable, and your buttons are stacking which means an integer has been selected twice. So the problems are setting the integer and moving the dialog buttons
I think you haven't taken a look at my map because what your describing isn't what's in it. I know the problem, I'm just not sure why I'm having it. Below are the generalized steps I'm taking (assuming the grid is selected for 4x4)
The problem I have is the if/then/else. Some reason it seems to think if either the x OR y is the same as the empty spot's cord, do nothing. If I remove the conditions all together, it works fine. I want to know what the problem is, this is really bugging me.