Results 1 to 8 of 8

Thread: Need a better way handle one line of code inside of multiple cards (1000+ cards)

  1. #1

    Need a better way handle one line of code inside of multiple cards (1000+ cards)

    I am currently scripting a game that has a ton of cards in it around 4.5k (includes all the game's expansions).
    As you play the game certain cards add to your combat power and then display your total onto a counter. I have the global script reading the cards and a script inside the cards that looks like this
    --Card Name
    cp = #

    After I went through and named all the cards and add the line of code to each card that needed it I started playing with friends only to find out that some decks had randomly deleted or copied over the scripts that I had put in there.
    Example: I would play monster A who has a cp of 3 but the counter would show 5. I'd look into the script and see it had monster B's code in it and then I'd fine monster B's code in almost all the cards in that deck.
    This bug has happened twice now.

    Someone mentioned to me about making a spread sheet and using that to organize all the cards' cps. But I have no idea how to do that.
    If you have an idea on how to handle lots of small scripts please let me know and send a link to some examples or tutorials.

  2. #2
    By the way, do you really need one line script in each? If cards names are unique, you could just define CP for each name e.g. in Global script. If they aren't secret, you could add them to cards description.

  3. #3
    Join Date
    May 2016
    Easy solution, make a big table with the card name (like dzik said) and associate it with a value. Like:

    cardList = {
        ["Name of Card"] = 50,
        ["Different Name"] = 35,
        (etc etc you get the idea)
    Then when detecting a card you want, you just use its name to fetch from the table.

    attackPower = cardList[card.getName()]

  4. #4
    Yeah I'm probably going to do that. It's just a big task and I feel so defeated after thinking I had finished it

    - - - Updated - - -

    Putting it in the description would be fine but can you use the description as an Int value? I thought it was a string? I'll have to play around with it some.

  5. #5
    @Mr. Crzy
    You can do
    local cp = tonumber(card.getDescription())
    to convert between strings and numbers (base 10 is default).

  6. #6
    Join Date
    May 2016
    Also string are pretty fluid in Lua. Often you can have it act as a number or string on the fly

  7. #7
    wish I had known that from the get go.
    Thank you!

  8. #8
    Join Date
    Sep 2017
    Note also that if you save a card or deck using "save object" context menu,
    you get a file stuff,JSON in your saved object folder, which you can edit with
    the atom editor to insert or change many of the card properties including name
    and description.

Similar Threads

  1. Why doesn't my code correctly count deck cards?
    By AgentElrond in forum Scripting
    Replies: 1
    Last Post: 01-08-2018, 02:15 PM
  2. Replies: 0
    Last Post: 07-06-2017, 09:28 AM
  3. Replies: 3
    Last Post: 06-28-2017, 02:22 AM
  4. Edit cards inside of a deck
    By Elemental in forum Suggestions
    Replies: 0
    Last Post: 10-12-2016, 04:13 AM
  5. Replies: 0
    Last Post: 04-05-2016, 01:31 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