From 68d49aca987f97b12d3c4df1cf09e853ba4a3632 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Tue, 15 Nov 2022 11:57:28 +0100 Subject: [PATCH] added documentation for difficulty selector code --- src/core/Global.ttslua | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index 986d803c..2e0a201e 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -25,6 +25,7 @@ local NOT_INTERACTABLE = { local chaosTokens = {} local chaosTokensLastMat = nil local IS_RESHUFFLING = false + --------------------------------------------------------- -- data for tokens --------------------------------------------------------- @@ -233,11 +234,10 @@ function returnChaosTokens() end function drawChaostoken(params) - findChaosBag() - local mat = params[1] local tokenOffset = params[2] local isRightClick = params[3] + findChaosBag() -- return token(s) on other playmat first if chaosTokensLastMat ~= nil and chaosTokensLastMat ~= mat and #chaosTokens ~= 0 then @@ -368,6 +368,9 @@ end -- 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) local data = getDataValue('modeData', args.key) if data ~= nil then @@ -415,6 +418,10 @@ function createSetupButtons(args) 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) findChaosBag() @@ -464,8 +471,13 @@ function fillContainer(args) end end - if value.message then broadcastToAll(value.message) end - if value.warning then broadcastToAll(value.warning, { 1, 0.5, 0.5 }) end + if value.message then + broadcastToAll(value.message) + end + + if value.warning then + broadcastToAll(value.warning, { 1, 0.5, 0.5 }) + end end end @@ -509,13 +521,14 @@ function spawnChaosToken(id, pos) end end --- chaos bag needs this! +-- chaos bag needs this for renaming chaos tokens function getTokenName(params) local name = IMAGE_TOKEN_MAP[params.url] if name == nil then name = "" end return name end +-- returns the image url for a chaos token (identified by the "id") function getChaosTokenImageURL(id) if id == 'p1' then return 'https://i.imgur.com/uIx8jbY.png' end if id == '0' then return 'https://i.imgur.com/btEtVfd.png' end