Results 1 to 5 of 5

Thread: Putting cards into decks makes a lot of functions break

  1. #1

    Putting cards into decks makes a lot of functions break


    I've been writing a large script for 7 Wonders board game to make it fully automized.

    I released my work over 2 months ago but lately I have seen some bug reports and worked to fix them. While working on the fix I encountered the most bizarre issue since I started writing this script. Apparently, when you put 2 cards on each other and form a deck, then put them back in your hand, they stop responding to at least half of the scripting functions. I will explain what I exactly tried and what were the results.

    Here's the link for the script in debug mode so you can reproduce what I'm writing here on your own:
    Here's the link for the original script that I'm trying to fix:

    After the game loads click "start the game", 3 players receive 7 cards to their hands. The script at that time saves those cards' in a table for future reference (named players_hand in the script).
    When you put one of your cards on the tile and click "confirm" all the cards will jump into the air and fall where they were previously(I did that just to test their behavior).
    You can then click "confirm" again to unconfirm your choice etc. etc. (the reasons behind the design of this script can be found in the link to the steam workshop).

    So here's the bizarre part. Restart the script and click "start the game", then put any two cards from your hand next to it and make a deck from them. Then put them back again in your hand.
    After this when you choose a card from your hand and click "confirm" the script will break on the command to get the current position of one of the cards (getPosition).

    So what actually happens in the script: When you click confirm the script will try to change position of every card that was saved in players_hand table. I checked and after putting cards in the deck and returning them to the hand their guids stay the same and the reference to them is still there in the players_hand table. What's even better, the script also writes the guid of every card on the chat before trying to get their current location and the cards that were in the deck do still have the same guid and script will write their guids correctly before crashing on trying to use "getPosition" function. I tried using "setLock" instead of "setPosition"+"getPosition" and that function doesn't crash the script but instead doesn't do anything with the cards that were in the deck previously.

    I am completely oblivious to the reasons behind this behavior. I am not sure if it's some kind of game bug or if there is something wrong with my code, anyway there are no events/functions used on making a new deck from 2 cards.

    Help/feedback will be greatly appreciated

    PS: In the debug script check line 756 for the part that crashes the script.
    Last edited by Fanderman; 08-30-2017 at 12:18 PM.

  2. #2
    You do know that stacking cards destroys them, and if you break that stack (deck) again they will not be same objects they were before?

    Try to create a minimal example of this behavior. Just the thing that breaks.

  3. #3
    Actually I think that could explain this behavior. Though it's pretty strange that they still give those cards the same guid. Since the cards put from the deck are no longer the same cards, the reference to cards from which the deck was created could no longer move these cards since they no longer exist within the game board but they still have their guid so it can write it.
    Though there is another question, how to update those cards' reference within the script whenever they are put in a deck?

  4. #4
    When they are put in the deck, they are destroyed - you can't get a reference that points to them. When they are then drawn from a deck, they will retain old GUID *if no other object already took it*, but they will spawn as brand new objects.

    You can capture cards leaving decks using onObjectLeaveContainer(container, object).

  5. #5
    Alright then, problem solved.

Similar Threads

  1. Decks, Cards, and Scripting
    By DopeGhoti in forum Scripting
    Replies: 10
    Last Post: 04-21-2016, 01:31 PM
  2. Putting down a hand of cards
    By Spheniscine in forum Suggestions
    Replies: 0
    Last Post: 04-20-2016, 03:52 PM
  3. [ADDED] High resolution cards (built from decks not required to be 10x7 cards)
    By SwiftIllusion in forum Suggestions
    Replies: 11
    Last Post: 12-22-2015, 12:00 AM
  4. Tuckboxes for decks of cards.
    By HeungWeiLo in forum General Discussion
    Replies: 1
    Last Post: 03-24-2015, 08:21 AM
  5. Many decks of cards RAM usage
    By em in forum General Discussion
    Replies: 5
    Last Post: 06-13-2014, 05: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