From fa4d1f428d6698f894b14a4e8ce2417724cd7f88 Mon Sep 17 00:00:00 2001 From: Buhallin Date: Mon, 14 Nov 2022 02:02:18 -0800 Subject: [PATCH] Finish some missed cleanup and fix a bug with deck size --- src/playercards/CardSearch.ttslua | 20 ++++++-------------- src/playercards/PlayerCardSpawner.ttslua | 8 +++++++- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/playercards/CardSearch.ttslua b/src/playercards/CardSearch.ttslua index a768ea9f..9c179f1d 100644 --- a/src/playercards/CardSearch.ttslua +++ b/src/playercards/CardSearch.ttslua @@ -32,7 +32,7 @@ inputParameters.width = 1200 inputParameters.height = 130 inputParameters.font_size = 107 -local allCardsBag = getObjectFromGUID("15bb07") +local ALL_CARDS_GUID = "15bb07" -- main code function onSave() return JSON.encode({ spawnAll, searchExact, inputParameters.value }) end @@ -102,6 +102,7 @@ function search() return end + local allCardsBag = getObjectFromGUID(ALL_CARDS_GUID) if allCardsBag == nil then printToAll("Player card bag couldn't be found.", "Red") return @@ -113,6 +114,10 @@ function search() printToAll("No match found.", "Red") return end + if (#cardList > 100) then + printToAll("Matched more than 100 cards, please try a more specific search.", "Yellow") + return + end -- sort table by name (reverse for multiple results, because bottom card spawns first) table.sort(cardList, function(k1, k2) return spawnAll == (k1.data.Nickname > k2.data.Nickname) end) @@ -120,17 +125,4 @@ function search() local rot = self.getRotation() local pos = self.positionToWorld(Vector(0, 2, -0.225)) Spawner.spawnCards(cardList, pos, rot, true) - -- for _, card in ipairs(cardList) do - -- pos[2] = pos[2] + 0.1 - -- spawnObjectData({ - -- data = card.data, - -- position = pos, - -- rotation = rot - -- }) - -- if not spawnAll then return end - -- if i == 100 then - -- printToAll("Only first 100 results of " .. #cardList .. " total results spawned.", "Yellow") - -- return - -- end - -- end end diff --git a/src/playercards/PlayerCardSpawner.ttslua b/src/playercards/PlayerCardSpawner.ttslua index 32f635a2..d0e1eef6 100644 --- a/src/playercards/PlayerCardSpawner.ttslua +++ b/src/playercards/PlayerCardSpawner.ttslua @@ -51,7 +51,6 @@ Spawner.spawn = function(cardList, pos, rot, callback) end -- Spawn a single card directly if (#cardList == 1) then - log(pos) spawnObjectData({ data = cardList[1].data, position = pos, @@ -62,6 +61,13 @@ Spawner.spawn = function(cardList, pos, rot, callback) end -- For multiple cards, construct a deck and spawn that local deck = Spawner.buildDeckDataTemplate() + -- Decks won't inherently scale to the cards in them. The card list being spawned should be all + -- the same type/size by this point, so use the first card to set the size + deck.Transform = { + scaleX = cardList[1].data.Transform.scaleX, + scaleY = 1, + scaleZ = cardList[1].data.Transform.scaleZ, + } for _, spawnCard in ipairs(cardList) do Spawner.addCardToDeck(deck, spawnCard.data) end