diff --git a/src/accessories/AttachmentHelper.ttslua b/src/accessories/AttachmentHelper.ttslua index 0f187c8a..1d32e047 100644 --- a/src/accessories/AttachmentHelper.ttslua +++ b/src/accessories/AttachmentHelper.ttslua @@ -51,7 +51,7 @@ local BACKGROUNDS = { fontcolor = { 1, 1, 1 } }, { - title = "Subject 5U-21 (Suzi)", + title = "Subject 5U-21", url = "http://cloud-3.steamusercontent.com/ugc/2021606446228199363/CE43D58F37C9F48BDD6E6E145FE29BADEFF4DBC5/", fontcolor = { 1, 1, 1 } }, @@ -99,6 +99,44 @@ function getFontColor() return { 1, 1, 1 } end +-- attempt to load image from below card when dropped +function onDrop(playerColor) + local pos = self.getPosition():setAt("y", 2) + local search = Physics.cast({ + direction = { 0, -1, 0 }, + max_distance = 2, + type = 3, + size = { 0.1, 0.1, 0.1 }, + origin = pos + }) + + local syncName + for _, v in ipairs(search) do + if v.hit_object.tag == "Card" then + syncName = v.hit_object.getName() + break + end + end + + if not syncName then return end + + -- remove level information fron syncName + syncName = syncName:gsub("%s%(%d%)", "") + + -- loop through background table + for _, bgInfo in ipairs(BACKGROUNDS) do + if bgInfo.title == syncName then + printToColor("Background for '" .. syncName .. "' loaded!", playerColor, "Green") + local customInfo = self.getCustomObject() + customInfo.diffuse = bgInfo.url + self.setCustomObject(customInfo) + self.reload() + return + end + end + printToColor("Didn't find background for '" .. syncName .. "'!", playerColor, "Orange") +end + -- called by context menu to change background image function selectImage(color) -- generate list of options