From 6f87e9c1e8697a2e0b8e31fe7f52ac39ca2d12a9 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Sun, 6 Oct 2024 12:54:26 +0200 Subject: [PATCH] Added support for ID searching --- objects/Search-A-Card.24051a.json | 6 ++--- ...CardSearch.ttslua => Search-A-Card.ttslua} | 22 ++++++++++--------- 2 files changed, 15 insertions(+), 13 deletions(-) rename src/playercards/{CardSearch.ttslua => Search-A-Card.ttslua} (89%) diff --git a/objects/Search-A-Card.24051a.json b/objects/Search-A-Card.24051a.json index bfb882d5..b154bbaa 100644 --- a/objects/Search-A-Card.24051a.json +++ b/objects/Search-A-Card.24051a.json @@ -33,7 +33,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": true, - "LuaScript": "require(\"playercards/CardSearch\")", + "LuaScript": "require(\"playercards/Search-A-Card\")", "LuaScriptState": "[true,false,\"\"]", "MeasureMovement": false, "Name": "Custom_Tile", @@ -48,9 +48,9 @@ "rotX": 0, "rotY": 270, "rotZ": 0, - "scaleX": 4, + "scaleX": 4.5, "scaleY": 1, - "scaleZ": 4 + "scaleZ": 4.5 }, "Value": 0, "XmlUI": "" diff --git a/src/playercards/CardSearch.ttslua b/src/playercards/Search-A-Card.ttslua similarity index 89% rename from src/playercards/CardSearch.ttslua rename to src/playercards/Search-A-Card.ttslua index 2aca432e..4384a600 100644 --- a/src/playercards/CardSearch.ttslua +++ b/src/playercards/Search-A-Card.ttslua @@ -11,15 +11,15 @@ BUTTON_LABELS["search"][true] = "Name equals search term" BUTTON_LABELS["search"][false] = "Name contains search term" local inputParameters = {} -inputParameters.label = "Click to enter card name" +inputParameters.label = "Enter name / ID" inputParameters.input_function = "input_func" inputParameters.function_owner = self inputParameters.alignment = 2 -inputParameters.position = { x = 0, y = 0.1, z = -0.62 } -inputParameters.width = 3750 -inputParameters.height = 380 -inputParameters.font_size = 350 -inputParameters.scale = { 0.1, 1, 0.1 } +inputParameters.position = { x = 0, y = 0.1, z = -0.6 } +inputParameters.width = 3500 +inputParameters.height = 450 +inputParameters.font_size = 400 +inputParameters.scale = { 0.12, 1, 0.12 } inputParameters.color = { 0.9, 0.7, 0.5 } inputParameters.font_color = { 0, 0, 0 } @@ -103,11 +103,13 @@ function startSearch() return end - -- if the search string is a number, assume it's an ID and spawn the card directly - if tonumber(inputParameters.value) then + -- if the search string doesn't contain whitespace, attempt to treat it as ID + if not string.find(inputParameters.value, "%s") then local singleCard = allCardsBagApi.getCardById(inputParameters.value) - spawnCardList({ singleCard }) - return + if singleCard ~= nil then + spawnCardList({ singleCard }) + return + end end -- search all objects in bag