Results 1 to 2 of 2

Thread: Scripting Cards for my game

  1. #1

    Exclamation Scripting Cards for my game

    Alright, so I'm new to the whole scripting thing and honestly I have no idea how it works.
    Anyways, here's how my game functions.
    Each card has a cost, and an end game value.
    I would love to be able to script each card's end game value so that at the end of the game users don't have to total up the points, it just has it set already.
    I would also love to script the cards in their hand so that a counter already has a total for value in their hand.
    This is the game link:

  2. #2
    If the cards are or can be named (some unique string for each card, can be same if they're identical, can be put as description too), you could build a table of values
    local values = {
        ['Simba'] = 5,
        ['Ariel'] = 13,
        ['Mr. Incredible'] = 8,
        -- and so on
    and use this to calculate and sum cards value. For example, if they're named and you want to tally up Green hand:

    function testTallyUpGreen()
        local sum = 0
        -- get his hand
        local heldCards = Player.Green.getHandObjects()
        -- iterate over each object in hand
        for i,card in ipairs(heldCards) do
            -- if card has a value, add it (warn if not, delete this if you want)
            local cardValue = values[card.getName()]
            if cardValue then
                sum = sum + cardValue
                print('Unrecognized card: ' .. card.getName())
        print('Green hand value is: ' .. sum)

Similar Threads

  1. Replies: 12
    Last Post: 08-18-2018, 01:56 AM
  2. Replies: 3
    Last Post: 05-19-2018, 02:01 AM
  3. Replies: 12
    Last Post: 09-14-2017, 05:51 AM
  4. In-Game Scripting Tools
    By MrStump in forum Scripting
    Replies: 10
    Last Post: 02-10-2017, 02:52 PM
  5. Decks, Cards, and Scripting
    By DopeGhoti in forum Scripting
    Replies: 10
    Last Post: 04-21-2016, 01:31 PM

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