Skip to content

Commit

Permalink
Danger ores quality (#1439)
Browse files Browse the repository at this point in the history
* Init Factorio 2.0 update

* add credits

* fix test module

* I know luackeck, I know

* Fixes

* Fix bad event.player_index handling

* Hotfixes

* Remove all filter inserters

* Migrate removed items

* Deprecating spidertron control and landfill features

* Small updates and DO preset
  • Loading branch information
RedRafe authored Oct 26, 2024
1 parent 26e1c28 commit 96860dc
Show file tree
Hide file tree
Showing 15 changed files with 365 additions and 36 deletions.
9 changes: 4 additions & 5 deletions features/gui/shortcuts.lua
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,10 @@ function Public.get_main_frame(player)
type = 'frame',
name = main_frame_name,
direction = 'horizontal',
style = 'quick_bar_window_frame',
style = 'quick_bar_slot_window_frame',
}
main_frame.auto_center = true
Gui.set_style(main_frame, { minimal_width = 20 })

do -- shortcuts
local left_flow = main_frame.add { type = 'flow', direction = 'vertical' }
Expand Down Expand Up @@ -174,7 +175,7 @@ function Public.get_main_frame(player)
for button_name, s in pairs(enabled_shortcuts()) do
button = table.add {
type = 'sprite-button',
style = 'quick_bar_slot_button',
style = 'slot_button', --quick_bar_page_button
sprite = s.sprite,
hovered_sprite = s.hovered_sprite,
tooltip = s.tooltip,
Expand All @@ -200,9 +201,7 @@ function Public.get_main_frame(player)
type = 'sprite-button',
name = settings_button_name,
style = 'shortcut_bar_expand_button',
sprite = 'utility/expand_dots_white',
hovered_sprite = 'utility/expand_dots',
clicked_sprite = 'utility/expand_dots',
sprite = 'utility/expand_dots',
tooltip = {'player_shortcuts.settings_tooltip'},
mouse_button_filter = { 'left' },
auto_toggle = true,
Expand Down
17 changes: 14 additions & 3 deletions features/player_stats.lua
Original file line number Diff line number Diff line change
Expand Up @@ -308,12 +308,23 @@ local function rocket_launched(event)

change_for_global(rockets_launched_name, 1)

local inventory = entity.get_inventory(defines.inventory.rocket_silo_rocket)
if not inventory or not inventory.valid then
local pod = entity.cargo_pod
if not pod or not pod.valid then
return
end

local count = inventory.get_item_count('satellite')
local count = 0
local qualities = prototypes.quality
for k = 1, pod.get_max_inventory_index() do
local inventory = pod.get_inventory(k)
if inventory then
local add = inventory.get_item_count
for tier, _ in pairs(qualities) do
count = count + add({ name = 'satellite', quality = tier })
end
end
end

if count == 0 then
return
end
Expand Down
12 changes: 6 additions & 6 deletions features/redmew_qol.lua
Original file line number Diff line number Diff line change
Expand Up @@ -577,16 +577,16 @@ if config.loaders then

local direction_to_offset_back = {
[0] = {x = 0, y = 1.5},
[2] = {x = -1.5, y = 0},
[4] = {x = 0, y = -1.5},
[6] = {x = 1.5, y = 0}
[4] = {x = -1.5, y = 0},
[8] = {x = 0, y = -1.5},
[12] = {x = 1.5, y = 0}
}

local direction_to_offset_front = {
[0] = {x = 0, y = -1.5},
[2] = {x = 1.5, y = 0},
[4] = {x = 0, y = 1.5},
[6] = {x = -1.5, y = 0}
[4] = {x = 1.5, y = 0},
[8] = {x = 0, y = 1.5},
[12] = {x = -1.5, y = 0}
}

local loaders = {['loader'] = true, ['fast-loader'] = true, ['express-loader'] = true}
Expand Down
2 changes: 1 addition & 1 deletion locale/en/redmew_features.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ instructions=Select a brush tile to replace [item=refined-concrete] and [item=re
no_place_landfill=Coloured concrete can not be placed on landfill tiles.
[death_corpse_tags]
empty_corpse=[color=red][Corpse][/color]Your corpse was empty and has been removed.
empty_corpse=[color=red][Corpse][/color] Your corpse was empty and has been removed.
[dump_offline_inventories]
inventory_location=[color=blue][Corpse][/color] __1__ has been offline __2__ minutes. Their inventory is now available at [gps=__3__,__4__,__5__]
Expand Down
20 changes: 18 additions & 2 deletions map_gen/maps/danger_ores/config/vanilla_allowed_entities.lua
Original file line number Diff line number Diff line change
@@ -1,27 +1,43 @@
return {
-- pipes
'pipe',
'pipe-to-ground',
-- belts
'transport-belt',
'fast-transport-belt',
'express-transport-belt',
-- undergrounds
'underground-belt',
'fast-underground-belt',
'express-underground-belt',
-- poles
'small-electric-pole',
'medium-electric-pole',
'big-electric-pole',
'substation',
-- drills
'electric-mining-drill',
'electric-mining-drill-2',
'electric-mining-drill-3',
'burner-mining-drill',
'pumpjack',
-- vehicles
'car',
'tank',
'spidertron',
-- rails
'straight-rail',
'curved-rail',
'curved-rail-a',
'curved-rail-b',
'half-diagonal-rail',
'legacy-straight-rail',
'legacy-curved-rail',
'rail-signal',
'rail-chain-signal',
'train-stop',
'locomotive',
'cargo-wagon',
'fluid-wagon',
'artillery-wagon'
}
'artillery-wagon',
}
30 changes: 30 additions & 0 deletions map_gen/maps/danger_ores/modules/ban_quality_mining.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
-- This module prevents all but the normal quality drills from being built on top of resources
local Event = require 'utils.event'

local function on_built(event)
local entity = event.entity
if not (entity and entity.valid) then
return
end

local e_type = entity.type
if entity.name == 'entity-ghost' then
e_type = entity.ghost_type
end
if e_type ~= 'mining-drill' then
return
end
if entity.quality.level < 1 then
return
end

local index = event.player_index
local player = index and game.get_player(index)
if player and player.valid then
player.print('Only [quality=normal] drills can be built on top of resources!')
end
entity.destroy()
end

Event.add(defines.events.on_built_entity, on_built)
Event.add(defines.events.on_robot_built_entity, on_built)
12 changes: 7 additions & 5 deletions map_gen/maps/danger_ores/modules/banned_entities.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,14 @@ return function(allowed_entities, message)
local items = {}
local len = 0
local entities = RestrictEntities.get_allowed()
for k in pairs(entities) do
for k, _ in pairs(entities) do
local entity = prototypes.entity[k]
for _, v in pairs(entity.items_to_place_this) do
if not items[v.name] then --- Avoid duplication for straight-rail and curved-rail, which both use rail
items[v.name] = v
len = len + 1
if entity then
for _, v in pairs(entity.items_to_place_this or {}) do
if not items[v.name] then --- Avoid duplication for straight-rail and curved-rail, which both use rail
items[v.name] = v
len = len + 1
end
end
end
end
Expand Down
29 changes: 29 additions & 0 deletions map_gen/maps/danger_ores/modules/robot_cargo_capacity.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
-- This module replaces mining productivity research effects with robot cargo capacity effects
local Event = require 'utils.event'

local function starts_with(str, pattern)
return str:sub(1, #pattern) == pattern
end

Event.add(defines.events.on_research_finished, function(event)
local tech = event.research
if not (tech and tech.valid) then
return
end

if not starts_with(tech.name, 'mining-productivity') then
return
end

local force = tech.force
force.mining_drill_productivity_bonus = 0
force.worker_robots_storage_bonus = force.worker_robots_storage_bonus + 1

game.print(table.concat({
'[color=orange][Mining productivity][/color]',
'',
'[color=blue][Worker robots cargo size][/color]',
'\nReplacing technology effects. New robots cargo capacity:',
'[color=green][font=var]+'..force.worker_robots_storage_bonus..'[/font][/color]'
}, '\t\t'))
end)
20 changes: 18 additions & 2 deletions map_gen/maps/danger_ores/modules/rocket_launched.lua
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,24 @@ return function(config)
return
end

local inventory = entity.get_inventory(defines.inventory.rocket_silo_rocket)
if not inventory or not inventory.valid then
local pod = entity.cargo_pod
if not pod or not pod.valid then
return
end

local count = 0
local qualities = prototypes.quality
for k = 1, pod.get_max_inventory_index() do
local inventory = pod.get_inventory(k)
if inventory then
local add = inventory.get_item_count
for tier, _ in pairs(qualities) do
count = count + add({ name = 'satellite', quality = tier })
end
end
end

if count == 0 then
return
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,31 @@ return function()
return
end

local inventory = entity.get_inventory(defines.inventory.rocket_silo_rocket)
if not inventory or not inventory.valid then
local pod = entity.cargo_pod
if not pod or not pod.valid then
return
end

local count = 0
local qualities = prototypes.quality
for k = 1, pod.get_max_inventory_index() do
local inventory = pod.get_inventory(k)
if inventory then
local add = inventory.get_item_count
for tier, _ in pairs(qualities) do
count = count + add({ name = 'satellite', quality = tier })
end
end
end

if count == 0 then
return
end

local satellite_count = game.forces.player.get_item_launched('satellite')
if satellite_count == 0 then
return
end

if satellite_count == 1 then
disable_biters()
end
Expand Down
21 changes: 18 additions & 3 deletions map_gen/maps/danger_ores/modules/rocket_launched_krastorio2.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,31 @@ return function()
return
end

local inventory = entity.get_inventory(defines.inventory.rocket_silo_rocket)
if not inventory or not inventory.valid then
local pod = entity.cargo_pod
if not pod or not pod.valid then
return
end

local count = 0
local qualities = prototypes.quality
for k = 1, pod.get_max_inventory_index() do
local inventory = pod.get_inventory(k)
if inventory then
local add = inventory.get_item_count
for tier, _ in pairs(qualities) do
count = count + add({ name = 'satellite', quality = tier })
end
end
end

if count == 0 then
return
end

local satellite_count = game.forces.player.get_item_launched('satellite')
if satellite_count == 0 then
return
end

if satellite_count == 1 then
disable_biters()
end
Expand Down
21 changes: 18 additions & 3 deletions map_gen/maps/danger_ores/modules/rocket_launched_pyanodon.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,31 @@ return function()
return
end

local inventory = entity.get_inventory(defines.inventory.rocket_silo_rocket)
if not inventory or not inventory.valid then
local pod = entity.cargo_pod
if not pod or not pod.valid then
return
end

local count = 0
local qualities = prototypes.quality
for k = 1, pod.get_max_inventory_index() do
local inventory = pod.get_inventory(k)
if inventory then
local add = inventory.get_item_count
for tier, _ in pairs(qualities) do
count = count + add({ name = 'satellite', quality = tier })
end
end
end

if count == 0 then
return
end

local satellite_count = game.forces.player.get_item_launched('satellite')
if satellite_count == 0 then
return
end

if satellite_count == 1 then
disable_biters()
end
Expand Down
21 changes: 18 additions & 3 deletions map_gen/maps/danger_ores/modules/rocket_launched_simple.lua
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,31 @@ return function(config)
return
end

local inventory = entity.get_inventory(defines.inventory.rocket_silo_rocket)
if not inventory or not inventory.valid then
local pod = entity.cargo_pod
if not pod or not pod.valid then
return
end

local count = 0
local qualities = prototypes.quality
for k = 1, pod.get_max_inventory_index() do
local inventory = pod.get_inventory(k)
if inventory then
local add = inventory.get_item_count
for tier, _ in pairs(qualities) do
count = count + add({ name = 'satellite', quality = tier })
end
end
end

if count == 0 then
return
end

local satellite_count = game.forces.player.get_item_launched('satellite')
if satellite_count == 0 then
return
end

if satellite_count == 1 then
disable_biters()
end
Expand Down
Loading

0 comments on commit 96860dc

Please sign in to comment.