From f4f644d7210bdc80a96f4f22b4ad49de51cb6b2d Mon Sep 17 00:00:00 2001 From: TWLTriston Date: Sun, 15 Oct 2017 07:33:51 -0400 Subject: [PATCH] Additional ways to earn fish by contributing to the factory --- fish_market.lua | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/fish_market.lua b/fish_market.lua index 8d4edaa1..abd5a0a3 100644 --- a/fish_market.lua +++ b/fish_market.lua @@ -57,7 +57,7 @@ function spawn_market(cmd) local market = surface.create_entity{name="market", position=market_location, force=force} market.destructible = false - market.add_market_item{price={{"raw-fish", 10}}, offer={type="give-item", item="exoskeleton-equipment"}} + market.add_market_item{price={{"raw-fish", 10}}, offer={type="give-item", item="discharge-defense-remote"}} market.add_market_item{price={{"raw-fish", 30}}, offer={type="give-item", item="small-plane"}} market.add_market_item{price={{"raw-fish", 1}}, offer={type="give-item", item="rail", count=2}} market.add_market_item{price={{"raw-fish", 2}}, offer={type="give-item", item="rail-signal"}} @@ -79,11 +79,13 @@ function spawn_market(cmd) market.add_market_item{price={{"raw-fish", 15}}, offer={type="give-item", item="rocket"}} market.add_market_item{price={{"raw-fish", 20}}, offer={type="give-item", item="explosive-rocket"}} market.add_market_item{price={{"raw-fish", 2500}}, offer={type="give-item", item="atomic-bomb"}} + market.add_market_item{price={{"raw-fish", 25}}, offer={type="give-item", item="railgun"}} + market.add_market_item{price={{"raw-fish", 10}}, offer={type="give-item", item="railgun-dart", count=10}} market.add_market_item{price={{"raw-fish", 100}}, offer={type="give-item", item="loader"}} 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", 200}}, 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"}} @@ -242,7 +244,7 @@ local function market_item_purchased(event) 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) @@ -339,7 +341,35 @@ function fish_market_on_180_ticks() end end +function fish_built_entity (event) + entity = event.created_entity + if entity.type == "entity-ghost" then + -- No reward for ghosts / bps + return + end + + -- player_index = event.player_index + + if entity.type == "furnace" then + local x = math.random(1,5) + if x == 1 then + fish_earned(event, 5) + end + elseif entity.type == "assembling-machine" then + local x = math.random(1,5) + if x == 1 then + fish_earned(event, 5) + end + elseif entity.type == "mining-drill" then + local x = math.random(1,5) + if x == 1 then + fish_earned(event, 5) + end + end + +end Event.register(defines.events.on_preplayer_mined_item, preplayer_mined_item) Event.register(defines.events.on_entity_died, fish_drop_entity_died) Event.register(defines.events.on_market_item_purchased, market_item_purchased) +Event.register(defines.events.on_built_entity, fish_built_entity)