Queue System

For questions about using Classic.

Post » Mon May 12, 2008 5:05 pm

I've been working on a rts and am wondering if there is some way to make a queue or a spring box or something similar in an array. so far I've been having to make an alterable value that just ticks down, but this isn't effective for a building that makes more than 1 type of unit.
B
6
S
2
G
5
Posts: 249
Reputation: 2,323

Post » Thu May 15, 2008 8:08 pm

Well i suppose i don't do justice at explaining a rather complex idea, let me help illustrate it before I get buried in the forums. :)

when you click on a unit icon in the build menu in a RTS it adds it to a queue.

1-0-0-0

and as you add more it bumps them down the queue

1-2-2-0

when it reaches the end it loops stacking back to the front. I've been trying to use the array object to do this but there just doesn't seem to be enough commands to pull it off.

a simpler way of doing it would be a spring box in which the number is staked on top of by the next number.

1-0-0-0 --> 2-1-0-0 --> 2-2-1-0

you would have to revers the way it grabs the number but still a lot easier to understand.
Ashley I know you have been working on the Terminal Orbit RTS, how did you solve this?

P.S. a data object for this would be awesome :D
B
6
S
2
G
5
Posts: 249
Reputation: 2,323

Post » Thu May 15, 2008 8:42 pm

Hmm, looks like some kind of stack... it should be possible with the array object, if you keep track of how many items have been read with a separate counter or something. If you place an Array object in a container with the unit, you can store a whole array of data on a per-instance basis, which might be useful.

BTW Terminal Orbit never had a build queue, construction units were one-shot...
Scirra Founder
B
359
S
214
G
72
Posts: 22,948
Reputation: 178,532

Post » Thu May 15, 2008 9:18 pm

You could do it the old "Basic" way.

Use a string and break the string down with system "text" expressions.
This way you can build a (Q , d) array.

If u set the string as a private variable, this variable is differend for each instance, there is the (d) depht in your string.

The (Q) Que is the position in the string.

Now i dont know if u know how the acces system expressions. So excuse me for "over explaining".

Give an object a private variable called TheQue, type "text", intial value "0"

I allways give it a value at layout startup, so when you restart the layout, everything gets reset, and its polite to yourself to define variables in the events sheet. But thats up to you.

Now just for this lil "tutorial" make one system event "always"

Make a new action, acces the private variable 'TheQue' to change its value.

Now where u normal would type a value. We will put a system expression. Thats easy as:
On the bottom of the wizzard u find the objects listed again, including the system object.
Click system object. Now you have all expressions listed for the system object listed.
Look for text.
There u see "get left substring". Clicking it will bring "left(String, Count)" in the value field.

String got to be the private variable 'TheQue'. You get that out of the expressions, and the same way, of the object u gave the private variable to. This will give you something like "Sprite.Value('Variable name')", where Variable name will be TheQue. ('TheQue').

Count will be 1 for the first character in the string.

So to get the first in Que, it will be something like

left(Sprite.Value('TheQue''),1)

To add to the Que. Lets assume your initial value is numeric. Look voor the system expression "convert value to string" This returns "str(Value)" .. where u change value to ur value, or the value as an expression as getting a global variable, or private variable, even object.X or object.angle.

so add to the Que will be.

Sprite.Value('TheQue'') + str(value)

delete the first in Que will be

right(String, (len(String)-1))

or in your case

right(Sprite.Value('TheQue'') , (len(Sprite.Value('TheQue'') )-1))


Hope this helped you, or gave you a new direction to work to.

j0h
B
3
S
2
G
4
Posts: 322
Reputation: 2,119

Post » Thu May 15, 2008 9:31 pm

thanks for the suggestions, ill give them a try when i get the time to.

I never actually got to play the demo for Terminal Orbit, a couple of months ago i was trying to find it on your site, but ended up finding Construct . :)
B
6
S
2
G
5
Posts: 249
Reputation: 2,323


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 5 guests