From ac5f0033227f9ebcc7f6a2bee508b48cb86ea022 Mon Sep 17 00:00:00 2001 From: SimonFlapse Date: Wed, 14 Nov 2018 01:41:39 +0100 Subject: [PATCH] Added luadoc for new files --- map_gen/Diggy/FormatMarketItems.lua | 18 +++++++++++++----- map_gen/Diggy/MarketUnlockables.lua | 5 +++++ 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/map_gen/Diggy/FormatMarketItems.lua b/map_gen/Diggy/FormatMarketItems.lua index 59e29fad..df4f3877 100644 --- a/map_gen/Diggy/FormatMarketItems.lua +++ b/map_gen/Diggy/FormatMarketItems.lua @@ -5,19 +5,27 @@ local FormatMarketItems = {} local market_prototype_items = {} local insert = table.insert - -function FormatMarketItems.add(self_level, self_price, self_name) +--- Returns the correct format for Diggy.Feature.MarketExhange.lua to process +-- @param self_level integer of the level the given item should be unlocked at +-- @param self_price integer of the price in the configured currency_item the given item should cost +-- @param self_name string of the factorio entity prototype-name +-- +local function add(self_level, self_price, self_name) if (not market_prototype_items[self_level]) then insert(market_prototype_items, self_level, {}) end insert(market_prototype_items[self_level], {price = self_price, name = self_name}) end +--- handles the unlockable market items from Config.lua in map_gen.Diggy +-- serves as a handler for an array of items and passes it on to FormatMarketItems.add() that returns the correct format for Diggy.Feature.MarketExhange.lua to process. +-- @param items array of items where each item is an table with keys: level (integer level it unlocks at), price (price in the configured currency_item) and name (has to be an entity's prototype-name) +-- @returns table of items formated in the correct way for Diggy.Feature.MarketExhange.lua to interpret. +-- function FormatMarketItems.initalize_unlockables(items) - local unlockables = {} - -- handles the unlockables from Config.lua in map_gen.Diggy + local unlockables = {} for _, item in ipairs(items) do - FormatMarketItems.add(item.level, item.price, item.name) + add(item.level, item.price, item.name) end for lvl, v in pairs(market_prototype_items) do diff --git a/map_gen/Diggy/MarketUnlockables.lua b/map_gen/Diggy/MarketUnlockables.lua index 00fa9322..b2058bb0 100644 --- a/map_gen/Diggy/MarketUnlockables.lua +++ b/map_gen/Diggy/MarketUnlockables.lua @@ -19,6 +19,11 @@ local function truncate(precision, formula) return number, numberlen end +--- Handles the level requirement to stone sent. Calculates based on a forumla one number corresponding to that levels cost +-- You can configure this in Diggy.Config.lua under features.MarketExhange +-- @param level integer of a level +-- @returns integer of cost corresponding to the level based on a calculation +-- function MarketUnlockables.calculate_level(level) -- all configurable variables must be integers. local b = floor(Config.difficulity_scale) or 25 -- Default 25 <-- Controls how much stone is needed. local start_value = floor(Config.start_stone) or 50 -- The start value/the first level cost