Results 1 to 7 of 7

Thread: Dealing cards from a zone

  1. #1

    Dealing cards from a zone

    Hi there,

    I'm new to scripting, and have had reasonable success at doing some basic stuff... but this one is foxing me. I have read many posts but can't seem to do what I would assume is quite basic in the grand scheme of things!

    What I want to do is deal cards from a scripted zone.

    I've scripted a cleanup, that pulls all the cards back to a place in the zone.
    And I separately scripted dealing to hands on another game with a static deck so understand the basics of dealing.

    What I can't seem to do is combine these two. I believe that that deck GUID changes when rebuilt, so I can't rely on that... that I need a scripting zone. I've setup a scripting zone and have its GUID....

    But could someone help me with that last connection please? How to deal from the scripted zone.

    Thanks in advance.

  2. #2
    Join Date
    May 2020
    on the earth
    As i understood you, you are able to deal cards from the script zone, or?

    If you dont know the GUID, you can use the function
    getObjects() Returns a Table of Objects in the script zone/bag/deck.
    to determine the GUID of the deck. i guess that should do it. API:

  3. #3
    More the opposite, I'm trying to put all the cards back in a zone.

    i say zone because as I understand it there is no 'deck' per se after they are dealt, they are all individual GUIDs.

    But my ultimate aim is to take all the cards on the table and put them back into a deck for the next round.


  4. #4
    Join Date
    May 2020
    on the earth
    you actually want to group the cards together to get a deck... in that case you need the group() function API:

  5. #5
    Thanks... I have looked into that, but cant seem to work out how to extrapolate that into grouping all cards of one description back into a deck.

  6. #6
    Join Date
    May 2020
    on the earth
    if you can post a small example, I can look into it, because currently I cant imagine what's causing the difficulties.

  7. #7
    Join Date
    Sep 2017

    sample code to locate all cards from two different decks and reassemble the decks.

        local deck1Pos = {x = 5, y = 5, z = 2} -- set this to the location where you want your deck to end up.  the Y coord should be 2 + the eventual height of the deck.
        local deck2Pos = {x = -5, y = 5, z = 2} -- position of another deck
        for _, obj in ipairs(getAllObjects()) do
            if obj.tag == "Card" or obj.tag == "Deck" then
                local desc = getCardType(obj)
                if #desc <= 2 then -- the standard deck has CardID values of 2 characters. 
                       -- other decks have a CardID with a deckID prefixed. You will need to discover the best way to distinguish your decks
                    deck1Pos.y = deck1Pos.y + obj.getBounds().size.y
                    deck2Pos.y = deck2Pos.y + obj.getBounds().size.y
    function getCardType(obj)
        local json = obj.getJSON()
        local cardID, _ = string.match(json, "\"CardID\": (%w*)")
        print(cardID) -- use this output to discover what your CardID values are.
        return cardID

Similar Threads

  1. onObjectLeaveContainer only called for first card when dealing several cards
    By Benjamin Dobell in forum Scripting Bug Reports
    Replies: 0
    Last Post: 11-06-2018, 09:56 AM
  2. Replies: 0
    Last Post: 10-24-2018, 01:03 AM
  3. cards in hand zone float above the table
    By springboard in forum Scripting
    Replies: 3
    Last Post: 06-11-2018, 11:01 PM
  4. Replies: 1
    Last Post: 01-09-2018, 08:17 PM
  5. Dealing Cards and Hand Zones
    By TehCupcakes in forum Bug Reports
    Replies: 2
    Last Post: 11-08-2016, 07:24 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