1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2024-12-12 10:04:40 +02:00

Merge pull request #617 from iltar/fish-market-new-gui

Fish market with new GUI and stack limit
This commit is contained in:
Matthew 2019-01-09 12:41:08 -05:00 committed by GitHub
commit 75274a8c87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 205 additions and 501 deletions

View File

@ -16,6 +16,14 @@ global.config = {
-- New Scenario Features, appears in the "What's new" tab
new_info_key = 'Nothing is new. The world is at peace',
},
-- saves players' lives if they have a small-plane in their inventory, also adds the small-plane to the market and must therefor be loaded first
train_saviour = {
enabled = true,
},
-- Adds the infinite storage chest to the market and adds a custom GUI to it. Also has to be loaded first due to adding a market item
infinite_storage_chest = {
enabled = false,
},
-- adds a command to scale UPS and movement speed. Use with caution as it might break scenarios that modify movement speed
performance = {
enabled = true,
@ -52,7 +60,6 @@ global.config = {
-- adds a fish market
fish_market = {
enabled = true,
market_item = market_item,
},
-- adds anti-nuke griefing
nuke_control = {
@ -181,10 +188,6 @@ global.config = {
donator_messages = {
enabled = true,
},
-- saves players' lives if they have a small-plane in their inventory, also adds the small-plan to the market
train_saviour = {
enabled = true,
},
player_colors = {
enabled = true,
},

View File

@ -17,6 +17,12 @@ require 'features.player_create'
require 'features.user_groups'
-- Feature modules, each can be disabled safely
if config.train_saviour.enabled then
require 'features.train_saviour'
end
if config.infinite_storage_chest.enabled then
require 'features.infinite_storage_chest'
end
if config.autodeconstruct.enabled then
require 'features.autodeconstruct'
end
@ -35,9 +41,6 @@ end
if config.donator_messages.enabled then
require 'features.donator_messages'
end
if config.train_saviour.enabled then
require 'features.train_saviour'
end
if config.fish_market.enabled then
require 'features.fish_market'
end

View File

@ -1,24 +1,30 @@
--[[
Hello there script explorer!
With this you can add a "Fish Market" to your World
You can earn fish by killing alot of biters or by mining wood, ores, rocks.
To spawn the market, do "/market" in your chat ingame as the games host.
It will spawn a few tiles north of the current position where your character is.
---MewMew---
--]]
local Event = require 'utils.event'
local Token = require 'utils.token'
local Task = require 'utils.task'
local PlayerStats = require 'features.player_stats'
local Game = require 'utils.game'
local Command = require 'utils.command'
local Market_items = require 'resources.market_items'
local market_item = Market_items.market_item
local Retailer = require 'features.retailer'
local market_items = require 'resources.market_items'
local fish_market_bonus_message = require 'resources.fish_messages'
local pairs = pairs
local random = math.random
local format = string.format
local get_random = table.get_random
local running_speed_boost_messages = {
'%s found the lost Dragon Scroll and got a lv.1 speed boost!',
'Guided by Master Oogway, %s got a lv.2 speed boost!',
'Kung Fu Master %s defended the village and was awarded a lv.3 speed boost!',
'Travelled at the speed of light. %s saw a black hole. Oops.',
}
local mining_speed_boost_messages = {
'%s is going on a tree harvest!',
'In search of a sharper axe, %s got a lv.2 mining boost!',
'Wood fiend, %s, has picked up a massive chain saw and is awarded a lv.3 mining boost!',
'Better learn to control that saw, %s, chopped off their legs. Oops.',
}
local function spawn_market(_, player)
local surface = player.surface
@ -27,29 +33,24 @@ local function spawn_market(_, player)
local pos = player.position
pos.y = pos.y - 4
local market = surface.create_entity {name = 'market', position = pos}
local market = surface.create_entity({name = 'market', position = pos})
market.destructible = false
player.print("Market added. To remove it, highlight it with your cursor and run the command /sc game.player.selected.destroy()")
for _, item in ipairs(Market_items) do
market.add_market_item(item)
Retailer.add_market('fish_market', market)
for _, prototype in pairs(market_items) do
Retailer.set_item('fish_market', prototype)
end
force.add_chart_tag(
surface,
{
icon = {type = 'item', name = market_item},
position = pos,
text = 'Market'
}
)
force.add_chart_tag(surface, {icon = {type = 'item', name = 'coin'}, position = pos, text = 'Market'})
end
local function fish_earned(event, amount)
local player_index = event.player_index
local player = Game.get_player_by_index(player_index)
local stack = {name = market_item, count = amount}
local stack = {name = 'coin', count = amount}
local inserted = player.insert(stack)
local diff = amount - inserted
@ -58,31 +59,25 @@ local function fish_earned(event, amount)
player.surface.spill_item_stack(player.position, stack, true)
end
local fish = PlayerStats.get_coin_earned(player_index)
fish = fish + amount
PlayerStats.set_coin_earned(player_index, fish)
PlayerStats.change_coin_earned(player_index, amount)
if fish % 70 == 0 then
if player and player.valid then
local message = table.get_random(fish_market_bonus_message, true)
if PlayerStats.get_coin_earned(player_index) % 70 == 0 and player and player.valid then
local message = get_random(fish_market_bonus_message, true)
player.print(message)
end
end
end
local function pre_player_mined_item(event)
if event.entity.type == 'simple-entity' then -- Cheap check for rock, may have other side effects
local type = event.entity.type
if type == 'simple-entity' then -- Cheap check for rock, may have other side effects
fish_earned(event, 10)
return
end
if event.entity.type == 'tree' then
local x = math.random(1, 4)
if x == 1 then
if type == 'tree' and random(1, 4) == 1 then
fish_earned(event, 4)
end
end
end
local entity_drop_amount = {
['biter-spawner'] = {low = 5, high = 15},
@ -92,13 +87,9 @@ local entity_drop_amount = {
['big-worm-turret'] = {low = 10, high = 20}
}
local spill_items =
Token.register(
function(data)
local stack = {name = market_item, count = data.count}
data.surface.spill_item_stack(data.position, stack, true)
end
)
local spill_items = Token.register(function(data)
data.surface.spill_item_stack(data.position, {name = 'coin', count = data.count}, true)
end)
local function fish_drop_entity_died(event)
local entity = event.entity
@ -111,20 +102,19 @@ local function fish_drop_entity_died(event)
return
end
local count = math.random(bounds.low, bounds.high)
local count = random(bounds.low, bounds.high)
if count > 0 then
Task.set_timeout_in_ticks(1, spill_items, {count = count, surface = entity.surface, position = entity.position})
end
end
local function reset_player_running_speed(player)
player.character_running_speed_modifier = global.player_speed_boost_records[player.index].pre_boost_modifier
global.player_speed_boost_records[player.index] = nil
end
local function boost_player_running_speed(player, market)
local function boost_player_running_speed(player)
if global.player_speed_boost_records == nil then
global.player_speed_boost_records = {}
end
@ -133,26 +123,21 @@ local function boost_player_running_speed(player, market)
global.player_speed_boost_records[player.index] = {
start_tick = game.tick,
pre_boost_modifier = player.character_running_speed_modifier,
boost_lvl = 0
boost_lvl = 0,
}
end
local boost_msg = {
[1] = '%s found the lost Dragon Scroll and got a lv.1 speed boost!',
[2] = 'Guided by Master Oogway, %s got a lv.2 speed boost!',
[3] = 'Kungfu Master %s defended the village and was awarded a lv.3 speed boost!',
[4] = 'Travelled at the speed of light. %s saw a blackhole. Oops.'
}
global.player_speed_boost_records[player.index].boost_lvl = 1 + global.player_speed_boost_records[player.index].boost_lvl
player.character_running_speed_modifier = 1 + player.character_running_speed_modifier
if global.player_speed_boost_records[player.index].boost_lvl >= 4 then
game.print(string.format(boost_msg[global.player_speed_boost_records[player.index].boost_lvl], player.name))
game.print(format(running_speed_boost_messages[global.player_speed_boost_records[player.index].boost_lvl], player.name))
reset_player_running_speed(player)
player.character.die(player.force, market)
player.character.die(player.force, player.character)
return
end
player.print(string.format(boost_msg[global.player_speed_boost_records[player.index].boost_lvl], player.name))
player.print(format(running_speed_boost_messages[global.player_speed_boost_records[player.index].boost_lvl], player.name))
end
local function reset_player_mining_speed(player)
@ -160,7 +145,7 @@ local function reset_player_mining_speed(player)
global.player_mining_boost_records[player.index] = nil
end
local function boost_player_mining_speed(player, market)
local function boost_player_mining_speed(player)
if global.player_mining_boost_records == nil then
global.player_mining_boost_records = {}
end
@ -169,62 +154,33 @@ local function boost_player_mining_speed(player, market)
global.player_mining_boost_records[player.index] = {
start_tick = game.tick,
pre_mining_boost_modifier = player.character_mining_speed_modifier,
boost_lvl = 0
boost_lvl = 0,
}
end
local boost_msg = {
[1] = '%s is going on a tree harvest!',
[2] = 'In search of a sharper axe, %s got a lv.2 mining boost!',
[3] = 'Wood fiend, %s, has picked up a massive chain saw and is awarded a lv.3 mining boost!',
[4] = 'Better learn to control that saw, %s, chopped off their legs. Oops.'
}
global.player_mining_boost_records[player.index].boost_lvl = 1 + global.player_mining_boost_records[player.index].boost_lvl
player.character_mining_speed_modifier = 1 + player.character_mining_speed_modifier
if global.player_mining_boost_records[player.index].boost_lvl >= 4 then
game.print(string.format(boost_msg[global.player_mining_boost_records[player.index].boost_lvl], player.name))
game.print(format(mining_speed_boost_messages[global.player_mining_boost_records[player.index].boost_lvl], player.name))
reset_player_mining_speed(player)
player.character.die(player.force, market)
player.character.die(player.force, player.character)
return
end
player.print(string.format(boost_msg[global.player_mining_boost_records[player.index].boost_lvl], player.name))
player.print(format(mining_speed_boost_messages[global.player_mining_boost_records[player.index].boost_lvl], player.name))
end
local function market_item_purchased(event)
local market = event.market
if not market or not market.valid then
local function on_market_purchase(event)
local item_name = event.item.name
if item_name == 'temporary-running-speed-bonus' then
boost_player_running_speed(event.player)
return
end
local offer_index = event.offer_index
local player_index = event.player_index
-- cost
local market_item = market.get_market_items()[offer_index]
local fish_cost = market_item.price[1].amount * event.count
PlayerStats.change_coin_spent(player_index, fish_cost)
if event.offer_index == 1 then -- Temporary speed bonus
local player = Game.get_player_by_index(player_index)
boost_player_running_speed(player, market)
if item_name == 'temporary-mining-speed-bonus' then
boost_player_mining_speed(event.player)
return
end
if event.offer_index == 2 then -- Temporary mining bonus
local player = Game.get_player_by_index(player_index)
boost_player_mining_speed(player, market)
end
if event.offer_index == 3 then -- train saviour item
local player = Game.get_player_by_index(player_index)
local train_savior_item = Market_items[offer_index].item
player.insert {name = train_savior_item, count = event.count}
end
end
if not global.pet_command_rotation then
global.pet_command_rotation = 1
end
local function on_180_ticks()
@ -255,8 +211,7 @@ local function on_180_ticks()
end
local function fish_player_crafted_item(event)
local x = math.random(1, 50)
if x == 1 then
if random(1, 50) == 1 then
fish_earned(event, 1)
end
end
@ -269,26 +224,17 @@ local function player_created(event)
end
local count = global.config.player_rewards.info_player_reward and 1 or 10
player.insert {name = market_item, count = count}
player.insert({name = 'coin', count = count})
end
local function init()
Command.add(
'market',
{
Command.add('market', {
description = 'Places a market near you.',
admin_only = true
},
spawn_market
)
admin_only = true,
}, spawn_market)
Event.on_nth_tick(180, on_180_ticks)
Event.add(defines.events.on_pre_player_mined_item, pre_player_mined_item)
Event.add(defines.events.on_entity_died, fish_drop_entity_died)
Event.add(defines.events.on_market_item_purchased, market_item_purchased)
Event.add(Retailer.events.on_market_purchase, on_market_purchase)
Event.add(defines.events.on_player_crafted_item, fish_player_crafted_item)
Event.add(defines.events.on_player_created, player_created)
end
Event.on_init(init)
Event.on_load(init)

View File

@ -250,4 +250,4 @@ Gui.on_custom_close(
)
local market_items = require 'resources.market_items'
table.insert(market_items, {price = {{market_items.market_item, 100}}, offer = {type = 'give-item', item = 'infinity-chest'}})
table.insert(market_items, {price = 100, name = 'infinity-chest', description = 'Stores unlimited quantity of items for up to 48 different item types'})

View File

@ -93,10 +93,8 @@ local memory = {
market_gui_refresh_scheduled = {},
}
Global.register({
memory = memory,
}, function (tbl)
memory = tbl.memory
Global.register(memory, function (tbl)
memory = tbl
end)
local function schedule_market_gui_refresh(group_name)
@ -165,10 +163,12 @@ local function redraw_market_items(data)
end
for i, item in pairs(market_items) do
local stack_limit = item.stack_limit
local stack_count = stack_limit ~= -1 and stack_limit < count and item.stack_limit or count
local price = item.price
local tooltip = {'', item.name_label, format('\nprice: %.2f', price)}
local description = item.description
local total_price = ceil(price * count)
local total_price = ceil(price * stack_count)
local disabled = item.disabled == true
local message
if total_price == 1 then
@ -187,19 +187,19 @@ local function redraw_market_items(data)
if disabled then
insert(tooltip, '\n\n' .. (item.disabled_reason or 'Not available'))
elseif is_missing_coins then
insert(tooltip, '\n\n' .. format('Missing %d coins to buy %d', missing_coins, count))
insert(tooltip, '\n\n' .. format('Missing %d coins to buy %d', missing_coins, stack_count))
end
local button = grid.add({type = 'flow'}).add({
type = 'sprite-button',
name = item_button_name,
sprite = item.sprite,
number = count,
number = stack_count,
tooltip = tooltip,
})
button.style = 'slot_button'
Gui.set_data(button, {index = i, data = data})
Gui.set_data(button, {index = i, data = data, stack_count = stack_count})
local label = grid.add({type = 'label', caption = message})
local label_style = label.style
@ -406,6 +406,7 @@ Gui.on_click(item_button_name, function (event)
local element = event.element
local button_data = Gui.get_data(element)
local data = button_data.data
local stack_count = button_data.stack_count
local item = data.market_items[button_data.index]
@ -421,9 +422,8 @@ Gui.on_click(item_button_name, function (event)
local name = item.name
local price = item.price
local count = data.count
local cost = ceil(price * count)
local cost = ceil(price * stack_count)
local coin_count = player.get_item_count('coin')
if cost > coin_count then
@ -432,8 +432,8 @@ Gui.on_click(item_button_name, function (event)
end
if item.type == 'item' then
local inserted = player.insert({name = name, count = count})
if inserted < count then
local inserted = player.insert({name = name, count = stack_count})
if inserted < stack_count then
player.print('Insufficient inventory space')
if inserted > 0 then
player.remove_item({name = name, count = inserted})
@ -451,7 +451,7 @@ Gui.on_click(item_button_name, function (event)
raise_event(Retailer.events.on_market_purchase, {
item = item,
count = count,
count = stack_count,
player = player,
})
end)
@ -483,6 +483,10 @@ function Retailer.set_item(group_name, prototype)
prototype.sprite = prototype.sprite or 'item/' .. item_name
prototype.type = prototype.type or 'item'
if not prototype.stack_limit then
prototype.stack_limit = -1
end
memory.items[group_name][item_name] = prototype
schedule_market_gui_refresh(group_name)

View File

@ -1,5 +1,5 @@
local Event = require 'utils.event'
local Market_items = require 'resources.market_items'
local market_items = require 'resources.market_items'
local Global = require 'utils.global'
local Donators = require 'resources.donators'
local UserGroups = require 'features.user_groups'
@ -9,17 +9,19 @@ local train_perk_flag = Donators.donator_perk_flags.train
local saviour_token_name = 'small-plane' -- item name for what saves players
local saviour_timeout = 180 -- number of ticks players are train immune after getting hit (roughly)
table.insert(Market_items, 3, {price = {{Market_items.market_item, 100}}, offer = {type = 'nothing', effect_description = 'Train Immunity (+1 ' .. saviour_token_name .. ')\nEach ' .. saviour_token_name .. ' in your inventory will save you\nfrom being killed by a train once\n\nPrice: 100 ' .. Market_items.market_item .. 's'}, item = saviour_token_name})
table.insert(market_items, 3, {
price = 100,
name = saviour_token_name,
name_label = 'Train Immunity (1x use)',
description = 'Each ' .. saviour_token_name .. ' in your inventory will save you from being killed by a train once.',
})
local remove_stack = {name = saviour_token_name, count = 1}
local saved_players = {}
Global.register(
saved_players,
function(tbl)
Global.register(saved_players, function(tbl)
saved_players = tbl
end
)
end)
local train_names = {
['locomotive'] = true,
@ -80,17 +82,8 @@ local function on_pre_death(event)
player.remove_item(remove_stack)
saved_players[player_index] = game_tick
save_player(player)
game.print(
table.concat {
player_name,
' has been saved from a train death. Their ',
saviour_token_name,
' survival item has been consumed.'
}
)
game.print(player_name .. ' has been saved from a train death. One of their Train Immunity items has been consumed.')
end
Event.add(defines.events.on_pre_player_died, on_pre_death)

View File

@ -1,228 +0,0 @@
local Event = require 'utils.event'
local Token = require 'utils.token'
local Task = require 'utils.task'
local PlayerStats = require 'features.player_stats'
local Game = require 'utils.game'
local Utils = require 'utils.core'
local Command = require 'utils.command'
local market_items = require 'resources.market_items'
for _, item in ipairs(market_items) do
local price = item.price[1]
price[1] = 'raw-wood'
price[2] = price[2] * 4
end
market_items[1].offer.effect_description = 'Temporary speed bonus - Price 40 Wood'
market_items[2].offer.effect_description = 'Temporary mining bonus - Price 40 Wood'
table.insert(market_items, {price = {{'raw-wood', 4}}, offer = {type = 'give-item', item = 'raw-fish'}})
local function spawn_market(_, player)
local surface = game.player.surface
local force = player.force
local pos = player.position
pos.y = pos.y - 4
local market = surface.create_entity {name = 'market', position = pos}
market.destructible = false
for _, item in ipairs(market_items) do
market.add_market_item(item)
end
force.add_chart_tag(
surface,
{
icon = {type = 'item', name = 'raw-wood'},
position = pos,
text = 'Market'
}
)
end
local entity_drop_amount = {
--[[['small-biter'] = {low = -62, high = 1},
['small-spitter'] = {low = -62, high = 1},
['medium-biter'] = {low = -14, high = 1},
['medium-spitter'] = {low = -14, high = 1},
['big-biter'] = {low = -2, high = 1},
['big-spitter'] = {low = -2, high = 1},
['behemoth-biter'] = {low = 1, high = 1},
['behemoth-spitter'] = {low = 1, high = 1}, ]]
['biter-spawner'] = {low = 5, high = 15},
['spitter-spawner'] = {low = 5, high = 15},
['small-worm-turret'] = {low = 2, high = 8},
['medium-worm-turret'] = {low = 5, high = 15},
['big-worm-turret'] = {low = 10, high = 20}
}
local spill_items =
Token.register(
function(data)
local stack = {name = 'raw-wood', count = data.count * 4}
data.surface.spill_item_stack(data.position, stack, true)
end
)
local function wood_drop_entity_died(event)
local entity = event.entity
if not entity or not entity.valid then
return
end
local bounds = entity_drop_amount[entity.name]
if not bounds then
return
end
local count = math.random(bounds.low, bounds.high)
if count > 0 then
Task.set_timeout_in_ticks(1, spill_items, {count = count, surface = entity.surface, position = entity.position})
end
end
local function reset_player_runningspeed(player)
player.character_running_speed_modifier = global.player_speed_boost_records[player.index].pre_boost_modifier
global.player_speed_boost_records[player.index] = nil
end
local function boost_player_runningspeed(player, market)
if global.player_speed_boost_records == nil then
global.player_speed_boost_records = {}
end
if global.player_speed_boost_records[player.index] == nil then
global.player_speed_boost_records[player.index] = {
start_tick = game.tick,
pre_boost_modifier = player.character_running_speed_modifier,
boost_lvl = 0
}
end
local boost_msg = {
[1] = '%s found the lost Dragon Scroll and got a lv.1 speed boost!',
[2] = 'Guided by Master Oogway, %s got a lv.2 speed boost!',
[3] = 'Kungfu Master %s defended the village and was awarded a lv.3 speed boost!',
[4] = 'Travelled at the speed of light. %s saw a blackhole. Oops.'
}
global.player_speed_boost_records[player.index].boost_lvl = 1 + global.player_speed_boost_records[player.index].boost_lvl
player.character_running_speed_modifier = 1 + player.character_running_speed_modifier
game.print(string.format(boost_msg[global.player_speed_boost_records[player.index].boost_lvl], player.name))
if global.player_speed_boost_records[player.index].boost_lvl >= 4 then
reset_player_runningspeed(player)
player.character.die(player.force, market)
end
end
local function reset_player_miningspeed(player)
player.character_mining_speed_modifier = global.player_mining_boost_records[player.index].pre_mining_boost_modifier
global.player_mining_boost_records[player.index] = nil
end
local function boost_player_miningspeed(player, market)
if global.player_mining_boost_records == nil then
global.player_mining_boost_records = {}
end
if global.player_mining_boost_records[player.index] == nil then
global.player_mining_boost_records[player.index] = {
start_tick = game.tick,
pre_mining_boost_modifier = player.character_mining_speed_modifier,
boost_lvl = 0
}
end
local boost_msg = {
[1] = '%s is going on a tree harvest!',
[2] = 'In search of a sharper axe, %s got a lv.2 mining boost!',
[3] = 'Wood fiend, %s, has picked up a massive chain saw and is awarded a lv.3 mining boost!',
[4] = 'Better learn to control that saw, %s, chopped off their legs. Oops.'
}
global.player_mining_boost_records[player.index].boost_lvl = 1 + global.player_mining_boost_records[player.index].boost_lvl
player.character_mining_speed_modifier = 1 + player.character_mining_speed_modifier
game.print(string.format(boost_msg[global.player_mining_boost_records[player.index].boost_lvl], player.name))
if global.player_mining_boost_records[player.index].boost_lvl >= 4 then
reset_player_miningspeed(player)
player.character.die(player.force, market)
end
end
local function market_item_purchased(event)
local market = event.market
if not market or not market.valid then
return
end
local offer_index = event.offer_index
local player_index = event.player_index
-- cost
local market_item = market.get_market_items()[offer_index]
local cost = market_item.price[1].amount * event.count
PlayerStats.change_fish_spent(player_index, cost)
if event.offer_index == 1 then -- Temporary speed bonus
local player = Game.get_player_by_index(player_index)
boost_player_runningspeed(player, market)
end
if event.offer_index == 2 then -- Temporary mining bonus
local player = Game.get_player_by_index(player_index)
boost_player_miningspeed(player, market)
end
end
if not global.pet_command_rotation then
global.pet_command_rotation = 1
end
local function on_180_ticks()
if game.tick % 900 == 0 then
if global.player_speed_boost_records then
for k, v in pairs(global.player_speed_boost_records) do
if game.tick - v.start_tick > 3000 then
reset_player_runningspeed(Game.get_player_by_index(k))
end
end
end
if global.player_mining_boost_records then
for k, v in pairs(global.player_mining_boost_records) do
if game.tick - v.start_tick > 6000 then
reset_player_miningspeed(Game.get_player_by_index(k))
end
end
end
end
end
local function player_mined_entity(event)
local buffer = event.buffer
if not buffer or not buffer.valid then
return
end
local count = buffer.get_item_count('raw-wood')
if count > 0 then
PlayerStats.change_fish_earned(event.player_index, count)
end
end
Command.add(
'market',
{
description = 'Places a market near you.',
admin_only = true
},
spawn_market
)
Event.on_nth_tick(180, on_180_ticks)
Event.add(defines.events.on_entity_died, wood_drop_entity_died)
Event.add(defines.events.on_market_item_purchased, market_item_purchased)
Event.add(defines.events.on_player_mined_entity, player_mined_entity)

View File

@ -3,6 +3,8 @@ local Perlin = require 'map_gen.shared.perlin_noise'
local Event = require 'utils.event'
local Global = require 'utils.global'
local math = require "utils.math"
local match = string.match
local remove = table.remove
local oil_seed
local uranium_seed
@ -34,8 +36,11 @@ Global.register_init(
)
local market_items = require 'resources.market_items'
table.remove(market_items, 13)
table.remove(market_items, 9)
for i = #market_items, 1, -1 do
if match(market_items[i].name, 'flamethrower') then
remove(market_items, i)
end
end
Event.add(
defines.events.on_research_finished,

View File

@ -1,11 +1,17 @@
local b = require 'map_gen.shared.builders'
local Event = require 'utils.event'
local Perlin = require 'map_gen.shared.perlin_noise'
local match = string.match
local remove = table.remove
local enemy_seed = 420420
local market_items = require 'resources.market_items'
table.remove(market_items, 8)
for i = #market_items, 1, -1 do
if match(market_items[i].name, 'flamethrower') then
remove(market_items, i)
end
end
Event.add(
defines.events.on_research_finished,

View File

@ -144,7 +144,6 @@ local terrain_modules = {
--require 'map_gen.misc.terraforming' -- prevents players from building on non-terraformed tiles
--require 'map_gen.misc.car_body' -- gives players cars instead of characters
--require 'map_gen.misc.naughty_words' -- admonishes players for cursing
--require 'map_gen.misc.infinite_storage_chest'
if #entity_modules > 0 then
shape = shape or b.full_shape

View File

@ -1,111 +1,84 @@
local market_item = global.config.fish_market.market_item or 'coin'
return {
market_item = market_item,
{
price = {{market_item, 10}},
offer = {type = 'nothing', effect_description = 'Temporary speed bonus \nIncreases running speed by one level \nfor a short period \n\nPrice: 10 ' .. market_item..'s'}
name = 'temporary-running-speed-bonus',
name_label = 'Temporary running speed bonus',
type = 'temporary-buff',
description = 'Increases running speed by one level for a short period',
sprite = 'technology/exoskeleton-equipment',
stack_limit = 1,
price = 10,
},
{
price = {{market_item, 10}},
offer = {type = 'nothing', effect_description = 'Temporary mining bonus \nIncreases manual mining speed by one level \nfor a short period \n\nPrice: 10 ' .. market_item..'s'}
name = 'temporary-mining-speed-bonus',
name_label = 'Temporary mining speed bonus',
type = 'temporary-buff',
description = 'Increases manual mining speed by one level for a short period',
sprite = 'technology/mining-productivity-1',
stack_limit = 1,
price = 10,
},
{price = {{market_item, 2}}, offer = {type = 'give-item', item = 'raw-fish'}},
{price = {{market_item, 1}}, offer = {type = 'give-item', item = 'rail', count = 2}},
{price = {{market_item, 2}}, offer = {type = 'give-item', item = 'rail-signal'}},
{price = {{market_item, 2}}, offer = {type = 'give-item', item = 'rail-chain-signal'}},
{price = {{market_item, 15}}, offer = {type = 'give-item', item = 'train-stop'}},
{price = {{market_item, 75}}, offer = {type = 'give-item', item = 'locomotive'}},
{price = {{market_item, 30}}, offer = {type = 'give-item', item = 'cargo-wagon'}},
{price = {{market_item, 1}}, offer = {type = 'give-item', item = 'red-wire', count = 2}},
{price = {{market_item, 1}}, offer = {type = 'give-item', item = 'green-wire', count = 2}},
{price = {{market_item, 3}}, offer = {type = 'give-item', item = 'decider-combinator'}},
{price = {{market_item, 3}}, offer = {type = 'give-item', item = 'arithmetic-combinator'}},
{price = {{market_item, 3}}, offer = {type = 'give-item', item = 'constant-combinator'}},
{price = {{market_item, 7}}, offer = {type = 'give-item', item = 'programmable-speaker'}},
{price = {{market_item, 15}}, offer = {type = 'give-item', item = 'steel-axe'}},
{price = {{market_item, 15}}, offer = {type = 'give-item', item = 'submachine-gun'}},
{price = {{market_item, 15}}, offer = {type = 'give-item', item = 'shotgun'}},
{price = {{market_item, 250}}, offer = {type = 'give-item', item = 'combat-shotgun'}},
{price = {{market_item, 25}}, offer = {type = 'give-item', item = 'railgun'}},
{price = {{market_item, 250}}, offer = {type = 'give-item', item = 'flamethrower'}},
{price = {{market_item, 175}}, offer = {type = 'give-item', item = 'rocket-launcher'}},
{price = {{market_item, 250}}, offer = {type = 'give-item', item = 'tank-cannon'}},
{price = {{market_item, 750}}, offer = {type = 'give-item', item = 'tank-machine-gun'}},
{price = {{market_item, 75}}, offer = {type = 'give-item', item = 'tank-flamethrower'}},
{price = {{market_item, 2500}}, offer = {type = 'give-item', item = 'artillery-wagon-cannon'}},
{price = {{market_item, 1}}, offer = {type = 'give-item', item = 'firearm-magazine'}},
{price = {{market_item, 5}}, offer = {type = 'give-item', item = 'piercing-rounds-magazine'}},
{price = {{market_item, 20}}, offer = {type = 'give-item', item = 'uranium-rounds-magazine'}},
{price = {{market_item, 2}}, offer = {type = 'give-item', item = 'shotgun-shell'}},
{price = {{market_item, 10}}, offer = {type = 'give-item', item = 'piercing-shotgun-shell'}},
{price = {{market_item, 5}}, offer = {type = 'give-item', item = 'railgun-dart'}},
{price = {{market_item, 25}}, offer = {type = 'give-item', item = 'flamethrower-ammo'}},
{price = {{market_item, 15}}, offer = {type = 'give-item', item = 'rocket'}},
{price = {{market_item, 25}}, offer = {type = 'give-item', item = 'explosive-rocket'}},
{price = {{market_item, 2500}}, offer = {type = 'give-item', item = 'atomic-bomb'}},
{price = {{market_item, 20}}, offer = {type = 'give-item', item = 'cannon-shell'}},
{price = {{market_item, 30}}, offer = {type = 'give-item', item = 'explosive-cannon-shell'}},
{price = {{market_item, 75}}, offer = {type = 'give-item', item = 'explosive-uranium-cannon-shell'}},
{price = {{market_item, 100}}, offer = {type = 'give-item', item = 'artillery-shell'}},
{price = {{market_item, 3}}, offer = {type = 'give-item', item = 'land-mine'}},
{price = {{market_item, 5}}, offer = {type = 'give-item', item = 'grenade'}},
{price = {{market_item, 35}}, offer = {type = 'give-item', item = 'cluster-grenade'}},
{price = {{market_item, 5}}, offer = {type = 'give-item', item = 'defender-capsule'}},
--{price = {{market_item, 15}}, offer = {type = 'give-item', item = 'distractor-capsule'}}, Removed so we dont have 51 items and they are useless anyways
{price = {{market_item, 75}}, offer = {type = 'give-item', item = 'destroyer-capsule'}},
{price = {{market_item, 35}}, offer = {type = 'give-item', item = 'poison-capsule'}},
{price = {{market_item, 35}}, offer = {type = 'give-item', item = 'slowdown-capsule'}},
{price = {{market_item, 50}}, offer = {type = 'give-item', item = 'artillery-targeting-remote'}},
{price = {{market_item, 1000}}, offer = {type = 'give-item', item = 'artillery-turret'}},
{price = {{market_item, 350}}, offer = {type = 'give-item', item = 'modular-armor'}},
{price = {{market_item, 875}}, offer = {type = 'give-item', item = 'power-armor'}},
{price = {{market_item, 40}}, offer = {type = 'give-item', item = 'solar-panel-equipment'}},
{price = {{market_item, 875}}, offer = {type = 'give-item', item = 'fusion-reactor-equipment'}},
{price = {{market_item, 100}}, offer = {type = 'give-item', item = 'battery-equipment'}},
{price = {{market_item, 625}}, offer = {type = 'give-item', item = 'battery-mk2-equipment'}},
{price = {{market_item, 250}}, offer = {type = 'give-item', item = 'belt-immunity-equipment'}},
{price = {{market_item, 100}}, offer = {type = 'give-item', item = 'night-vision-equipment'}},
{price = {{market_item, 150}}, offer = {type = 'give-item', item = 'exoskeleton-equipment'}},
{price = {{market_item, 250}}, offer = {type = 'give-item', item = 'personal-roboport-equipment'}},
{price = {{market_item, 25}}, offer = {type = 'give-item', item = 'construction-robot'}},
{price = {{market_item, 350}}, offer = {type = 'give-item', item = 'energy-shield-equipment'}},
{price = {{market_item, 750}}, offer = {type = 'give-item', item = 'personal-laser-defense-equipment'}},
{price = {{market_item, 1}}, offer = {type = 'give-item', item = 'refined-hazard-concrete'}},
{price = {{market_item, 75}}, offer = {type = 'give-item', item = 'loader'}},
{price = {{market_item, 150}}, offer = {type = 'give-item', item = 'fast-loader'}},
{price = {{market_item, 225}}, offer = {type = 'give-item', item = 'express-loader'}}
--[[ {price = {{market_item, 5}}, offer = {type = 'give-item', item = 'science-pack-1'}},
{price = {{market_item, 10}}, offer = {type = 'give-item', item = 'science-pack-2'}},
{price = {{market_item, 15}}, offer = {type = 'give-item', item = 'science-pack-3'}},
{price = {{market_item, 15}}, offer = {type = 'give-item', item = 'military-science-pack'}},
{price = {{market_item, 20}}, offer = {type = 'give-item', item = 'production-science-pack'}},
{price = {{market_item, 25}}, offer = {type = 'give-item', item = 'high-tech-science-pack'}}, ]]
--[[ {price = {{market_item, 3}}, offer = {type = 'give-item', item = 'piercing-rounds-magazine'}},
{price = {{market_item, 2}}, offer = {type = 'give-item', item = 'grenade'}},
{price = {{market_item, 1}}, offer = {type = 'give-item', item = 'land-mine'}},
{price = {{market_item, 1}}, offer = {type = 'give-item', item = 'solid-fuel'}},
{price = {{market_item, 15}}, offer = {type = 'give-item', item = 'steel-axe'}},
{price = {{market_item, 125}}, offer = {type = 'give-item', item = 'rocket-launcher'}},
{price = {{market_item, 15}}, offer = {type = 'give-item', item = 'rocket'}},
{price = {{market_item, 20}}, offer = {type = 'give-item', item = 'explosive-rocket'}},
{price = {{market_item, 2500}}, offer = {type = 'give-item', item = 'atomic-bomb'}},
{price = {{market_item, 25}}, offer = {type = 'give-item', item = 'railgun'}},
{price = {{market_item, 10}}, offer = {type = 'give-item', item = 'railgun-dart', count = 10}},
{price = {{market_item, 100}}, offer = {type = 'give-item', item = 'loader'}},
{price = {{market_item, 175}}, offer = {type = 'give-item', item = 'fast-loader'}},
{price = {{market_item, 250}}, offer = {type = 'give-item', item = 'express-loader'}},
{price = {{market_item, 500}}, offer = {type = 'give-item', item = 'belt-immunity-equipment'}},
{price = {{market_item, 100}}, offer = {type = 'give-item', item = 'night-vision-equipment'}},
{price = {{market_item, 200}}, offer = {type = 'give-item', item = 'modular-armor'}},
{price = {{market_item, 500}}, offer = {type = 'give-item', item = 'power-armor'}},
{price = {{market_item, 150}}, offer = {type = 'give-item', item = 'personal-roboport-equipment'}},
{price = {{market_item, 50}}, offer = {type = 'give-item', item = 'construction-robot', count = 10}},
{price = {{market_item, 50}}, offer = {type = 'give-item', item = 'solar-panel-equipment', count = 1}},
{price = {{market_item, 50}}, offer = {type = 'give-item', item = 'battery-equipment', count = 1}},
{price = {{market_item, 750}}, offer = {type = 'give-item', item = 'battery-mk2-equipment', count = 1}},
{price = {{market_item, 1000}}, offer = {type = 'give-item', item = 'fusion-reactor-equipment', count = 1}},
{price = {{market_item, 100}}, offer = {type = 'give-item', item = 'exoskeleton-equipment'}} ]]
{price = 2, name = 'raw-fish'},
{price = 0.95, name = 'rail'},
{price = 2, name = 'rail-signal'},
{price = 2, name = 'rail-chain-signal'},
{price = 15, name = 'train-stop'},
{price = 75, name = 'locomotive'},
{price = 30, name = 'cargo-wagon'},
{price = 0.95, name = 'red-wire'},
{price = 0.95, name = 'green-wire'},
{price = 3, name = 'decider-combinator'},
{price = 3, name = 'arithmetic-combinator'},
{price = 3, name = 'constant-combinator'},
{price = 7, name = 'programmable-speaker'},
{price = 15, name = 'steel-axe'},
{price = 15, name = 'submachine-gun'},
{price = 15, name = 'shotgun'},
{price = 250, name = 'combat-shotgun'},
{price = 25, name = 'railgun'},
{price = 250, name = 'flamethrower'},
{price = 175, name = 'rocket-launcher'},
{price = 250, name = 'tank-cannon'},
{price = 750, name = 'tank-machine-gun'},
{price = 75, name = 'tank-flamethrower'},
{price = 2500, name = 'artillery-wagon-cannon'},
{price = 1, name = 'firearm-magazine'},
{price = 5, name = 'piercing-rounds-magazine'},
{price = 20, name = 'uranium-rounds-magazine'},
{price = 2, name = 'shotgun-shell'},
{price = 10, name = 'piercing-shotgun-shell'},
{price = 5, name = 'railgun-dart'},
{price = 25, name = 'flamethrower-ammo'},
{price = 15, name = 'rocket'},
{price = 25, name = 'explosive-rocket'},
{price = 2500, name = 'atomic-bomb'},
{price = 20, name = 'cannon-shell'},
{price = 30, name = 'explosive-cannon-shell'},
{price = 75, name = 'explosive-uranium-cannon-shell'},
{price = 100, name = 'artillery-shell'},
{price = 3, name = 'land-mine'},
{price = 5, name = 'grenade'},
{price = 35, name = 'cluster-grenade'},
{price = 5, name = 'defender-capsule'},
{price = 75, name = 'destroyer-capsule'},
{price = 35, name = 'poison-capsule'},
{price = 35, name = 'slowdown-capsule'},
{price = 50, name = 'artillery-targeting-remote'},
{price = 1000, name = 'artillery-turret'},
{price = 350, name = 'modular-armor'},
{price = 875, name = 'power-armor'},
{price = 40, name = 'solar-panel-equipment'},
{price = 875, name = 'fusion-reactor-equipment'},
{price = 100, name = 'battery-equipment'},
{price = 625, name = 'battery-mk2-equipment'},
{price = 250, name = 'belt-immunity-equipment'},
{price = 100, name = 'night-vision-equipment'},
{price = 150, name = 'exoskeleton-equipment'},
{price = 250, name = 'personal-roboport-equipment'},
{price = 25, name = 'construction-robot'},
{price = 350, name = 'energy-shield-equipment'},
{price = 750, name = 'personal-laser-defense-equipment'},
{price = 1, name = 'refined-hazard-concrete'},
{price = 75, name = 'loader'},
{price = 150, name = 'fast-loader'},
{price = 225, name = 'express-loader'},
}