Mixing up objects [SOLVED]

K.V.

I have 5 objects in a container.

o1, o2, o3, o4, and o5.

There is a menu, which goes like this:

  ShowMenu("Pick an object.", GetDirectChildren(container), false){
    MoveObject(GetObject(result,new_container1)
    ShowMenu("Pick an object.", GetDirectChildren(container), false){
      MoveObject(GetObject(result,new_container2)
      ShowMenu("Pick an object.", GetDirectChildren(container), false){
        MoveObject(GetObject(result,new_container3)
        ShowMenu("Pick an object.", GetDirectChildren(container), false){
          MoveObject(GetObject(result,new_container4)
          ShowMenu("Pick an object.", GetDirectChildren(container), false){
            MoveObject(GetObject(result,new_container5)
          }
        }
      }
    }
  }

What's the most efficient way to randomly mix up that list order (each time this script runs, not each ShowMenu)?

Right now, I've got this, and it doesn't work:

  objectlist = NewObjectList()
  list add (objectlist, o1)
  list add (objectlist, o2)
  list add (objectlist, o3)
  list add (objectlist, o4)
  list add (objectlist, o5)
  foreach (o, objectlist) {
    o.parent = objectholder
  }
  for (i, 1, 5) {
    o = PickOneObject(GetDirectChildren(objectholder))
    o.parent = container
  }
  ShowMenu("Pick an object.", GetDirectChildren(container), false){
    MoveObject(GetObject(result,new_container1)
    ShowMenu("Pick an object.", GetDirectChildren(container), false){
      MoveObject(GetObject(result,new_container2)
      ShowMenu("Pick an object.", GetDirectChildren(container), false){
        MoveObject(GetObject(result,new_container3)
        ShowMenu("Pick an object.", GetDirectChildren(container), false){
          MoveObject(GetObject(result,new_container4)
          ShowMenu("Pick an object.", GetDirectChildren(container), false){
            MoveObject(GetObject(result,new_container5)
          }
        }
      }
    }
  }

I suspect it doesn't work because Quest is still reading each object in order and checking its parent during the GetDirectChildren() function.


When you get a list with GetDirectChildren objects are ordered according to where they appear in the .aslx file. When you set an object's parent, it does not really change where it is, it only changes the attribute so it seems like it is somewhere else.

Add the objects to an object list to get the order changed.

There is also an issue that an object can be chosen more than once, so the best way is to copy into and object list, then randomly pick from the list into a new list, and delete the chosen object from the first list to stop it getting chosen again.


K.V.

Thanks, Pixie.

I didn't think there was a way without using numerous lists, most of which would need to be reset or altered after each choice.

This one will just have to be in the same order each game. (It'll be fine that way. I was just trying to add some flair.)


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums