Results 1 to 3 of 3

Thread: Problem with Cloning a multi state object

  1. #1

    Problem with Cloning a multi state object

    Hello everyone, I hope someone can help me.

    I have written a script that will take an custom card object with 2 states and make a clone of it.
    It then takes the clone and gives it new front and back images, a new name and description, it then changes the state and gives the other state new images, name and description as well.

    This all works and my clone is generated

    my problem is after the code is done there is a third object with both states details set to the same as the second state.

    here is the relevant section of my code.

    Code:
    CardToClone = getObjectFromGUID("GUID")
    local cloneParams = {}
    -- set up to clone of card with states the custom card with states
    cloneParams.position = NewCardPosition
    -- create the clone of the card with states
    NewCard = CardToClone.clone(cloneParams)
    local NewCardParams = {}
    -- set up the front and back face url of the first state
    NewCardParams.face = Image_URL_face1
    NewCardParams.back = Image_URL_back
    -- set the clones images
    NewCard.SetCustomObject(NewCardParams)
    -- set the name of first state
    NewCard.SetName(Name1)
    -- set description of first state
    NewCard.setDescription(Description1)
    -- Change state to the other card
    NewCard.setState(2)
    -- set up the front and back face url of the second state
    NewCardParams.face = Image_URL_face2
    NewCardParams.back = Image_URL_back
    -- set the clones images
    NewCard.SetCustomObject(NewCardParams)
    -- set the name of the second state
    NewCard.SetName(Name2)
    -- set description of the second state
    NewCard.setDescription(Description2)
    -- set state back to the first state
    --NewCard.setState(1)

  2. #2
    Join Date
    Sep 2017
    Posts
    396
    Not sure how or why this could happen; I suggest breaking up the procedure into individual steps and see when and where the extra object appears; I recall that in some circumstances you need to do an object.reload() but I don't see how leaving it out could imply an extra spawn. Definitely looks like a bug to me.

  3. #3
    Thanks for the advice cche. It was the .setState that was creating the duplicate.

    I have sort managed to remove the bug by using
    Code:
    NewCard = NewCard.setState(#)
    when changing states and spawning the card out of position and moving it to the right place at the end. I have no idea why moving it helps but it does appear to prevent the .setState from spawning a duplicate.

Similar Threads

  1. [SOLVED] Tutorial: Custom Multi State Objects (How To Make And Use)
    By LordAshes in forum General Discussion
    Replies: 0
    Last Post: 09-08-2019, 09:04 PM
  2. [ADDED] [v8.7] Gizmo capable of multi-object adjustments
    By Cluny in forum Suggestions
    Replies: 4
    Last Post: 02-17-2017, 08:52 PM
  3. [ADDED] Shuffle lock option on multi-state
    By Kragin in forum Suggestions
    Replies: 7
    Last Post: 12-08-2016, 10:51 AM
  4. Replies: 2
    Last Post: 09-17-2016, 03:33 PM
  5. Allow multi object placement from bags
    By Wakke in forum Suggestions
    Replies: 2
    Last Post: 02-14-2016, 03:46 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •