load skin from dropped on card

This commit is contained in:
Chr1Z93 2023-08-22 01:05:08 +02:00
parent a81cfe22ed
commit ccda7d7592

View File

@ -51,7 +51,7 @@ local BACKGROUNDS = {
fontcolor = { 1, 1, 1 } fontcolor = { 1, 1, 1 }
}, },
{ {
title = "Subject 5U-21 (Suzi)", title = "Subject 5U-21",
url = "http://cloud-3.steamusercontent.com/ugc/2021606446228199363/CE43D58F37C9F48BDD6E6E145FE29BADEFF4DBC5/", url = "http://cloud-3.steamusercontent.com/ugc/2021606446228199363/CE43D58F37C9F48BDD6E6E145FE29BADEFF4DBC5/",
fontcolor = { 1, 1, 1 } fontcolor = { 1, 1, 1 }
}, },
@ -99,6 +99,44 @@ function getFontColor()
return { 1, 1, 1 } return { 1, 1, 1 }
end 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 -- called by context menu to change background image
function selectImage(color) function selectImage(color)
-- generate list of options -- generate list of options