Skip to content
This repository has been archived by the owner on Apr 8, 2021. It is now read-only.

CardCustom never finishes loading according to loading_custom #15

Open
Benjamin-Dobell opened this issue Dec 17, 2019 · 1 comment
Open
Labels
bug Something isn't working lua Lua scripting

Comments

@Benjamin-Dobell
Copy link
Member

Benjamin-Dobell commented Dec 17, 2019

Describe the bug

When spawning a custom CardCustom using spawnObjectJSON, loading_custom remains as true indefinitely i.e. after the card texture has visibly loaded.

To Reproduce

  1. Create a new Single Player game, dismiss the Load prompt to use the default empty scene.
  2. Open the Scripting editor and paste the Lua attached below into Global.
  3. Hit "Save & Play".

Expected behavior

Should see in Game chat tab:

Loading complete for Card
Loading complete for CardCustom

Actual behavior

Instead seeing:

Loading complete for Card
Loading failed to complete for CardCustom. spawning = false, loading_custom = true

Lua Scripts:

Global:

local function waitUntilLoadedCallback(object)
    Wait.condition(function()
        local name = JSON.decode(object.getJSON()).Name
        print('Loading complete for ' .. name)
    end, function()
        return not object.spawning and not object.loading_custom
    end, 10, function()
        local name = JSON.decode(object.getJSON()).Name
        print('Loading failed to complete for ' .. name .. '. spawning = ' .. tostring(object.spawning) .. ' loading_custom = ' .. tostring(object.loading_custom))
    end)
end

function onLoad()
    local jsonRepresentation = {
      Name = "Card",
      Transform = {
        posX = 0,
        posY = 3,
        posZ = 0,
        rotX = 0,
        rotY = 180,
        rotZ = 0,
        scaleX = 1,
        scaleY = 1.2,
        scaleZ = 1.4
      },
      Nickname = "Test Card",
      Hands = true,
      CardID = 2111,
      CustomDeck = {
        ["21"] = {
          FaceURL = "https://kb.tabletopsimulator.com/img/custom-deck/template-sheet.png",
          BackURL = "https://kb.tabletopsimulator.com/img/custom-deck/template-sheet.png",
          NumWidth = 10,
          NumHeight = 7,
          BackIsHidden = true,
          UniqueBack = true
        }
      }
    }

    spawnObjectJSON({
        json = JSON.encode(jsonRepresentation),
        callback_function = waitUntilLoadedCallback
    })

    jsonRepresentation.Name = "CardCustom"
    jsonRepresentation.Transform.posX = 2

    spawnObjectJSON({
        json = JSON.encode(jsonRepresentation),
        callback_function = waitUntilLoadedCallback
    })
end

Tabletop Simulator Info (please complete the following information):

  • OS: macOS
  • Version: v12.2.2-12.2.13

Known workarounds

None.

Additional context

Likely arose in 12.2.2 as changes were made in this area to attempt to address #12.

@Benjamin-Dobell Benjamin-Dobell added bug Something isn't working lua Lua scripting labels Dec 17, 2019
@Benjamin-Dobell Benjamin-Dobell changed the title CustomCard never finishes loading according to loading_custom CardCustom never finishes loading according to loading_custom Dec 17, 2019
@apachano
Copy link

Just noting that this still happens on 12.4.3 - in Linux :(

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working lua Lua scripting
Projects
None yet
Development

No branches or pull requests

2 participants