Scripting Groups

Tuesday, October 10, 2006 by SirSmiley | Discussion: DesktopX

Is there anyway to script a group collectively?

This is what I'm working on.

[url=http://img166.imageshack.us/my.php?image=gamepreviewqh4.jpg][img=http://img166.imageshack.us/img166/198/gamepreviewqh4.th.jpg][/url]

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.
SirSmiley
Reply #1 Tuesday, October 10, 2006 5:36 PM
This is the image. Didn't want to mess up the code.


Free Image Hosting at www.ImageShack.us
rabidrobot
Reply #2 Tuesday, October 10, 2006 6:20 PM
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.


SirSmiley
Reply #3 Tuesday, October 10, 2006 9:11 PM
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.

Please login to comment and/or vote for this skin.

Welcome Guest! Please take the time to register with us.
There are many great features available to you once you register, including:

  • Richer content, access to many features that are disabled for guests like commenting on the forums and downloading skins.
  • Access to a great community, with a massive database of many, many areas of interest.
  • Access to contests & subscription offers like exclusive emails.
  • It's simple, and FREE!



web-wc01