added documentation for difficulty selector code

This commit is contained in:
Chr1Z93 2022-11-15 11:57:28 +01:00
parent 1b2f70b59b
commit 68d49aca98

View File

@ -25,6 +25,7 @@ local NOT_INTERACTABLE = {
local chaosTokens = {} local chaosTokens = {}
local chaosTokensLastMat = nil local chaosTokensLastMat = nil
local IS_RESHUFFLING = false local IS_RESHUFFLING = false
--------------------------------------------------------- ---------------------------------------------------------
-- data for tokens -- data for tokens
--------------------------------------------------------- ---------------------------------------------------------
@ -233,11 +234,10 @@ function returnChaosTokens()
end end
function drawChaostoken(params) function drawChaostoken(params)
findChaosBag()
local mat = params[1] local mat = params[1]
local tokenOffset = params[2] local tokenOffset = params[2]
local isRightClick = params[3] local isRightClick = params[3]
findChaosBag()
-- return token(s) on other playmat first -- return token(s) on other playmat first
if chaosTokensLastMat ~= nil and chaosTokensLastMat ~= mat and #chaosTokens ~= 0 then if chaosTokensLastMat ~= nil and chaosTokensLastMat ~= mat and #chaosTokens ~= 0 then
@ -368,6 +368,9 @@ end
-- Difficulty selector script -- Difficulty selector script
--------------------------------------------------------- ---------------------------------------------------------
-- called for button creation on the difficulty selectors
---@param object object Usually "self"
---@param key string Name of the scenario
function createSetupButtons(args) function createSetupButtons(args)
local data = getDataValue('modeData', args.key) local data = getDataValue('modeData', args.key)
if data ~= nil then if data ~= nil then
@ -415,6 +418,10 @@ function createSetupButtons(args)
end end
end end
-- called for adding chaos tokens
---@param object object Usually "self"
---@param key string Name of the scenario
---@param mode string diffculty (e.g. "hard" or "expert")
function fillContainer(args) function fillContainer(args)
findChaosBag() findChaosBag()
@ -464,8 +471,13 @@ function fillContainer(args)
end end
end end
if value.message then broadcastToAll(value.message) end if value.message then
if value.warning then broadcastToAll(value.warning, { 1, 0.5, 0.5 }) end broadcastToAll(value.message)
end
if value.warning then
broadcastToAll(value.warning, { 1, 0.5, 0.5 })
end
end end
end end
@ -509,13 +521,14 @@ function spawnChaosToken(id, pos)
end end
end end
-- chaos bag needs this! -- chaos bag needs this for renaming chaos tokens
function getTokenName(params) function getTokenName(params)
local name = IMAGE_TOKEN_MAP[params.url] local name = IMAGE_TOKEN_MAP[params.url]
if name == nil then name = "" end if name == nil then name = "" end
return name return name
end end
-- returns the image url for a chaos token (identified by the "id")
function getChaosTokenImageURL(id) function getChaosTokenImageURL(id)
if id == 'p1' then return 'https://i.imgur.com/uIx8jbY.png' end if id == 'p1' then return 'https://i.imgur.com/uIx8jbY.png' end
if id == '0' then return 'https://i.imgur.com/btEtVfd.png' end if id == '0' then return 'https://i.imgur.com/btEtVfd.png' end