Scripting Groups

Is there anyway to script a group collectively?

This is what I'm working on.

[img=http://img166.imageshack.us/img166/198/gamepreviewqh4.th.jpg]

Each piece is made up of four blocks that are cloned then grouped together.

Using the "I" piece as example:

I0_0 is set as the parent
I1_
I2_
I3_

Group is set to shapeI_0 for each item.
First cloned piece is
I0_1
I1_1
I2_1
I3_1
Group "shapeI_1"

The cloned object is cloned within the game grid.

Being able to script each group independently would save significant coding.

There are four rotation movements like this:

Sub Rotate1
    desktopx.object("I1_1").Left = desktopx.object("I0_1").Left
    desktopx.object("I1_1").Top = desktopx.object("I0_1").Top + 31
    desktopx.object("I2_1").Left = desktopx.object("I1_1").Left
    desktopx.object("I2_1").Top = desktopx.object("I1_1").Top + 31
    desktopx.object("I3_1").Left = desktopx.object("I1_1").Left
    desktopx.object("I3_1").Top = desktopx.object("I2_1").Top + 31
End Sub

There are three position movments like this:
Sub MoveDown
    desktopx.object("I0_1").Top = desktopx.object("I0_1").Top+31
    desktopx.object("I1_1").Top = desktopx.object("I1_1").Top+31
    desktopx.object("I2_1").Top = desktopx.object("I2_1").Top+31
    desktopx.object("I3_1").Top = desktopx.object("I3_1").Top+31
End Sub


Being able to script the groups will eliminate eight lines of code in the above examples alone. Any input or ideas are greatly welcome.

PS. Theres only one image being used at 354 bytes.
3,206 views 3 replies
Reply #1 Top
This is the image. Didn't want to mess up the code.


Free Image Hosting at www.ImageShack.us
Reply #2 Top
Yes, you can script group collectively. Check the docs under Developer's Guide->Scripting->Enumerators. You will end up using a For Each loop, as in the example, most likely.


Reply #3 Top
Yes, I saw/tried that. It's more reflective of scripting elements with the confines of a group. Scripting rotation at 90 per element essential results in no change.

I'll continue working on that basis but, using that specific example results in increased coding.