1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2024-12-12 10:04:40 +02:00
This commit is contained in:
grilledham 2019-01-31 17:16:37 +00:00
parent 9775b6446a
commit 370a17fe44
2 changed files with 74 additions and 7 deletions

View File

@ -0,0 +1,53 @@
local Gui = require 'utils.gui'
local Toast = require 'features.gui.toast'
local Retailer = require 'features.retailer'
local Color = require 'resources.color_presets'
local Public = {}
local market_signal = {type = 'virtual', name = 'signal-O'}
local find_outpost_name = Gui.uid_name()
function Public.do_outpost_toast(market, outpost_name, message)
local data = {market = market, outpost_name = outpost_name}
Toast.toast_all_players_template(
15,
function(container)
local sprite =
container.add {
type = 'sprite-button',
name = find_outpost_name,
sprite = 'utility/search_icon',
style = 'slot_button'
}
Gui.set_data(sprite, data)
local label =
container.add {
type = 'label',
name = Toast.close_toast_name,
caption = message
}
local label_style = label.style
label_style.single_line = false
label_style.font_color = Color.lawn_green
end
)
end
Gui.on_click(
find_outpost_name,
function(event)
local player = event.player
local element = event.element
local data = Gui.get_data(element)
local market = data.market
local outpost_name = data.outpost_name
player.add_custom_alert(market, market_signal, outpost_name, true)
end
)
return Public

View File

@ -8,6 +8,7 @@ local PlayerStats = require 'features.player_stats'
local RS = require 'map_gen.shared.redmew_surface'
local Server = require 'features.server'
local Color = require 'resources.color_presets'
local CrashSiteToast = require 'map_gen.presets.crash_site.crash_site_toast'
local table = require 'utils.table'
--local next = next
@ -667,6 +668,7 @@ local function to_shape(blocks, part_size, on_init)
outpost_id = outpost_id,
magic_crafters = {},
--magic_fluid_crafters = {},
market = nil,
turret_count = 0,
top_left = {nil, nil},
bottom_right = {nil, nil},
@ -973,10 +975,11 @@ local function do_outpost_upgrade(event)
local level = outpost_data.level + 1
outpost_data.level = level
local message =
concat({'*** ', Retailer.get_market_group_label(outpost_id), ' has been upgraded to level ', level, ' ***'})
game.print(message, Color.lime_green)
Server.to_discord_bold(message)
local outpost_name = Retailer.get_market_group_label(outpost_id)
local message = concat {outpost_name, ' has been upgraded to level ', level}
CrashSiteToast.do_outpost_toast(outpost_data.market, outpost_name, message)
Server.to_discord_bold(concat {'*** ', message, ' ***'})
for i = 1, #outpost_magic_crafters do
local crafter = outpost_magic_crafters[i]
@ -1041,8 +1044,18 @@ local function do_capture_outpost(outpost_data)
return
end
game.print(concat({'*** ', 'Outpost captured: ' .. name, ' ***'}), Color.lime_green)
Server.to_discord_bold('Outpost captured: ' .. name)
local donators = global.donators
if next(donators) then
local donator = table.get_random_dictionary_entry(donators, true)
if donator then
name = concat({donator, "'s ", name})
Retailer.set_market_group_label(outpost_id, name)
end
end
local message = 'Outpost captured: ' .. name
CrashSiteToast.do_outpost_toast(outpost_data.market, name, message)
Server.to_discord_bold(concat {'*** ', message, ' ***'})
activate_market_upgrade(outpost_data)
end
@ -1446,6 +1459,7 @@ Public.market_set_items_callback =
local outpost_data = outposts[market_id]
local upgrade_base_cost = callback_data.upgrade_base_cost or 0
outpost_data.market = entity
outpost_data.upgrade_rate = callback_data.upgrade_rate
outpost_data.upgrade_base_cost = upgrade_base_cost
outpost_data.upgrade_cost_base = callback_data.upgrade_cost_base
@ -1521,7 +1535,7 @@ function Public.do_random_loot(entity, weights, loot)
end
entity.operable = false
entity.destructible = false
--entity.destructible = false
local i = math.random() * weights.total