1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2025-02-13 13:49:35 +02:00

Additional fish market items, and add ons to the player gui

This commit is contained in:
TWLTriston 2017-10-15 06:58:24 -04:00
parent 348096bb87
commit 3d6a105dd2
3 changed files with 73 additions and 10 deletions

View File

@ -10,6 +10,7 @@ global.scenario.variables.mods = require "locale.resources.mods"
global.scenario.variables.regulars = require "locale.resources.regulars"
global.scenario.variables.player_positions = {}
global.scenario.variables.player_walk_distances = {}
global.scenario.variables.player_deaths = {}
global.scenario.config = {}
global.scenario.custom_functions = {}
global.scenario.config.nuke_min_time_hours = 3 --how long a player must be on the server to be allowed to use the nuke

View File

@ -83,6 +83,17 @@ function spawn_market(cmd)
market.add_market_item{price={{"raw-fish", 175}}, offer={type="give-item", item="fast-loader"}}
market.add_market_item{price={{"raw-fish", 250}}, offer={type="give-item", item="express-loader"}}
market.add_market_item{price={{"raw-fish", 1000}}, offer={type="give-item", item="belt-immunity-equipment"}}
market.add_market_item{price={{"raw-fish", 100}}, offer={type="give-item", item="modular-armor"}}
market.add_market_item{price={{"raw-fish", 500}}, offer={type="give-item", item="power-armor"}}
market.add_market_item{price={{"raw-fish", 2000}}, offer={type="give-item", item="power-armor-mk2"}}
market.add_market_item{price={{"raw-fish", 150}}, offer={type="give-item", item="personal-roboport-equipment"}}
market.add_market_item{price={{"raw-fish", 1500}}, offer={type="give-item", item="personal-roboport-mk2-equipment"}}
market.add_market_item{price={{"raw-fish", 50}}, offer={type="give-item", item="construction-robot", count=10}}
market.add_market_item{price={{"raw-fish", 50}}, offer={type="give-item", item="solar-panel-equipment", count=1}}
market.add_market_item{price={{"raw-fish", 50}}, offer={type="give-item", item="battery-equipment", count=1}}
market.add_market_item{price={{"raw-fish", 750}}, offer={type="give-item", item="battery-mk2-equipment", count=1}}
market.add_market_item{price={{"raw-fish", 2000}}, offer={type="give-item", item="fusion-reactor-equipment", count=1}}
market.add_market_item{price={{"raw-fish", 100}}, offer={type="give-item", item="exoskeleton-equipment"}}
end
@ -94,6 +105,7 @@ local total_fish_market_messages = #fish_market_message
local total_fish_market_bonus_messages = #fish_market_bonus_message
if not global.fish_market_fish_caught then global.fish_market_fish_caught = {} end
if not global.fish_market_fish_spent then global.fish_market_fish_spent = {} end
local function fish_earned(event, amount)
@ -101,9 +113,9 @@ local function fish_earned(event, amount)
player.insert { name = "raw-fish", count = amount }
if global.fish_market_fish_caught[event.player_index] then
global.fish_market_fish_caught[event.player_index] = global.fish_market_fish_caught[event.player_index] + 1
global.fish_market_fish_caught[event.player_index] = global.fish_market_fish_caught[event.player_index] + amount
else
global.fish_market_fish_caught[event.player_index] = 1
global.fish_market_fish_caught[event.player_index] = amount
end
if global.fish_market_fish_caught[event.player_index] <= total_fish_market_messages then
@ -225,6 +237,12 @@ local function market_item_purchased(event)
local player = game.players[event.player_index]
-- cost
market_items = event.market.get_market_items()
market_item = market_items[event.offer_index]
fish_cost = market_item.price[1].amount * event.count
global.fish_market_fish_spent[event.player_index] = global.fish_market_fish_spent[event.player_index] + fish_cost
if event.offer_index == 1 then -- exoskeleton-equipment
player.get_inventory(defines.inventory.player_main).remove({name="exoskeleton-equipment", count=event.count})
boost_player_runningspeed(player)

View File

@ -27,6 +27,10 @@ local function on_player_joined_game(event)
global.poke_spam_protection[event.player_index] = game.tick
if not global.player_list_pokes_counter then global.player_list_pokes_counter = {} end
if not global.scenario.variables.player_deaths[player.name] then global.scenario.variables.player_deaths[player.name] = 0 end
if not global.fish_market_fish_caught[event.player_index] then global.fish_market_fish_caught[event.player_index] = 0 end
if not global.fish_market_fish_spent[event.player_index] then global.fish_market_fish_spent[event.player_index] = 0 end
if player.gui.top.player_list_button == nil then
local button = player.gui.top.add({ type = "sprite-button", name = "player_list_button", sprite = "item/heavy-armor" })
button.style.minimal_height = 38
@ -184,14 +188,14 @@ local function player_list_show(player, sort_by)
player.gui.left.direction = "horizontal"
local frame = player.gui.left.add { type = "frame", name = "player-list-panel", direction = "vertical" }
frame.style.minimal_width = 540
frame.style.minimal_width = 650
frame.style.top_padding = 8
frame.style.left_padding = 8
frame.style.right_padding = 8
frame.style.bottom_padding = 8
local player_list_panel_header_table = frame.add { type = "table", name = "player_list_panel_header_table", colspan = 5 }
local player_list_panel_header_table = frame.add { type = "table", name = "player_list_panel_header_table", colspan = 7 }
local label = player_list_panel_header_table.add { type = "label", name = "player_list_panel_header_1", caption = " " .. #game.connected_players }
label.style.font = "default-game"
@ -223,8 +227,26 @@ local function player_list_show(player, sort_by)
local label = player_list_panel_header_table.add { type = "label", name = "player_list_panel_header_4", caption = str .. "Distance walked" }
label.style.font = "default-listbox"
label.style.font_color = { r=0.98, g=0.66, b=0.22}
label.style.minimal_width = 160
label.style.maximal_width = 160
label.style.minimal_width = 150
label.style.maximal_width = 150
str = ""
if sort_by == "fish_asc" then str = symbol_asc .. " " end
if sort_by == "fish_desc" then str = symbol_desc .. " " end
local label = player_list_panel_header_table.add { type = "label", name = "player_list_panel_header_fish", caption = str .. "Fish (Caught/Used)" }
label.style.font = "default-listbox"
label.style.font_color = { r=0.98, g=0.66, b=0.22}
label.style.minimal_width = 150
label.style.maximal_width = 150
str = ""
if sort_by == "deaths_asc" then str = symbol_asc .. " " end
if sort_by == "deaths_desc" then str = symbol_desc .. " " end
local label = player_list_panel_header_table.add { type = "label", name = "player_list_panel_header_deaths", caption = str .. "Deaths" }
label.style.font = "default-listbox"
label.style.font_color = { r=0.98, g=0.66, b=0.22}
label.style.minimal_width = 80
label.style.maximal_width = 80
str = ""
if sort_by == "pokes_asc" then str = symbol_asc .. " " end
@ -235,10 +257,10 @@ local function player_list_show(player, sort_by)
label.style.minimal_width = 35
local player_list_panel_table = frame.add { type = "scroll-pane", name = "scroll_pane", direction = "vertical", horizontal_scroll_policy = "never", vertical_scroll_policy = "auto"}
player_list_panel_table.style.maximal_height = 530
player_list_panel_table.style.maximal_height = 650
player_list_panel_table = player_list_panel_table.add { type = "table", name = "player_list_panel_table", colspan = 5 }
player_list_panel_table = player_list_panel_table.add { type = "table", name = "player_list_panel_table", colspan = 7 }
local player_list = get_sorted_list(sort_by)
@ -262,8 +284,16 @@ local function player_list_show(player, sort_by)
label.style.maximal_width = 130
local label = player_list_panel_table.add { type = "label", name = "player_list_panel_player_distance_" .. i, caption = round(global.scenario.variables.player_walk_distances[player_list[i].name]/1000, 1) .. " km" }
label.style.minimal_width = 160
label.style.maximal_width = 160
label.style.minimal_width = 150
label.style.maximal_width = 150
local label = player_list_panel_table.add { type = "label", name = "player_list_panel_player_fish" .. i, caption = global.fish_market_fish_caught[player_list[i].player_index] .. " / " .. global.fish_market_fish_spent[player_list[i].player_index] }
label.style.minimal_width = 150
label.style.maximal_width = 150
local label = player_list_panel_table.add { type = "label", name = "player_list_panel_player_deaths" .. i, caption = global.scenario.variables.player_deaths[player_list[i].name] }
label.style.minimal_width = 80
label.style.maximal_width = 80
local flow = player_list_panel_table.add { type = "flow", name = "button_flow_" .. i, direction = "horizontal" }
@ -368,5 +398,19 @@ function player_list_on_12_seconds()
end
end
end
function on_player_died( event_player, cause )
game.print(serpent.block(event_player))
player = game.players[event_player.player_index]
game.print(serpent.block(player))
game.print(player.name .. " Died")
if not global.scenario.variables.player_deaths[player.name] then
global.scenario.variables.player_deaths[player.name] = 0
end
global.scenario.variables.player_deaths[player.name] = global.scenario.variables.player_deaths[player.name] + 1
end
Event.register(defines.events.on_player_joined_game, on_player_joined_game)
Event.register(defines.events.on_gui_click, on_gui_click)
Event.register(defines.events.on_player_died, on_player_died)