HOME ➔ SUPPORT ➔ Community ➔ General CourseLab issues ... Managing object identifiers through variables
Managing object identifiers through variables
  View type:
I have 12 objects whose identifiers are numbers from 1 to 12. I want to make another object move over each of them depending on the value of a variable named N, using the .x and .y properties of those object and the move action. How can I use the value of the variable N to build the line MOVE-START (Object='pawn',X='$identifier.x',Y=$identifier.y') making it insert the value of the variable N in place of "identifier"?
Something to remember is that actions aren't a part of a full programming language so there are gaps in their capibilities. So looking at what you want to do...
Getting the x y coordinates for the move will be the first problem, these will be in the XML that generates the page and will be the top left corner of the object so might not be quite where you want the object to move to. Parsing XML files of the type used can be less than easy.
So you think I'll just have an array with that data in it. Directly you can;t do that with actions, you might with some javascript.
I'd be tempted to do this a little differently.
Once you've determined what your trigger event is just set up a series of IF actions that check your variable N's value against another number representing the objects. You follow this with an indented MOVE-START to move your chosen object to the specific object.
You'd need one of these for each move to an object. It's a bit long winded but would take you 5-10 minutes to set up. Trying to do this more programtically will take you much longer!!
Message options
No additional options