1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2025-01-18 03:21:47 +02:00

Added the definition of unlockables back into config.lua

Also added a current level tool tip for the "Progress to next level:" label.

Removed some old comments I forgot
This commit is contained in:
SimonFlapse 2018-11-12 22:02:18 +01:00
parent ae78bf47cc
commit da82a748b1
3 changed files with 45 additions and 38 deletions

View File

@ -1,5 +1,4 @@
-- dependencies
local MarketUnlockables = require 'map_gen.Diggy.Feature.MarketUnlockables'
-- this
local Config = {
@ -281,7 +280,31 @@ local Config = {
-- every x ticks it will clear y currency_item
void_chest_frequency = 307,
unlockables = MarketUnlockables.initalize_unlockables(), --Define new items in MarketUnlockables.lua
-- add or remove a table entry to add or remove a unlockable item from the mall.
-- format: {unlock_at_level, price, prototype_name},
unlockables = require('map_gen.Diggy.Feature.MarketUnlockables').initalize_unlockables(
{
{1, 50, 'raw-fish'}, -- unlocks at level 1, price is 50 and the prototype name for fish is raw-fish.
{1, 50, 'steel-axe'},
{1, 20, 'raw-wood'},
{2, 50, 'small-lamp'},
{2, 25, 'stone-brick'},
{2, 125, 'stone-wall'},
{3, 850, 'submachine-gun'},
{3, 850, 'shotgun'},
{3, 50, 'firearm-magazine'},
{3, 50, 'shotgun-shell'},
{3, 500, 'light-armor'},
{11, 750, 'heavy-armor'},
{13, 100, 'piercing-rounds-magazine'},
{13, 100, 'piercing-shotgun-shell'},
{13, 1500, 'modular-armor'},
{16, 1000, 'landfill'},
{30, 250, 'uranium-rounds-magazine'},
{30, 1000, 'combat-shotgun'},
}
),
buffs = { --Define new buffs here
{prototype = {name = 'mining_speed', value = 5}},
{prototype = {name = 'inventory_slot', value = 1}},

View File

@ -247,7 +247,6 @@ local tag_label_item = Gui.uid_name()
local function apply_heading_style(style, width)
style.font = 'default-bold'
--style.align = 'center'
style.width = width
end
@ -259,7 +258,6 @@ local function redraw_heading(data, header)
local heading_table = frame.add({type = 'table', column_count = 2})
apply_heading_style(heading_table.add({type = 'label', name = tag_label_stone, caption = 'Requirement'}).style, 100)
apply_heading_style(heading_table.add({type = 'label', name = tag_label_buff, caption = header_caption}).style, 220)
--apply_heading_style(heading_table.add({type = 'label', name = tag_label_item, caption = 'Item'}).style, 200)
end
local function redraw_progressbar(data)
@ -277,7 +275,7 @@ local function redraw_progressbar(data)
local sent = stone_tracker.stone_sent_to_surface - act_stone
local percentage = (math.floor((sent / range)*10^4))/10^4
apply_heading_style(flow.add({type = 'label', name = 'Diggy.MarketExchange.Frame.Progress.Level', caption = 'Progress to next level:'}).style)
apply_heading_style(flow.add({type = 'label', tooltip = 'Current at level ' .. stone_tracker.current_level, name = 'Diggy.MarketExchange.Frame.Progress.Level', caption = 'Progress to next level:'}).style)
local level_progressbar = flow.add({type = 'progressbar', tooltip = percentage * 100 .. '% stone to next level'})
level_progressbar.style.width = 350
level_progressbar.value = percentage

View File

@ -4,18 +4,22 @@
local MarketUnlockables = {}
local marked_prototype_items = {}
local insert = table.insert
local floor = math.floor
local ceil = math.ceil
local log10 = math.log10
local function market_prototype_add(self_level, self_price, self_name)
function MarketUnlockables.add(self_level, self_price, self_name)
if (not marked_prototype_items[self_level]) then
table.insert(marked_prototype_items, self_level, {})
insert(marked_prototype_items, self_level, {})
end
table.insert(marked_prototype_items[self_level], {price = self_price, name = self_name})
insert(marked_prototype_items[self_level], {price = self_price, name = self_name})
end
function MarketUnlockables.initalize_unlockables()
local levelcost = {}
local unlockables = {}
local prev_number = 0
function MarketUnlockables.initalize_unlockables(items)
local levelcost = {}
local unlockables = {}
local prev_number = 0
for i = 1,100 do
local b = 20 -- Default 20 <-- Controls how much stone is needed.
local start_value = 50 -- The start value/the first level cost
@ -25,44 +29,26 @@ function MarketUnlockables.initalize_unlockables()
--Truncates to the precision and prevents dublicates by incrementing with 5 in the third highest place
local number = formula
local numberlen = math.floor(math.log10(number)+1)
local numberlen = floor(log10(number)+1)
precision = (numberlen >= 8) and (precision+1) or precision
number = number/10^(numberlen-precision)
number = math.floor(number)*10^(numberlen-precision)
number = floor(number)*10^(numberlen-precision)
while (prev_number >= number) do
number = (prev_number > number) and number or number + math.ceil(5*10^(numberlen-3))
number = (prev_number > number) and number or number + ceil(5*10^(numberlen-3))
end
levelcost[i] = number
prev_number = number
end
-- Add new market unlockables here
-- market_prototype_add(unlock_level, price, prototype_name)
market_prototype_add(1, 50, 'raw-fish')
market_prototype_add(1, 50, 'steel-axe')
market_prototype_add(2, 50, 'small-lamp')
market_prototype_add(2, 25, 'stone-brick')
market_prototype_add(2, 125, 'stone-wall')
market_prototype_add(3, 850, 'submachine-gun')
market_prototype_add(3, 850, 'shotgun')
market_prototype_add(3, 50, 'firearm-magazine')
market_prototype_add(3, 50, 'shotgun-shell')
market_prototype_add(3, 500, 'light-armor')
market_prototype_add(11, 750, 'heavy-armor')
market_prototype_add(13, 100, 'piercing-rounds-magazine')
market_prototype_add(13, 100, 'piercing-shotgun-shell')
market_prototype_add(13, 1500, 'modular-armor')
market_prototype_add(16, 1000, 'landfill')
market_prototype_add(30, 250, 'uranium-rounds-magazine')
market_prototype_add(30, 1000, 'combat-shotgun')
market_prototype_add(1, 20, 'raw-wood')
-- handles the unlockables from Config.lua in map_gen.Diggy
for _, item in pairs(items) do
MarketUnlockables.add(item[1], item[2], item[3])
end
for lvl, v in pairs(marked_prototype_items) do
for _, w in ipairs(v) do
table.insert(unlockables, {level = lvl, stone = levelcost[lvl], type = 'market', prototype = w})
insert(unlockables, {level = lvl, stone = levelcost[lvl], type = 'market', prototype = w})
end
end