first batch of player cards updates
This commit is contained in:
parent
832b8a24df
commit
ca214f7ecd
@ -8,10 +8,11 @@ buttonParamaters.width = 700
|
||||
buttonParamaters.height = 700
|
||||
|
||||
local altState = false
|
||||
local MODE = { [false] = "Add / Remove", [true] = "Take / Return" }
|
||||
local BUTTON_COLOR = { [false] = { 0.4, 0.4, 0.4 }, [true] = { 0.9, 0.9, 0.9 } }
|
||||
local FONT_COLOR = { [false] = { 1, 1, 1 }, [true] = { 0, 0, 0 } }
|
||||
local MODE = { [false] = "Add / Remove",[true] = "Take / Return" }
|
||||
local BUTTON_COLOR = { [false] = { 0.4, 0.4, 0.4 },[true] = { 0.9, 0.9, 0.9 } }
|
||||
local FONT_COLOR = { [false] = { 1, 1, 1 },[true] = { 0, 0, 0 } }
|
||||
local whitespace = " "
|
||||
local updating
|
||||
|
||||
---------------------------------------------------------
|
||||
-- creating buttons and menus + initializing tables
|
||||
@ -122,8 +123,8 @@ function doRemove(color)
|
||||
end
|
||||
end
|
||||
|
||||
broadcastToColor("Removed " .. count["Bless"] .. " Bless and " ..
|
||||
count["Curse"] .. " Curse tokens from the chaos bag.", color, "White")
|
||||
broadcastToColor("Removed " .. count.Bless .. " Bless and " ..
|
||||
count.Curse .. " Curse tokens from the chaos bag.", color, "White")
|
||||
broadcastToColor("Removed " .. removeType("Bless") .. " Bless and " ..
|
||||
removeType("Curse") .. " Curse tokens from play.", color, "White")
|
||||
|
||||
@ -239,6 +240,31 @@ function getTokenCount(type)
|
||||
return "(" .. (numInPlay[type] - #tokensTaken[type]) .. "/" .. #tokensTaken[type] .. ")"
|
||||
end
|
||||
|
||||
-- called by cards that seal bless/curse tokens
|
||||
---@param param Table This contains the type and guid of the sealed token
|
||||
function sealedToken(param)
|
||||
table.insert(tokensTaken[param.type], param.guid)
|
||||
broadcastCount(param.type)
|
||||
end
|
||||
|
||||
-- called by cards that seal bless/curse tokens
|
||||
---@param param Table This contains the type and guid of the released token
|
||||
function releasedToken(param)
|
||||
for i, v in ipairs(tokensTaken[param.type]) do
|
||||
if v == param.guid then
|
||||
table.remove(tokensTaken[param.type], i)
|
||||
break
|
||||
end
|
||||
end
|
||||
if not updating then
|
||||
updating = true
|
||||
Wait.time(function()
|
||||
broadcastCount(param.type)
|
||||
updating = false
|
||||
end, 0.1)
|
||||
end
|
||||
end
|
||||
|
||||
---------------------------------------------------------
|
||||
-- main functions: add, take and return
|
||||
---------------------------------------------------------
|
||||
|
@ -1,14 +1,24 @@
|
||||
do
|
||||
local BlessCurseManagerApi = {}
|
||||
local GUID = "5933fb"
|
||||
local MANAGER_GUID = "5933fb"
|
||||
|
||||
-- removes all taken tokens and resets the counts
|
||||
BlessCurseManagerApi.removeTakenTokensAndReset = function()
|
||||
local BlessCurseManager = getObjectFromGUID(GUID)
|
||||
local BlessCurseManager = getObjectFromGUID(MANAGER_GUID)
|
||||
Wait.time(function() BlessCurseManager.call("removeType", "Bless") end, 0.05)
|
||||
Wait.time(function() BlessCurseManager.call("removeType", "Curse") end, 0.10)
|
||||
Wait.time(function() BlessCurseManager.call("doReset", "White") end, 0.15)
|
||||
end
|
||||
|
||||
-- updates the internal count (called by cards that seal bless/curse tokens)
|
||||
BlessCurseManagerApi.sealedToken = function(type, guid)
|
||||
getObjectFromGUID(MANAGER_GUID).call("sealedToken", { type = type, guid = guid })
|
||||
end
|
||||
|
||||
-- updates the internal count (called by cards that seal bless/curse tokens)
|
||||
BlessCurseManagerApi.releasedToken = function(type, guid)
|
||||
getObjectFromGUID(MANAGER_GUID).call("releasedToken", { type = type, guid = guid })
|
||||
end
|
||||
|
||||
return BlessCurseManagerApi
|
||||
end
|
||||
|
@ -232,7 +232,7 @@ end
|
||||
-- chaos token drawing
|
||||
---------------------------------------------------------
|
||||
|
||||
-- checks scripting zone for chaos bag
|
||||
-- checks scripting zone for chaos bag (also called by a lot of objects!)
|
||||
function findChaosBag()
|
||||
local chaosbag_zone = getObjectFromGUID("83ef06")
|
||||
|
||||
|
88
src/playercards/CardsThatSealTokens.ttslua
Normal file
88
src/playercards/CardsThatSealTokens.ttslua
Normal file
@ -0,0 +1,88 @@
|
||||
local blessCurseManagerApi = require("chaosbag/BlessCurseManagerApi")
|
||||
|
||||
function onSave() return JSON.encode(sealedTokens) end
|
||||
|
||||
function onLoad(savedData)
|
||||
sealedTokens = JSON.decode(savedData) or {}
|
||||
ID_URL_MAP = Global.getTable("ID_URL_MAP")
|
||||
|
||||
-- add menu items
|
||||
if SHOW_SINGLE_RELEASE then
|
||||
self.addContextMenuItem("Release token", releaseOneToken)
|
||||
elseif SHOW_MULTI_RELEASE then
|
||||
self.addContextMenuItem("Release " .. SHOW_MULTI_RELEASE .. " token(s)", function(playerColor)
|
||||
for i = 1, SHOW_MULTI_RELEASE do
|
||||
releaseOneToken(playerColor)
|
||||
end
|
||||
end)
|
||||
else
|
||||
self.addContextMenuItem("Release token(s)", releaseTokens)
|
||||
end
|
||||
|
||||
for _, map in pairs(ID_URL_MAP) do
|
||||
if VALID_TOKENS[map.name] ~= nil then
|
||||
self.addContextMenuItem("Seal " .. map.name, function(playerColor) sealToken(map.name, playerColor) end)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- seals the named token on this card
|
||||
function sealToken(name, playerColor)
|
||||
local chaosbag = Global.call("findChaosBag")
|
||||
for i, obj in ipairs(chaosbag.getObjects()) do
|
||||
if obj.name == name then
|
||||
chaosbag.takeObject({
|
||||
position = self.getPosition() + Vector(0, 0.5 + 0.1 * #sealedTokens, 0),
|
||||
rotation = self.getRotation(),
|
||||
index = i - 1,
|
||||
smooth = false,
|
||||
callback_function = function(token)
|
||||
local guid = token.getGUID()
|
||||
table.insert(sealedTokens, guid)
|
||||
|
||||
if name == "Bless" or name == "Curse" then
|
||||
blessCurseManagerApi.sealedToken(name, guid)
|
||||
end
|
||||
end
|
||||
})
|
||||
return
|
||||
end
|
||||
end
|
||||
printToColor(name .. " token not found in chaos bag", playerColor)
|
||||
end
|
||||
|
||||
-- release the last sealed token
|
||||
function releaseOneToken(playerColor)
|
||||
if sealedTokens == {} then
|
||||
printToColor("No sealed token(s) found", playerColor)
|
||||
else
|
||||
printToColor("Releasing token", playerColor)
|
||||
local chaosbag = Global.call("findChaosBag")
|
||||
local guid = table.remove(sealedTokens)
|
||||
local token = getObjectFromGUID(guid)
|
||||
local name = token.getName()
|
||||
chaosbag.putObject(token)
|
||||
if name == "Bless" or name == "Curse" then
|
||||
blessCurseManagerApi.releasedToken(name, guid)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- releases all sealed tokens
|
||||
function releaseTokens(playerColor)
|
||||
if #sealedTokens == 0 then
|
||||
printToColor("No sealed token(s) found", playerColor)
|
||||
else
|
||||
printToColor("Releasing token(s)", playerColor)
|
||||
local chaosbag = Global.call("findChaosBag")
|
||||
for _, guid in ipairs(sealedTokens) do
|
||||
local token = getObjectFromGUID(guid)
|
||||
local name = token.getName()
|
||||
chaosbag.putObject(token)
|
||||
if name == "Bless" or name == "Curse" then
|
||||
blessCurseManagerApi.releasedToken(name, guid)
|
||||
end
|
||||
end
|
||||
sealedTokens = {}
|
||||
end
|
||||
end
|
@ -1,65 +1,6 @@
|
||||
VALID_TOKENS = {
|
||||
["+1"]=true,
|
||||
["Elder Sign"]=true
|
||||
["+1"] = true,
|
||||
["Elder Sign"] = true
|
||||
}
|
||||
|
||||
function onload()
|
||||
chaosbag = getChaosBag()
|
||||
sealedTokens = { }
|
||||
IMAGE_TOKEN_MAP = { }
|
||||
for i,v in pairs(Global.getVar("IMAGE_TOKEN_MAP")) do
|
||||
IMAGE_TOKEN_MAP[i] = v
|
||||
end
|
||||
|
||||
-- add menu items
|
||||
self.clearContextMenu()
|
||||
self.addContextMenuItem("Release Token", releaseTokens)
|
||||
for url,name in pairs(IMAGE_TOKEN_MAP) do
|
||||
if VALID_TOKENS[name] ~= nil then
|
||||
self.addContextMenuItem("Seal " .. name, function(playerColor) sealToken(url, playerColor) end)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function sealToken(url, playerColor)
|
||||
local pos = self.getPosition()
|
||||
|
||||
local name = IMAGE_TOKEN_MAP[url]
|
||||
for i,obj in ipairs(chaosbag.getObjects()) do
|
||||
if obj.name == name then
|
||||
chaosbag.takeObject({
|
||||
position={ pos.x, pos.y + 1, pos.z },
|
||||
index=i-1,
|
||||
smooth=false,
|
||||
callback_function=_sealToken
|
||||
})
|
||||
return
|
||||
end
|
||||
end
|
||||
printToColor(name .. " token not found in bag", playerColor)
|
||||
end
|
||||
|
||||
function _sealToken(obj)
|
||||
table.insert(sealedTokens, obj)
|
||||
end
|
||||
|
||||
function releaseTokens(playerColor)
|
||||
printToColor("Releasing token", playerColor)
|
||||
for i,obj in ipairs(sealedTokens) do
|
||||
chaosbag.putObject(obj)
|
||||
end
|
||||
sealedTokens = { }
|
||||
end
|
||||
|
||||
function getChaosBag()
|
||||
local items = getObjectFromGUID("83ef06").getObjects()
|
||||
local chaosbag = nil
|
||||
for i,v in ipairs(items) do
|
||||
if v.getDescription() == "Chaos Bag" then
|
||||
chaosbag = getObjectFromGUID(v.getGUID())
|
||||
break
|
||||
end
|
||||
end
|
||||
if chaosbag == nil then printToAll("No chaos bag found") end
|
||||
return chaosbag
|
||||
end
|
||||
require("playercards/CardsThatSealTokens")
|
||||
|
@ -1,81 +1,5 @@
|
||||
function onload()
|
||||
mode = "Curse"
|
||||
chaosbag = getChaosBag()
|
||||
manager = getObjectFromGUID("5933fb")
|
||||
sealedTokens = { }
|
||||
IMAGE_TOKEN_MAP = { }
|
||||
for i,v in pairs(Global.getVar("IMAGE_TOKEN_MAP")) do
|
||||
IMAGE_TOKEN_MAP[i] = v
|
||||
end
|
||||
VALID_TOKENS = {
|
||||
["Curse"] = true
|
||||
}
|
||||
|
||||
-- add menu items
|
||||
self.clearContextMenu()
|
||||
self.addContextMenuItem("Release Token", releaseTokens, true)
|
||||
for url,name in pairs(IMAGE_TOKEN_MAP) do
|
||||
if name == mode then
|
||||
self.addContextMenuItem("Seal " .. mode, function(playerColor) sealToken(url, playerColor) end, true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function sealToken(url, playerColor)
|
||||
local pos = self.getPosition()
|
||||
|
||||
local name = IMAGE_TOKEN_MAP[url]
|
||||
for i,obj in ipairs(chaosbag.getObjects()) do
|
||||
if obj.name == name then
|
||||
chaosbag.takeObject({
|
||||
position={ pos.x, pos.y + 1, pos.z },
|
||||
index=i-1,
|
||||
smooth=false,
|
||||
callback_function=_sealToken
|
||||
})
|
||||
return
|
||||
end
|
||||
end
|
||||
printToColor(name .. " token not found in bag", playerColor)
|
||||
end
|
||||
|
||||
function _sealToken(obj)
|
||||
table.insert(sealedTokens, obj)
|
||||
local guid = obj.getGUID()
|
||||
local tokensTaken = manager.getVar("tokensTaken")
|
||||
table.insert(tokensTaken[mode], guid)
|
||||
manager.setVar("tokensTaken", tokensTaken)
|
||||
manager.setVar("mode", mode)
|
||||
printToAll("Sealing " .. mode .. " token " .. manager.call("getTokenCount"))
|
||||
end
|
||||
|
||||
function releaseTokens(playerColor)
|
||||
if #sealedTokens == 0 then return end
|
||||
local token = sealedTokens[#sealedTokens]
|
||||
if token ~= nil then
|
||||
local guid = token.getGUID()
|
||||
chaosbag.putObject(token)
|
||||
local tokensTaken = manager.getVar("tokensTaken")
|
||||
for i,v in ipairs(tokensTaken[mode]) do
|
||||
if v == guid then
|
||||
table.remove(tokensTaken[mode], i)
|
||||
break
|
||||
end
|
||||
end
|
||||
manager.setVar("tokensTaken", tokensTaken)
|
||||
manager.setVar("mode", mode)
|
||||
printToAll("Releasing " .. mode .. " token" .. manager.call("getTokenCount"))
|
||||
end
|
||||
|
||||
table.remove(sealedTokens)
|
||||
end
|
||||
|
||||
function getChaosBag()
|
||||
local items = getObjectFromGUID("83ef06").getObjects()
|
||||
local chaosbag = nil
|
||||
for i,v in ipairs(items) do
|
||||
if v.getDescription() == "Chaos Bag" then
|
||||
chaosbag = getObjectFromGUID(v.getGUID())
|
||||
break
|
||||
end
|
||||
end
|
||||
if chaosbag == nil then printToAll("No chaos bag found") end
|
||||
return chaosbag
|
||||
end
|
||||
require("playercards/CardsThatSealTokens")
|
||||
|
@ -1,60 +1,5 @@
|
||||
function onload()
|
||||
chaosbag = getChaosBag()
|
||||
sealedTokens = { }
|
||||
IMAGE_TOKEN_MAP = { }
|
||||
for i,v in pairs(Global.getVar("IMAGE_TOKEN_MAP")) do
|
||||
IMAGE_TOKEN_MAP[i] = v
|
||||
end
|
||||
VALID_TOKENS = {
|
||||
["Elder Sign"] = true
|
||||
}
|
||||
|
||||
-- add menu items
|
||||
self.clearContextMenu()
|
||||
self.addContextMenuItem("Release Token", releaseTokens)
|
||||
for url,name in pairs(IMAGE_TOKEN_MAP) do
|
||||
if name == "Elder Sign" then
|
||||
self.addContextMenuItem("Seal Elder Sign", function(playerColor) sealToken(url, playerColor) end)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function sealToken(url, playerColor)
|
||||
local pos = self.getPosition()
|
||||
|
||||
local name = IMAGE_TOKEN_MAP[url]
|
||||
for i,obj in ipairs(chaosbag.getObjects()) do
|
||||
if obj.name == name then
|
||||
chaosbag.takeObject({
|
||||
position={ pos.x, pos.y + 1, pos.z },
|
||||
index=i-1,
|
||||
smooth=false,
|
||||
callback_function=_sealToken
|
||||
})
|
||||
return
|
||||
end
|
||||
end
|
||||
printToColor(name .. " token not found in bag", playerColor)
|
||||
end
|
||||
|
||||
function _sealToken(obj)
|
||||
table.insert(sealedTokens, obj)
|
||||
end
|
||||
|
||||
function releaseTokens(playerColor)
|
||||
printToColor("Releasing token", playerColor)
|
||||
for i,obj in ipairs(sealedTokens) do
|
||||
chaosbag.putObject(obj)
|
||||
end
|
||||
sealedTokens = { }
|
||||
end
|
||||
|
||||
function getChaosBag()
|
||||
local items = getObjectFromGUID("83ef06").getObjects()
|
||||
local chaosbag = nil
|
||||
for i,v in ipairs(items) do
|
||||
if v.getDescription() == "Chaos Bag" then
|
||||
chaosbag = getObjectFromGUID(v.getGUID())
|
||||
break
|
||||
end
|
||||
end
|
||||
if chaosbag == nil then printToAll("No chaos bag found") end
|
||||
return chaosbag
|
||||
end
|
||||
require("playercards/CardsThatSealTokens")
|
||||
|
@ -1,81 +1,7 @@
|
||||
function onload()
|
||||
mode = "Curse"
|
||||
chaosbag = getChaosBag()
|
||||
manager = getObjectFromGUID("5933fb")
|
||||
sealedTokens = { }
|
||||
IMAGE_TOKEN_MAP = { }
|
||||
for i,v in pairs(Global.getVar("IMAGE_TOKEN_MAP")) do
|
||||
IMAGE_TOKEN_MAP[i] = v
|
||||
end
|
||||
VALID_TOKENS = {
|
||||
["Curse"] = true
|
||||
}
|
||||
|
||||
-- add menu items
|
||||
self.clearContextMenu()
|
||||
self.addContextMenuItem("Release Token", releaseTokens, true)
|
||||
for url,name in pairs(IMAGE_TOKEN_MAP) do
|
||||
if name == mode then
|
||||
self.addContextMenuItem("Seal " .. mode, function(playerColor) sealToken(url, playerColor) end, true)
|
||||
end
|
||||
end
|
||||
end
|
||||
SHOW_SINGLE_RELEASE = true
|
||||
|
||||
function sealToken(url, playerColor)
|
||||
local pos = self.getPosition()
|
||||
|
||||
local name = IMAGE_TOKEN_MAP[url]
|
||||
for i,obj in ipairs(chaosbag.getObjects()) do
|
||||
if obj.name == name then
|
||||
chaosbag.takeObject({
|
||||
position={ pos.x, pos.y + 1, pos.z },
|
||||
index=i-1,
|
||||
smooth=false,
|
||||
callback_function=_sealToken
|
||||
})
|
||||
return
|
||||
end
|
||||
end
|
||||
printToColor(name .. " token not found in bag", playerColor)
|
||||
end
|
||||
|
||||
function _sealToken(obj)
|
||||
table.insert(sealedTokens, obj)
|
||||
local guid = obj.getGUID()
|
||||
local tokensTaken = manager.getVar("tokensTaken")
|
||||
table.insert(tokensTaken[mode], guid)
|
||||
manager.setVar("tokensTaken", tokensTaken)
|
||||
manager.setVar("mode", mode)
|
||||
printToAll("Sealing " .. mode .. " token " .. manager.call("getTokenCount"))
|
||||
end
|
||||
|
||||
function releaseTokens(playerColor)
|
||||
if #sealedTokens == 0 then return end
|
||||
local token = sealedTokens[#sealedTokens]
|
||||
if token ~= nil then
|
||||
local guid = token.getGUID()
|
||||
chaosbag.putObject(token)
|
||||
local tokensTaken = manager.getVar("tokensTaken")
|
||||
for i,v in ipairs(tokensTaken[mode]) do
|
||||
if v == guid then
|
||||
table.remove(tokensTaken[mode], i)
|
||||
break
|
||||
end
|
||||
end
|
||||
manager.setVar("tokensTaken", tokensTaken)
|
||||
manager.setVar("mode", mode)
|
||||
printToAll("Releasing " .. mode .. " token" .. manager.call("getTokenCount"))
|
||||
end
|
||||
|
||||
table.remove(sealedTokens)
|
||||
end
|
||||
|
||||
function getChaosBag()
|
||||
local items = getObjectFromGUID("83ef06").getObjects()
|
||||
local chaosbag = nil
|
||||
for i,v in ipairs(items) do
|
||||
if v.getDescription() == "Chaos Bag" then
|
||||
chaosbag = getObjectFromGUID(v.getGUID())
|
||||
break
|
||||
end
|
||||
end
|
||||
if chaosbag == nil then printToAll("No chaos bag found") end
|
||||
return chaosbag
|
||||
end
|
||||
require("playercards/CardsThatSealTokens")
|
||||
|
@ -1,81 +1,7 @@
|
||||
function onload()
|
||||
mode = "Bless"
|
||||
chaosbag = getChaosBag()
|
||||
manager = getObjectFromGUID("5933fb")
|
||||
sealedTokens = { }
|
||||
IMAGE_TOKEN_MAP = { }
|
||||
for i,v in pairs(Global.getVar("IMAGE_TOKEN_MAP")) do
|
||||
IMAGE_TOKEN_MAP[i] = v
|
||||
end
|
||||
VALID_TOKENS = {
|
||||
["Bless"] = true
|
||||
}
|
||||
|
||||
-- add menu items
|
||||
self.clearContextMenu()
|
||||
self.addContextMenuItem("Release Token", releaseTokens, true)
|
||||
for url,name in pairs(IMAGE_TOKEN_MAP) do
|
||||
if name == mode then
|
||||
self.addContextMenuItem("Seal " .. mode, function(playerColor) sealToken(url, playerColor) end, true)
|
||||
end
|
||||
end
|
||||
end
|
||||
SHOW_SINGLE_RELEASE = true
|
||||
|
||||
function sealToken(url, playerColor)
|
||||
local pos = self.getPosition()
|
||||
|
||||
local name = IMAGE_TOKEN_MAP[url]
|
||||
for i,obj in ipairs(chaosbag.getObjects()) do
|
||||
if obj.name == name then
|
||||
chaosbag.takeObject({
|
||||
position={ pos.x, pos.y + 1, pos.z },
|
||||
index=i-1,
|
||||
smooth=false,
|
||||
callback_function=_sealToken
|
||||
})
|
||||
return
|
||||
end
|
||||
end
|
||||
printToColor(name .. " token not found in bag", playerColor)
|
||||
end
|
||||
|
||||
function _sealToken(obj)
|
||||
table.insert(sealedTokens, obj)
|
||||
local guid = obj.getGUID()
|
||||
local tokensTaken = manager.getVar("tokensTaken")
|
||||
table.insert(tokensTaken[mode], guid)
|
||||
manager.setVar("tokensTaken", tokensTaken)
|
||||
manager.setVar("mode", mode)
|
||||
printToAll("Sealing " .. mode .. " token " .. manager.call("getTokenCount"))
|
||||
end
|
||||
|
||||
function releaseTokens(playerColor)
|
||||
if #sealedTokens == 0 then return end
|
||||
local token = sealedTokens[#sealedTokens]
|
||||
if token ~= nil then
|
||||
local guid = token.getGUID()
|
||||
chaosbag.putObject(token)
|
||||
local tokensTaken = manager.getVar("tokensTaken")
|
||||
for i,v in ipairs(tokensTaken[mode]) do
|
||||
if v == guid then
|
||||
table.remove(tokensTaken[mode], i)
|
||||
break
|
||||
end
|
||||
end
|
||||
manager.setVar("tokensTaken", tokensTaken)
|
||||
manager.setVar("mode", mode)
|
||||
printToAll("Releasing " .. mode .. " token" .. manager.call("getTokenCount"))
|
||||
end
|
||||
|
||||
table.remove(sealedTokens)
|
||||
end
|
||||
|
||||
function getChaosBag()
|
||||
local items = getObjectFromGUID("83ef06").getObjects()
|
||||
local chaosbag = nil
|
||||
for i,v in ipairs(items) do
|
||||
if v.getDescription() == "Chaos Bag" then
|
||||
chaosbag = getObjectFromGUID(v.getGUID())
|
||||
break
|
||||
end
|
||||
end
|
||||
if chaosbag == nil then printToAll("No chaos bag found") end
|
||||
return chaosbag
|
||||
end
|
||||
require("playercards/CardsThatSealTokens")
|
||||
|
@ -1,81 +1,7 @@
|
||||
function onload()
|
||||
mode = "Curse"
|
||||
chaosbag = getChaosBag()
|
||||
manager = getObjectFromGUID("5933fb")
|
||||
sealedTokens = { }
|
||||
IMAGE_TOKEN_MAP = { }
|
||||
for i,v in pairs(Global.getVar("IMAGE_TOKEN_MAP")) do
|
||||
IMAGE_TOKEN_MAP[i] = v
|
||||
end
|
||||
VALID_TOKENS = {
|
||||
["Curse"] = true
|
||||
}
|
||||
|
||||
-- add menu items
|
||||
self.clearContextMenu()
|
||||
self.addContextMenuItem("Release Token", releaseTokens, true)
|
||||
for url,name in pairs(IMAGE_TOKEN_MAP) do
|
||||
if name == mode then
|
||||
self.addContextMenuItem("Seal " .. mode, function(playerColor) sealToken(url, playerColor) end, true)
|
||||
end
|
||||
end
|
||||
end
|
||||
SHOW_SINGLE_RELEASE = true
|
||||
|
||||
function sealToken(url, playerColor)
|
||||
local pos = self.getPosition()
|
||||
|
||||
local name = IMAGE_TOKEN_MAP[url]
|
||||
for i,obj in ipairs(chaosbag.getObjects()) do
|
||||
if obj.name == name then
|
||||
chaosbag.takeObject({
|
||||
position={ pos.x, pos.y + 1, pos.z },
|
||||
index=i-1,
|
||||
smooth=false,
|
||||
callback_function=_sealToken
|
||||
})
|
||||
return
|
||||
end
|
||||
end
|
||||
printToColor(name .. " token not found in bag", playerColor)
|
||||
end
|
||||
|
||||
function _sealToken(obj)
|
||||
table.insert(sealedTokens, obj)
|
||||
local guid = obj.getGUID()
|
||||
local tokensTaken = manager.getVar("tokensTaken")
|
||||
table.insert(tokensTaken[mode], guid)
|
||||
manager.setVar("tokensTaken", tokensTaken)
|
||||
manager.setVar("mode", mode)
|
||||
printToAll("Sealing " .. mode .. " token " .. manager.call("getTokenCount"))
|
||||
end
|
||||
|
||||
function releaseTokens(playerColor)
|
||||
if #sealedTokens == 0 then return end
|
||||
local token = sealedTokens[#sealedTokens]
|
||||
if token ~= nil then
|
||||
local guid = token.getGUID()
|
||||
chaosbag.putObject(token)
|
||||
local tokensTaken = manager.getVar("tokensTaken")
|
||||
for i,v in ipairs(tokensTaken[mode]) do
|
||||
if v == guid then
|
||||
table.remove(tokensTaken[mode], i)
|
||||
break
|
||||
end
|
||||
end
|
||||
manager.setVar("tokensTaken", tokensTaken)
|
||||
manager.setVar("mode", mode)
|
||||
printToAll("Releasing " .. mode .. " token" .. manager.call("getTokenCount"))
|
||||
end
|
||||
|
||||
table.remove(sealedTokens)
|
||||
end
|
||||
|
||||
function getChaosBag()
|
||||
local items = getObjectFromGUID("83ef06").getObjects()
|
||||
local chaosbag = nil
|
||||
for i,v in ipairs(items) do
|
||||
if v.getDescription() == "Chaos Bag" then
|
||||
chaosbag = getObjectFromGUID(v.getGUID())
|
||||
break
|
||||
end
|
||||
end
|
||||
if chaosbag == nil then printToAll("No chaos bag found") end
|
||||
return chaosbag
|
||||
end
|
||||
require("playercards/CardsThatSealTokens")
|
||||
|
@ -1,81 +1,7 @@
|
||||
function onload()
|
||||
mode = "Bless"
|
||||
chaosbag = getChaosBag()
|
||||
manager = getObjectFromGUID("5933fb")
|
||||
sealedTokens = { }
|
||||
IMAGE_TOKEN_MAP = { }
|
||||
for i,v in pairs(Global.getVar("IMAGE_TOKEN_MAP")) do
|
||||
IMAGE_TOKEN_MAP[i] = v
|
||||
end
|
||||
VALID_TOKENS = {
|
||||
["Bless"] = true
|
||||
}
|
||||
|
||||
-- add menu items
|
||||
self.clearContextMenu()
|
||||
self.addContextMenuItem("Release Token", releaseTokens, true)
|
||||
for url,name in pairs(IMAGE_TOKEN_MAP) do
|
||||
if name == mode then
|
||||
self.addContextMenuItem("Seal " .. mode, function(playerColor) sealToken(url, playerColor) end, true)
|
||||
end
|
||||
end
|
||||
end
|
||||
SHOW_MULTI_RELEASE = 3
|
||||
|
||||
function sealToken(url, playerColor)
|
||||
local pos = self.getPosition()
|
||||
|
||||
local name = IMAGE_TOKEN_MAP[url]
|
||||
for i,obj in ipairs(chaosbag.getObjects()) do
|
||||
if obj.name == name then
|
||||
chaosbag.takeObject({
|
||||
position={ pos.x, pos.y + 1, pos.z },
|
||||
index=i-1,
|
||||
smooth=false,
|
||||
callback_function=_sealToken
|
||||
})
|
||||
return
|
||||
end
|
||||
end
|
||||
printToColor(name .. " token not found in bag", playerColor)
|
||||
end
|
||||
|
||||
function _sealToken(obj)
|
||||
table.insert(sealedTokens, obj)
|
||||
local guid = obj.getGUID()
|
||||
local tokensTaken = manager.getVar("tokensTaken")
|
||||
table.insert(tokensTaken[mode], guid)
|
||||
manager.setVar("tokensTaken", tokensTaken)
|
||||
manager.setVar("mode", mode)
|
||||
printToAll("Sealing " .. mode .. " token " .. manager.call("getTokenCount"))
|
||||
end
|
||||
|
||||
function releaseTokens(playerColor)
|
||||
if #sealedTokens == 0 then return end
|
||||
local token = sealedTokens[#sealedTokens]
|
||||
if token ~= nil then
|
||||
local guid = token.getGUID()
|
||||
chaosbag.putObject(token)
|
||||
local tokensTaken = manager.getVar("tokensTaken")
|
||||
for i,v in ipairs(tokensTaken[mode]) do
|
||||
if v == guid then
|
||||
table.remove(tokensTaken[mode], i)
|
||||
break
|
||||
end
|
||||
end
|
||||
manager.setVar("tokensTaken", tokensTaken)
|
||||
manager.setVar("mode", mode)
|
||||
printToAll("Releasing " .. mode .. " token" .. manager.call("getTokenCount"))
|
||||
end
|
||||
|
||||
table.remove(sealedTokens)
|
||||
end
|
||||
|
||||
function getChaosBag()
|
||||
local items = getObjectFromGUID("83ef06").getObjects()
|
||||
local chaosbag = nil
|
||||
for i,v in ipairs(items) do
|
||||
if v.getDescription() == "Chaos Bag" then
|
||||
chaosbag = getObjectFromGUID(v.getGUID())
|
||||
break
|
||||
end
|
||||
end
|
||||
if chaosbag == nil then printToAll("No chaos bag found") end
|
||||
return chaosbag
|
||||
end
|
||||
require("playercards/CardsThatSealTokens")
|
||||
|
@ -1,81 +1,5 @@
|
||||
function onload()
|
||||
mode = "Bless"
|
||||
chaosbag = getChaosBag()
|
||||
manager = getObjectFromGUID("5933fb")
|
||||
sealedTokens = { }
|
||||
IMAGE_TOKEN_MAP = { }
|
||||
for i,v in pairs(Global.getVar("IMAGE_TOKEN_MAP")) do
|
||||
IMAGE_TOKEN_MAP[i] = v
|
||||
end
|
||||
VALID_TOKENS = {
|
||||
["Bless"] = true
|
||||
}
|
||||
|
||||
-- add menu items
|
||||
self.clearContextMenu()
|
||||
self.addContextMenuItem("Release Token", releaseTokens, true)
|
||||
for url,name in pairs(IMAGE_TOKEN_MAP) do
|
||||
if name == mode then
|
||||
self.addContextMenuItem("Seal " .. mode, function(playerColor) sealToken(url, playerColor) end, true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function sealToken(url, playerColor)
|
||||
local pos = self.getPosition()
|
||||
|
||||
local name = IMAGE_TOKEN_MAP[url]
|
||||
for i,obj in ipairs(chaosbag.getObjects()) do
|
||||
if obj.name == name then
|
||||
chaosbag.takeObject({
|
||||
position={ pos.x, pos.y + 1, pos.z },
|
||||
index=i-1,
|
||||
smooth=false,
|
||||
callback_function=_sealToken
|
||||
})
|
||||
return
|
||||
end
|
||||
end
|
||||
printToColor(name .. " token not found in bag", playerColor)
|
||||
end
|
||||
|
||||
function _sealToken(obj)
|
||||
table.insert(sealedTokens, obj)
|
||||
local guid = obj.getGUID()
|
||||
local tokensTaken = manager.getVar("tokensTaken")
|
||||
table.insert(tokensTaken[mode], guid)
|
||||
manager.setVar("tokensTaken", tokensTaken)
|
||||
manager.setVar("mode", mode)
|
||||
printToAll("Sealing " .. mode .. " token " .. manager.call("getTokenCount"))
|
||||
end
|
||||
|
||||
function releaseTokens(playerColor)
|
||||
if #sealedTokens == 0 then return end
|
||||
local token = sealedTokens[#sealedTokens]
|
||||
if token ~= nil then
|
||||
local guid = token.getGUID()
|
||||
chaosbag.putObject(token)
|
||||
local tokensTaken = manager.getVar("tokensTaken")
|
||||
for i,v in ipairs(tokensTaken[mode]) do
|
||||
if v == guid then
|
||||
table.remove(tokensTaken[mode], i)
|
||||
break
|
||||
end
|
||||
end
|
||||
manager.setVar("tokensTaken", tokensTaken)
|
||||
manager.setVar("mode", mode)
|
||||
printToAll("Releasing " .. mode .. " token" .. manager.call("getTokenCount"))
|
||||
end
|
||||
|
||||
table.remove(sealedTokens)
|
||||
end
|
||||
|
||||
function getChaosBag()
|
||||
local items = getObjectFromGUID("83ef06").getObjects()
|
||||
local chaosbag = nil
|
||||
for i,v in ipairs(items) do
|
||||
if v.getDescription() == "Chaos Bag" then
|
||||
chaosbag = getObjectFromGUID(v.getGUID())
|
||||
break
|
||||
end
|
||||
end
|
||||
if chaosbag == nil then printToAll("No chaos bag found") end
|
||||
return chaosbag
|
||||
end
|
||||
require("playercards/CardsThatSealTokens")
|
||||
|
@ -1,81 +1,7 @@
|
||||
function onload()
|
||||
mode = "Bless"
|
||||
chaosbag = getChaosBag()
|
||||
manager = getObjectFromGUID("5933fb")
|
||||
sealedTokens = { }
|
||||
IMAGE_TOKEN_MAP = { }
|
||||
for i,v in pairs(Global.getVar("IMAGE_TOKEN_MAP")) do
|
||||
IMAGE_TOKEN_MAP[i] = v
|
||||
end
|
||||
VALID_TOKENS = {
|
||||
["Bless"] = true
|
||||
}
|
||||
|
||||
-- add menu items
|
||||
self.clearContextMenu()
|
||||
self.addContextMenuItem("Release Token", releaseTokens, true)
|
||||
for url,name in pairs(IMAGE_TOKEN_MAP) do
|
||||
if name == mode then
|
||||
self.addContextMenuItem("Seal " .. mode, function(playerColor) sealToken(url, playerColor) end, true)
|
||||
end
|
||||
end
|
||||
end
|
||||
SHOW_SINGLE_RELEASE = true
|
||||
|
||||
function sealToken(url, playerColor)
|
||||
local pos = self.getPosition()
|
||||
|
||||
local name = IMAGE_TOKEN_MAP[url]
|
||||
for i,obj in ipairs(chaosbag.getObjects()) do
|
||||
if obj.name == name then
|
||||
chaosbag.takeObject({
|
||||
position={ pos.x, pos.y + 1, pos.z },
|
||||
index=i-1,
|
||||
smooth=false,
|
||||
callback_function=_sealToken
|
||||
})
|
||||
return
|
||||
end
|
||||
end
|
||||
printToColor(name .. " token not found in bag", playerColor)
|
||||
end
|
||||
|
||||
function _sealToken(obj)
|
||||
table.insert(sealedTokens, obj)
|
||||
local guid = obj.getGUID()
|
||||
local tokensTaken = manager.getVar("tokensTaken")
|
||||
table.insert(tokensTaken[mode], guid)
|
||||
manager.setVar("tokensTaken", tokensTaken)
|
||||
manager.setVar("mode", mode)
|
||||
printToAll("Sealing " .. mode .. " token " .. manager.call("getTokenCount"))
|
||||
end
|
||||
|
||||
function releaseTokens(playerColor)
|
||||
if #sealedTokens == 0 then return end
|
||||
local token = sealedTokens[#sealedTokens]
|
||||
if token ~= nil then
|
||||
local guid = token.getGUID()
|
||||
chaosbag.putObject(token)
|
||||
local tokensTaken = manager.getVar("tokensTaken")
|
||||
for i,v in ipairs(tokensTaken[mode]) do
|
||||
if v == guid then
|
||||
table.remove(tokensTaken[mode], i)
|
||||
break
|
||||
end
|
||||
end
|
||||
manager.setVar("tokensTaken", tokensTaken)
|
||||
manager.setVar("mode", mode)
|
||||
printToAll("Releasing " .. mode .. " token" .. manager.call("getTokenCount"))
|
||||
end
|
||||
|
||||
table.remove(sealedTokens)
|
||||
end
|
||||
|
||||
function getChaosBag()
|
||||
local items = getObjectFromGUID("83ef06").getObjects()
|
||||
local chaosbag = nil
|
||||
for i,v in ipairs(items) do
|
||||
if v.getDescription() == "Chaos Bag" then
|
||||
chaosbag = getObjectFromGUID(v.getGUID())
|
||||
break
|
||||
end
|
||||
end
|
||||
if chaosbag == nil then printToAll("No chaos bag found") end
|
||||
return chaosbag
|
||||
end
|
||||
require("playercards/CardsThatSealTokens")
|
||||
|
@ -1,60 +1,5 @@
|
||||
function onload()
|
||||
chaosbag = getChaosBag()
|
||||
sealedTokens = { }
|
||||
IMAGE_TOKEN_MAP = { }
|
||||
for i,v in pairs(Global.getVar("IMAGE_TOKEN_MAP")) do
|
||||
IMAGE_TOKEN_MAP[i] = v
|
||||
end
|
||||
VALID_TOKENS = {
|
||||
["Auto-fail"] = true
|
||||
}
|
||||
|
||||
-- add menu items
|
||||
self.clearContextMenu()
|
||||
self.addContextMenuItem("Release Token", releaseTokens)
|
||||
for url,name in pairs(IMAGE_TOKEN_MAP) do
|
||||
if name == "Auto-fail" then
|
||||
self.addContextMenuItem("Seal Auto-fail", function(playerColor) sealToken(url, playerColor) end)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function sealToken(url, playerColor)
|
||||
local pos = self.getPosition()
|
||||
|
||||
local name = IMAGE_TOKEN_MAP[url]
|
||||
for i,obj in ipairs(chaosbag.getObjects()) do
|
||||
if obj.name == name then
|
||||
chaosbag.takeObject({
|
||||
position={ pos.x, pos.y + 1, pos.z },
|
||||
index=i-1,
|
||||
smooth=false,
|
||||
callback_function=_sealToken
|
||||
})
|
||||
return
|
||||
end
|
||||
end
|
||||
printToColor(name .. " token not found in bag", playerColor)
|
||||
end
|
||||
|
||||
function _sealToken(obj)
|
||||
table.insert(sealedTokens, obj)
|
||||
end
|
||||
|
||||
function releaseTokens(playerColor)
|
||||
printToColor("Releasing token", playerColor)
|
||||
for i,obj in ipairs(sealedTokens) do
|
||||
chaosbag.putObject(obj)
|
||||
end
|
||||
sealedTokens = { }
|
||||
end
|
||||
|
||||
function getChaosBag()
|
||||
local items = getObjectFromGUID("83ef06").getObjects()
|
||||
local chaosbag = nil
|
||||
for i,v in ipairs(items) do
|
||||
if v.getDescription() == "Chaos Bag" then
|
||||
chaosbag = getObjectFromGUID(v.getGUID())
|
||||
break
|
||||
end
|
||||
end
|
||||
if chaosbag == nil then printToAll("No chaos bag found") end
|
||||
return chaosbag
|
||||
end
|
||||
require("playercards/CardsThatSealTokens")
|
||||
|
@ -1,60 +1,5 @@
|
||||
function onload()
|
||||
chaosbag = getChaosBag()
|
||||
sealedTokens = { }
|
||||
IMAGE_TOKEN_MAP = { }
|
||||
for i,v in pairs(Global.getVar("IMAGE_TOKEN_MAP")) do
|
||||
IMAGE_TOKEN_MAP[i] = v
|
||||
end
|
||||
VALID_TOKENS = {
|
||||
["Elder Sign"] = true
|
||||
}
|
||||
|
||||
-- add menu items
|
||||
self.clearContextMenu()
|
||||
self.addContextMenuItem("Release Token", releaseTokens)
|
||||
for url,name in pairs(IMAGE_TOKEN_MAP) do
|
||||
if name == "Elder Sign" then
|
||||
self.addContextMenuItem("Seal Elder Sign", function(playerColor) sealToken(url, playerColor) end)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function sealToken(url, playerColor)
|
||||
local pos = self.getPosition()
|
||||
|
||||
local name = IMAGE_TOKEN_MAP[url]
|
||||
for i,obj in ipairs(chaosbag.getObjects()) do
|
||||
if obj.name == name then
|
||||
chaosbag.takeObject({
|
||||
position={ pos.x, pos.y + 1, pos.z },
|
||||
index=i-1,
|
||||
smooth=false,
|
||||
callback_function=_sealToken
|
||||
})
|
||||
return
|
||||
end
|
||||
end
|
||||
printToColor(name .. " token not found in bag", playerColor)
|
||||
end
|
||||
|
||||
function _sealToken(obj)
|
||||
table.insert(sealedTokens, obj)
|
||||
end
|
||||
|
||||
function releaseTokens(playerColor)
|
||||
printToColor("Releasing token", playerColor)
|
||||
for i,obj in ipairs(sealedTokens) do
|
||||
chaosbag.putObject(obj)
|
||||
end
|
||||
sealedTokens = { }
|
||||
end
|
||||
|
||||
function getChaosBag()
|
||||
local items = getObjectFromGUID("83ef06").getObjects()
|
||||
local chaosbag = nil
|
||||
for i,v in ipairs(items) do
|
||||
if v.getDescription() == "Chaos Bag" then
|
||||
chaosbag = getObjectFromGUID(v.getGUID())
|
||||
break
|
||||
end
|
||||
end
|
||||
if chaosbag == nil then printToAll("No chaos bag found") end
|
||||
return chaosbag
|
||||
end
|
||||
require("playercards/CardsThatSealTokens")
|
||||
|
@ -1,45 +1,7 @@
|
||||
function onload()
|
||||
chaosbag = getChaosBag()
|
||||
IMAGE_TOKEN_MAP = { }
|
||||
for i,v in pairs(Global.getVar("IMAGE_TOKEN_MAP")) do
|
||||
IMAGE_TOKEN_MAP[i] = v
|
||||
end
|
||||
VALID_TOKENS = {
|
||||
["0"] = true
|
||||
}
|
||||
|
||||
-- add menu items
|
||||
self.clearContextMenu()
|
||||
for url,name in pairs(IMAGE_TOKEN_MAP) do
|
||||
if name == "0" then
|
||||
self.addContextMenuItem("Seal 0", function(playerColor) sealToken(url, playerColor) end)
|
||||
end
|
||||
end
|
||||
end
|
||||
SHOW_SINGLE_RELEASE = true
|
||||
|
||||
function sealToken(url, playerColor)
|
||||
local pos = self.getPosition()
|
||||
|
||||
local name = IMAGE_TOKEN_MAP[url]
|
||||
for i,obj in ipairs(chaosbag.getObjects()) do
|
||||
if obj.name == name then
|
||||
chaosbag.takeObject({
|
||||
position={ pos.x, pos.y + 1, pos.z },
|
||||
index=i-1,
|
||||
smooth=false
|
||||
})
|
||||
return
|
||||
end
|
||||
end
|
||||
printToColor(name .. " token not found in bag", playerColor)
|
||||
end
|
||||
|
||||
function getChaosBag()
|
||||
local items = getObjectFromGUID("83ef06").getObjects()
|
||||
local chaosbag = nil
|
||||
for i,v in ipairs(items) do
|
||||
if v.getDescription() == "Chaos Bag" then
|
||||
chaosbag = getObjectFromGUID(v.getGUID())
|
||||
break
|
||||
end
|
||||
end
|
||||
if chaosbag == nil then printToAll("No chaos bag found") end
|
||||
return chaosbag
|
||||
end
|
||||
require("playercards/CardsThatSealTokens")
|
||||
|
@ -1,81 +1,7 @@
|
||||
function onload()
|
||||
mode = "Bless"
|
||||
chaosbag = getChaosBag()
|
||||
manager = getObjectFromGUID("5933fb")
|
||||
sealedTokens = { }
|
||||
IMAGE_TOKEN_MAP = { }
|
||||
for i,v in pairs(Global.getVar("IMAGE_TOKEN_MAP")) do
|
||||
IMAGE_TOKEN_MAP[i] = v
|
||||
end
|
||||
VALID_TOKENS = {
|
||||
["Bless"] = true
|
||||
}
|
||||
|
||||
-- add menu items
|
||||
self.clearContextMenu()
|
||||
self.addContextMenuItem("Release Token", releaseTokens, true)
|
||||
for url,name in pairs(IMAGE_TOKEN_MAP) do
|
||||
if name == mode then
|
||||
self.addContextMenuItem("Seal " .. mode, function(playerColor) sealToken(url, playerColor) end, true)
|
||||
end
|
||||
end
|
||||
end
|
||||
SHOW_SINGLE_RELEASE = true
|
||||
|
||||
function sealToken(url, playerColor)
|
||||
local pos = self.getPosition()
|
||||
|
||||
local name = IMAGE_TOKEN_MAP[url]
|
||||
for i,obj in ipairs(chaosbag.getObjects()) do
|
||||
if obj.name == name then
|
||||
chaosbag.takeObject({
|
||||
position={ pos.x, pos.y + 1, pos.z },
|
||||
index=i-1,
|
||||
smooth=false,
|
||||
callback_function=_sealToken
|
||||
})
|
||||
return
|
||||
end
|
||||
end
|
||||
printToColor(name .. " token not found in bag", playerColor)
|
||||
end
|
||||
|
||||
function _sealToken(obj)
|
||||
table.insert(sealedTokens, obj)
|
||||
local guid = obj.getGUID()
|
||||
local tokensTaken = manager.getVar("tokensTaken")
|
||||
table.insert(tokensTaken[mode], guid)
|
||||
manager.setVar("tokensTaken", tokensTaken)
|
||||
manager.setVar("mode", mode)
|
||||
printToAll("Sealing " .. mode .. " token " .. manager.call("getTokenCount"))
|
||||
end
|
||||
|
||||
function releaseTokens(playerColor)
|
||||
if #sealedTokens == 0 then return end
|
||||
local token = sealedTokens[#sealedTokens]
|
||||
if token ~= nil then
|
||||
local guid = token.getGUID()
|
||||
chaosbag.putObject(token)
|
||||
local tokensTaken = manager.getVar("tokensTaken")
|
||||
for i,v in ipairs(tokensTaken[mode]) do
|
||||
if v == guid then
|
||||
table.remove(tokensTaken[mode], i)
|
||||
break
|
||||
end
|
||||
end
|
||||
manager.setVar("tokensTaken", tokensTaken)
|
||||
manager.setVar("mode", mode)
|
||||
printToAll("Releasing " .. mode .. " token" .. manager.call("getTokenCount"))
|
||||
end
|
||||
|
||||
table.remove(sealedTokens)
|
||||
end
|
||||
|
||||
function getChaosBag()
|
||||
local items = getObjectFromGUID("83ef06").getObjects()
|
||||
local chaosbag = nil
|
||||
for i,v in ipairs(items) do
|
||||
if v.getDescription() == "Chaos Bag" then
|
||||
chaosbag = getObjectFromGUID(v.getGUID())
|
||||
break
|
||||
end
|
||||
end
|
||||
if chaosbag == nil then printToAll("No chaos bag found") end
|
||||
return chaosbag
|
||||
end
|
||||
require("playercards/CardsThatSealTokens")
|
||||
|
@ -1,67 +1,8 @@
|
||||
VALID_TOKENS = {
|
||||
Skull=true,
|
||||
Cultist=true,
|
||||
Tablet=true,
|
||||
["Elder Thing"]=true
|
||||
["Skull"] = true,
|
||||
["Cultist"] = true,
|
||||
["Tablet"] = true,
|
||||
["Elder Thing"] = true,
|
||||
}
|
||||
|
||||
function onload()
|
||||
chaosbag = getChaosBag()
|
||||
sealedTokens = { }
|
||||
IMAGE_TOKEN_MAP = { }
|
||||
for i,v in pairs(Global.getVar("IMAGE_TOKEN_MAP")) do
|
||||
IMAGE_TOKEN_MAP[i] = v
|
||||
end
|
||||
|
||||
-- add menu items
|
||||
self.clearContextMenu()
|
||||
self.addContextMenuItem("Release Token", releaseTokens)
|
||||
for url,name in pairs(IMAGE_TOKEN_MAP) do
|
||||
if VALID_TOKENS[name] ~= nil then
|
||||
self.addContextMenuItem("Seal " .. name, function(playerColor) sealToken(url, playerColor) end)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function sealToken(url, playerColor)
|
||||
local pos = self.getPosition()
|
||||
|
||||
local name = IMAGE_TOKEN_MAP[url]
|
||||
for i,obj in ipairs(chaosbag.getObjects()) do
|
||||
if obj.name == name then
|
||||
chaosbag.takeObject({
|
||||
position={ pos.x, pos.y + 1, pos.z },
|
||||
index=i-1,
|
||||
smooth=false,
|
||||
callback_function=_sealToken
|
||||
})
|
||||
return
|
||||
end
|
||||
end
|
||||
printToColor(name .. " token not found in bag", playerColor)
|
||||
end
|
||||
|
||||
function _sealToken(obj)
|
||||
table.insert(sealedTokens, obj)
|
||||
end
|
||||
|
||||
function releaseTokens(playerColor)
|
||||
printToColor("Releasing token", playerColor)
|
||||
for i,obj in ipairs(sealedTokens) do
|
||||
chaosbag.putObject(obj)
|
||||
end
|
||||
sealedTokens = { }
|
||||
end
|
||||
|
||||
function getChaosBag()
|
||||
local items = getObjectFromGUID("83ef06").getObjects()
|
||||
local chaosbag = nil
|
||||
for i,v in ipairs(items) do
|
||||
if v.getDescription() == "Chaos Bag" then
|
||||
chaosbag = getObjectFromGUID(v.getGUID())
|
||||
break
|
||||
end
|
||||
end
|
||||
if chaosbag == nil then printToAll("No chaos bag found") end
|
||||
return chaosbag
|
||||
end
|
||||
require("playercards/CardsThatSealTokens")
|
||||
|
@ -1,67 +1,8 @@
|
||||
VALID_TOKENS = {
|
||||
Skull=true,
|
||||
Cultist=true,
|
||||
Tablet=true,
|
||||
["Elder Thing"]=true
|
||||
["Skull"] = true,
|
||||
["Cultist"] = true,
|
||||
["Tablet"] = true,
|
||||
["Elder Thing"] = true,
|
||||
}
|
||||
|
||||
function onload()
|
||||
chaosbag = getChaosBag()
|
||||
sealedTokens = { }
|
||||
IMAGE_TOKEN_MAP = { }
|
||||
for i,v in pairs(Global.getVar("IMAGE_TOKEN_MAP")) do
|
||||
IMAGE_TOKEN_MAP[i] = v
|
||||
end
|
||||
|
||||
-- add menu items
|
||||
self.clearContextMenu()
|
||||
self.addContextMenuItem("Release Token", releaseTokens)
|
||||
for url,name in pairs(IMAGE_TOKEN_MAP) do
|
||||
if VALID_TOKENS[name] ~= nil then
|
||||
self.addContextMenuItem("Seal " .. name, function(playerColor) sealToken(url, playerColor) end)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function sealToken(url, playerColor)
|
||||
local pos = self.getPosition()
|
||||
|
||||
local name = IMAGE_TOKEN_MAP[url]
|
||||
for i,obj in ipairs(chaosbag.getObjects()) do
|
||||
if obj.name == name then
|
||||
chaosbag.takeObject({
|
||||
position={ pos.x, pos.y + 1, pos.z },
|
||||
index=i-1,
|
||||
smooth=false,
|
||||
callback_function=_sealToken
|
||||
})
|
||||
return
|
||||
end
|
||||
end
|
||||
printToColor(name .. " token not found in bag", playerColor)
|
||||
end
|
||||
|
||||
function _sealToken(obj)
|
||||
table.insert(sealedTokens, obj)
|
||||
end
|
||||
|
||||
function releaseTokens(playerColor)
|
||||
printToColor("Releasing token", playerColor)
|
||||
for i,obj in ipairs(sealedTokens) do
|
||||
chaosbag.putObject(obj)
|
||||
end
|
||||
sealedTokens = { }
|
||||
end
|
||||
|
||||
function getChaosBag()
|
||||
local items = getObjectFromGUID("83ef06").getObjects()
|
||||
local chaosbag = nil
|
||||
for i,v in ipairs(items) do
|
||||
if v.getDescription() == "Chaos Bag" then
|
||||
chaosbag = getObjectFromGUID(v.getGUID())
|
||||
break
|
||||
end
|
||||
end
|
||||
if chaosbag == nil then printToAll("No chaos bag found") end
|
||||
return chaosbag
|
||||
end
|
||||
require("playercards/CardsThatSealTokens")
|
||||
|
@ -1,60 +1,5 @@
|
||||
function onload()
|
||||
chaosbag = getChaosBag()
|
||||
sealedTokens = { }
|
||||
IMAGE_TOKEN_MAP = { }
|
||||
for i,v in pairs(Global.getVar("IMAGE_TOKEN_MAP")) do
|
||||
IMAGE_TOKEN_MAP[i] = v
|
||||
end
|
||||
VALID_TOKENS = {
|
||||
["Elder Sign"] = true
|
||||
}
|
||||
|
||||
-- add menu items
|
||||
self.clearContextMenu()
|
||||
self.addContextMenuItem("Release Token", releaseTokens)
|
||||
for url,name in pairs(IMAGE_TOKEN_MAP) do
|
||||
if name == "Elder Sign" then
|
||||
self.addContextMenuItem("Seal Elder Sign", function(playerColor) sealToken(url, playerColor) end)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function sealToken(url, playerColor)
|
||||
local pos = self.getPosition()
|
||||
|
||||
local name = IMAGE_TOKEN_MAP[url]
|
||||
for i,obj in ipairs(chaosbag.getObjects()) do
|
||||
if obj.name == name then
|
||||
chaosbag.takeObject({
|
||||
position={ pos.x, pos.y + 1, pos.z },
|
||||
index=i-1,
|
||||
smooth=false,
|
||||
callback_function=_sealToken
|
||||
})
|
||||
return
|
||||
end
|
||||
end
|
||||
printToColor(name .. " token not found in bag", playerColor)
|
||||
end
|
||||
|
||||
function _sealToken(obj)
|
||||
table.insert(sealedTokens, obj)
|
||||
end
|
||||
|
||||
function releaseTokens(playerColor)
|
||||
printToColor("Releasing token", playerColor)
|
||||
for i,obj in ipairs(sealedTokens) do
|
||||
chaosbag.putObject(obj)
|
||||
end
|
||||
sealedTokens = { }
|
||||
end
|
||||
|
||||
function getChaosBag()
|
||||
local items = getObjectFromGUID("83ef06").getObjects()
|
||||
local chaosbag = nil
|
||||
for i,v in ipairs(items) do
|
||||
if v.getDescription() == "Chaos Bag" then
|
||||
chaosbag = getObjectFromGUID(v.getGUID())
|
||||
break
|
||||
end
|
||||
end
|
||||
if chaosbag == nil then printToAll("No chaos bag found") end
|
||||
return chaosbag
|
||||
end
|
||||
require("playercards/CardsThatSealTokens")
|
||||
|
Loading…
Reference in New Issue
Block a user