So I have n number of active objects an all of them has this string:
32|64|96|12|32| and so on with some numbers
all of them mean X positions
I would like that the object moves to the next X position by getting the next element. Is it possible without string parser? I can't use it because I have lost of active objects.
So for example:
At the start of the rame:
- Active: add delimeter to "|"
Every second:
- Active: Set X position to Val( listGetAt$( "Alterable String A", 1) )
I think the easiest way to do what you want is this:
* Every 01"-00
(Active) : Set X position to Val( Mid$( string$( "String" ), value( "Counter" ) * 4, 3 ) )
(Counter) : Add 1 to Counter
It doesn't use delimiters to tell where one substring ends and the next begins. Instead, it uses substrings of a fixed length (3 characters / 4 including delimiter). If you need to change the length to something else, just change where it says 3, and change where it says 4 to 1 higher (that's to take into account the "|" which you'll probably want to keep to make editing the text easier.
Like I said, this requires that all substrings are the same length, eg. 001|012|123|
This shouldn't be a problem, but if you need to set the text from within the game, you can use:
* whenever...
(String 2) : Set alterable string to Right$("000"+ string$(String)"), 3)
This just puts zeroes in front of the number if required.
If you *need* to use delimiters and this is no good, let me know. It is possible, and I have an example somewhere, but it's more complicated.
You'll be please to know String Parser CAN handle all objects at once.
If you look at the expressions in String Parser, it has these two:
- Set String, return ""
- Set String, return 0
These allow you to set the Source String from within an expression. Since the expression runs once for each object you select, it will perform its String Parsery goodness for all instances of your object.
So you could do this:
Start of Frame
-- Parser: Set Delimiter 0 to "|"
Every Second
-- Active: Set X position to 'set( "String Parser", Alterable String A( "Active" )) + val(listGetAt$( "String Parser", 5))'
This will set all actives to the X position of the 5th element in their array. It *should* be unique for each one.
If you wanted each instance to have a different element that it was looking at as well (so not all of them are looking at element 5. Perhaps one looks at element 2, the other 4, etc), then you would need to base the element on another alterable value.
Finally, remember that you can rename Alterable Strings and Values. So you can rename 'Alterable String A' to 'Array' or anything else.
When Active1 Flag 1 is ON and I set the source string, it sets it from some active1 object, not from it which has flag 1 on :S
EDIT: Or I did something wrong...
Sketchy: If possible, delimiters would be very good without string parser.
Actually, I don't think my method would help you here. Sorry It uses fastloops, so it would be just as easy for you to fastloop through each object and use the string parser.
Having said that, there shouldn't be a problem with flags. What other conditions do you have in the "flag 1 is on" event?
Also, what was the problem with my first suggestion?
Sure i can take a look if you want to mail/upload it somewhere.
n/a
Assault Andy Administrator
I make other people create vaporware
Registered 29/07/2002
Points 5686
13th July, 2007 at 22:52:22 -
Sketchy briefly touched on this, but the best method to do this would be to use a fastloop and the string parser.
Basically you need three things.
* 32|64|96|12|32| saved as an alt string in the actives
* Alt Val A as an ID number
* Alt Val B as current position in the string
Start of frame, spread 0 in alt a of your active.
Then always run the loop "move" for the number of actives you have.
On loop "move"
& alt val of active = current loop index of "move"
then
Set Source String to Active's Alt String;
Active.x = Get element number (Alt val B) using string parser
Add 1 to Alt Val B of the active.
Instead of always running the loops "move" (as this would pretty much instantaneously move the actives to the end of their strings) you should just call the "move" loop whenever you want them to move, ie. every 1 second.