Results 1 to 3 of 3

Thread: Trying to copy and clone cards from one deck into another deck

  1. #1

    Cool [SOLVED] Trying to copy and clone cards from one deck into another deck

    Thank you for taking the time to read my post.

    I am trying to copy and clone (custom) cards from one deck into another deck.

    The two decks are of the same kind. Doing it "by hand" works.

    Here is my code:

    UI: <Button rectAlignment="UpperRight" height="20" width="100" offsetXY="0 -120" onClick="initialize" >Initialize</Button>

    Code:
    function initialize()
        print("Initializing cards.")
    
        deck_randomunits = getObjectFromGUID('2690ab')
        deck_basicunits = getObjectFromGUID('f292b1')
    
        deck_randomunits.shuffle()
        for i = 1, 8 do
            card = deck_randomunits.takeObject({smooth=false})
            deck_basicunits.putObject(card)
            --deck_basicunits.putObject(card)
            deck_basicunits.putObject(card.clone({position=deck_basicunits.getPosition()}))
        end
        deck_basicunits.clone()
        deck_randomunits.destruct()
    
    
        --print(#deck_randomunits.getObjects())
    end
    The problem is that white zombie cards appear.
    If I take out the line cloning the cards it seems to work but I need two of each random card in the target deck.

    Any and all help would be very much appreciated.

    Last edited by paranoidray; 05-05-2019 at 01:37 AM.

  2. #2
    This doesn't work either:

    Code:
    deck_randomunits = getObjectFromGUID('0c1e03')
    deck_basicunits = getObjectFromGUID('9a38ec')
    ro = deck_randomunits.getObjects()
    bo = deck_basicunits.getObjects()
    table.insert(ro, bo[1])
    nor

    Code:
    t = r.takeObject({smooth=true})
    b.putObject(t)
    b.putObject(t)
    Last edited by paranoidray; 05-05-2019 at 01:33 AM.

  3. #3
    The problem was the order of things!
    You can't clone a card AFTER it was put into another deck.
    But you CAN clone a card BEFORE!
    That makes sense in hindsight of course...

    Here is the working test code:

    Code:
        deck_randomunits = getObjectFromGUID('0c1e03')
        deck_basicunits = getObjectFromGUID('9a38ec')
        r = deck_randomunits
        b = deck_basicunits
    
        ro = deck_randomunits.getObjects()
        bo = deck_basicunits.getObjects()
        
        t = r.takeObject({smooth=true})
        tc = t.clone()
        b.putObject(t)
        b.putObject(tc)
    And here is the working code:

    Code:
    function initialize()
        print("Initializing cards.")
    
        deck_randomunits = getObjectFromGUID('0c1e03')
        deck_basicunits = getObjectFromGUID('9a38ec')
    
        deck_randomunits.shuffle()
        for i = 1, 8 do
            card = deck_randomunits.takeObject({smooth=false})
            deck_basicunits.putObject(card.clone())
            deck_basicunits.putObject(card)
        end
        deck_basicunits.clone({position={x=1, y=1, z=10}})
        deck_randomunits.destruct()
    
    
        --print(#deck_randomunits.getObjects())
    end
    Last edited by paranoidray; 05-05-2019 at 02:08 AM.

Similar Threads

  1. Replies: 2
    Last Post: 12-05-2017, 11:26 AM
  2. Replies: 1
    Last Post: 11-10-2016, 06:05 PM
  3. Replies: 2
    Last Post: 07-07-2016, 05:15 PM
  4. Ungrouping a Deck of Cards
    By Eric in forum General Discussion
    Replies: 1
    Last Post: 11-16-2015, 01:14 PM
  5. Replies: 3
    Last Post: 06-02-2015, 07:57 AM

Tags for this Thread

Posting Permissions

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