1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2025-03-05 15:05:57 +02:00

Added luadoc for new files

This commit is contained in:
SimonFlapse 2018-11-14 01:41:39 +01:00
parent f0a1c44d3d
commit ac5f003322
2 changed files with 18 additions and 5 deletions

View File

@ -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

View File

@ -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