Results 1 to 6 of 6

Thread: Script to place a card IN a deck either on top or bottom?

  1. #1

    Script to place a card IN a deck either on top or bottom?

    is there a way to script an object to be placed INTO a existing deck.. either on top or bottom or w/e?

    Like do I have to physically pick up the dekc and drop it on the card to put on bottom or draw the top 5 cards, place the can on the deck and then drop those 5 cards back on top to place a card in 6 position of deck?

    Of can you just place it directly into the deck at a given point?
    Last edited by Tragic; 07-14-2017 at 05:44 PM.

  2. #2
    AFAIK the former; you have to manually pick up the cards you want over it, put it over the rest, and let them all fall together.

    (it'd be really nice if putObject would take an optional position parameter...)

  3. #3

    Quote Originally Posted by onelivesleft View Post
    (it'd be really nice if putObject would take an optional position parameter...)

  4. #4
    Join Date
    Sep 2017
    With decks, you can use deck.cut() to divide the deck at an arbitrary location, and then reassemble the pieces with the new items. See for details.

  5. #5
    Please someone add an API function to slide a card into position X of a deck e.g. "position zero" could be add to the top and no specified position ( or a number greater than the number of cards in the deck ) would be add to the bottom

  6. #6
    Join Date
    Sep 2017

    Try this

    function insertInto(container, obj, offset) 
        if container != nil then -- we have a bag or deck
            local contents = container.getData()
            -- container.destroy() -- enable once test log shows correct result
            log(contents) -- check the exact name of the contained objects table
            local items = contents.contained_objects  -- might need to check if contained_objects is missing...
            if offset > #items then
                offset = #items + 1
            table.insert(items, obj, offset) -- this actually inserts obj into contents.contained_items because items is a reference.
            return spawnObjectData(contents) -- returns reference to new bag with additional object.
            print(logString(container), ": not a container")
            return nil
    purports to do the trick; no special API needed.

Similar Threads

  1. Drawing bottom card sometimes shuffles deck
    By Jabrwock in forum Bug Reports
    Replies: 4
    Last Post: 04-20-2017, 09:56 AM
  2. Prevent deck from moving (and still add cards to bottom)
    By TokMor in forum General Discussion
    Replies: 0
    Last Post: 03-30-2017, 03:06 PM
  3. [SOLVED] Put on the bottom of the deck bug
    By DarkPhoenix in forum Technical Support
    Replies: 3
    Last Post: 12-26-2015, 05:24 PM
  4. Replies: 1
    Last Post: 12-23-2014, 06:07 PM
  5. [ADDED] [v2.2] Place card on bottom of deck
    By Grimshad in forum Suggestions
    Replies: 6
    Last Post: 11-20-2014, 12:55 PM

Posting Permissions

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