Storing a random sequence
Not sure how to explain what I'm doing...
Say I make a sequence of numbers, something like this (but 6 rather than 3):
//&a, b, c are globals storing sprite numbers
loop:
int &temp = random(3, 1);
if (&temp == 1)
{
&temp = &a;
goto skip;
}
if (&temp == 2)
{
&temp = &b;
goto skip;
}
if (&temp == 3)
{
&temp = &c;
}
skip:
//do something
//also some counter to only loop x number of times
goto loop;
And now in another script I want to find out in which order 'do something' happened to each sprite. I thought of using sp_gold to store a simple number for the order but that won't work because what happens if one sprite is used more than once? So supervars or something might be the way to go but as you might remember I'm not much good at those and anyway I can't figure out what I'd store that would make sense.
Help?
Say I make a sequence of numbers, something like this (but 6 rather than 3):
//&a, b, c are globals storing sprite numbers
loop:
int &temp = random(3, 1);
if (&temp == 1)
{
&temp = &a;
goto skip;
}
if (&temp == 2)
{
&temp = &b;
goto skip;
}
if (&temp == 3)
{
&temp = &c;
}
skip:
//do something
//also some counter to only loop x number of times
goto loop;
And now in another script I want to find out in which order 'do something' happened to each sprite. I thought of using sp_gold to store a simple number for the order but that won't work because what happens if one sprite is used more than once? So supervars or something might be the way to go but as you might remember I'm not much good at those and anyway I can't figure out what I'd store that would make sense.
Help?
Could you be slightly more specific about what information you want?
Say, my outcome for this script is ACCBACBCAA. Then I could interpret your question in two ways:
1. For every sprite I want to know when it did something, like:
sprite A did something at moment 1, 5, 9 and 10
sprite B did something at moment 4 and 7
sprite C did something at moment 2, 3, 6 and 8
2. I want to know which sprite did something at which moment, like:
moment 1: sprite A did something
moment 2: sprite C did something
moment 3: sprite C did something
moment 4: sprite B did something
and so on..
In either case you'd probably want to use supervars anyway. Atleast I would...
Say, my outcome for this script is ACCBACBCAA. Then I could interpret your question in two ways:
1. For every sprite I want to know when it did something, like:
sprite A did something at moment 1, 5, 9 and 10
sprite B did something at moment 4 and 7
sprite C did something at moment 2, 3, 6 and 8
2. I want to know which sprite did something at which moment, like:
moment 1: sprite A did something
moment 2: sprite C did something
moment 3: sprite C did something
moment 4: sprite B did something
and so on..
In either case you'd probably want to use supervars anyway. Atleast I would...
Uh... kind of both
I want to check the sprites and see if I'm checking them in the correct order. For example I look at sprite A and the script checks if it is actually the first one that came up in the sequence, and so on.
Script something like this, using your example of ACCBACBCAA:
//sprite a
//some check here, eg if this is the first sprite
//I'm checking then &sprite_a should be 1 but not 5, 9, or 10.
if (&sprite_a == 1or5or9or10)
{
//yay!
}
Ok that's a weird way to explain but I can't think how to speak clearly!
I want to check the sprites and see if I'm checking them in the correct order. For example I look at sprite A and the script checks if it is actually the first one that came up in the sequence, and so on.
Script something like this, using your example of ACCBACBCAA:
//sprite a
//some check here, eg if this is the first sprite
//I'm checking then &sprite_a should be 1 but not 5, 9, or 10.
if (&sprite_a == 1or5or9or10)
{
//yay!
}
Ok that's a weird way to explain but I can't think how to speak clearly!
If I understand you right, you can use editor_frame/seq. Editor number #1 is the first sprite in order, #2 is the second, etc. Like this:
int &temp;
int &count = 1;
loop:
&temp = random(3, 1);
if (&temp == 1)
{
&temp = &a;
goto skip;
}
if (&temp == 2)
{
&temp = &b;
goto skip;
}
if (&temp == 3)
{
&temp = &c;
}
editor_frame(&count,&temp);
skip:
//do something
//also some counter to only loop x number of times
&count += 1;
goto loop;
-----
retrieve them like this:
&count = 1;
int &spr;
rloop:
if (&spr != 0)
{
&spr = editor_frame(&count,-1);
//do what you want with the sprite
&count += 1;
goto rloop;
}
-----
This will allow you to have 100 repetitions of the original loop. If you need more, I suggest you succumb to supervars.
editor_frame/seq with any number between 0 and 99 will work regardless of whether there is a sprite that corresponds to that number.
I don't know what would happen if you tried to access editor_frame/seq without first setting it. Here I am assuming it will be zero. But it may crash. If it does just run through a loop to set all you need to zero initially.
-
The other one, e.g. this:
if (&sprite_a == 1or5or9or10)
can be done by checking if editor_frame 1 or 5 or 9 or 10 is &sprite_a.
int &temp;
int &count = 1;
loop:
&temp = random(3, 1);
if (&temp == 1)
{
&temp = &a;
goto skip;
}
if (&temp == 2)
{
&temp = &b;
goto skip;
}
if (&temp == 3)
{
&temp = &c;
}
editor_frame(&count,&temp);
skip:
//do something
//also some counter to only loop x number of times
&count += 1;
goto loop;
-----
retrieve them like this:
&count = 1;
int &spr;
rloop:
if (&spr != 0)
{
&spr = editor_frame(&count,-1);
//do what you want with the sprite
&count += 1;
goto rloop;
}
-----
This will allow you to have 100 repetitions of the original loop. If you need more, I suggest you succumb to supervars.
editor_frame/seq with any number between 0 and 99 will work regardless of whether there is a sprite that corresponds to that number.
I don't know what would happen if you tried to access editor_frame/seq without first setting it. Here I am assuming it will be zero. But it may crash. If it does just run through a loop to set all you need to zero initially.
-
The other one, e.g. this:
if (&sprite_a == 1or5or9or10)
can be done by checking if editor_frame 1 or 5 or 9 or 10 is &sprite_a.
This will go wrong if any of the sprite number you do editor_frame on is set earlier. For example, in the barrel script.
That's why you don't use editor_frame for any other purpose on that screen . Or, if you only have 10 places, use 90-99
Woohoo, it works!
...Not that I thought it wouldn't work, of course! Just happy I've finished at last
Seems strange that editor_seq/frame work even if that sprite doesn't actually exist. The screen I was testing this on doesn't have any editor sprites at all but it works perfectly.
...Not that I thought it wouldn't work, of course! Just happy I've finished at last
Seems strange that editor_seq/frame work even if that sprite doesn't actually exist. The screen I was testing this on doesn't have any editor sprites at all but it works perfectly.
If you knew you wouldn't be here waiting for D-Mods but you would be creating them yourself.