Skip to content

Commit

Permalink
Split up service files
Browse files Browse the repository at this point in the history
Rework furnace recipe handling.
  • Loading branch information
bengardner committed Apr 19, 2024
1 parent f73b52a commit d3e74fd
Show file tree
Hide file tree
Showing 29 changed files with 2,306 additions and 2,099 deletions.
20 changes: 16 additions & 4 deletions control.lua
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
if script.active_mods["gvv"] then require("__gvv__.gvv")() end

-- declare global
-- declare global 'clog'
clog = require("src.log_console").log

-- need to register for on_tick() first
require "src.GlobalState"

require "src.NetworkChest"
Expand All @@ -12,9 +11,22 @@ require "src.NetworkViewUi"
require "src.NetworkViewUi_test"
require "src.NetworkTankGui"

require "src.service_players"
require "src.service_alerts"
require "src.service_queue"
require "src.service_assembling_machine"
require "src.service_car"
require "src.service_generic"
require "src.service_ghost"
require "src.service_furnace"
require "src.service_lab"
require "src.service_logistic_chest"
require "src.service_network_chest"
require "src.service_network_tank"
require "src.service_players"
require "src.service_rocket_silo"
require "src.service_spidertron"
require "src.service_upgrades"

require "src.auto_player_request"
require "src.cheat_production_supply"

require "src.remote_interface"
169 changes: 4 additions & 165 deletions data.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@ local constants = require "src.constants"
local Paths = require "src.Paths"
local Hotkeys = require "src.Hotkeys"

require "src.prototypes.network-sensor"
require "src.prototypes.network-chests"
require "src.prototypes.network-loader"
require "src.prototypes.network-sensor"
require "src.prototypes.network-tanks"

local M = {}

function M.main()
M.add_loader()
-- M.add_network_tank()

-- TODO: does this deserve a separate file?
data:extend(Hotkeys.hotkeys)

-- TODO: move this all to a 'gui' prototypes file?
data:extend({
{ type = "sprite", name = "inet_slot_empty_inset", filename = Paths.graphics .. "/icons/slot-inset-empty.png", width=40, height=40, flags = { "gui-icon" } },
{ type = "sprite", name = "inet_slot_empty_outset", filename = Paths.graphics .. "/icons/slot-outset-empty.png", width=40, height=40, flags = { "gui-icon" } },
Expand Down Expand Up @@ -59,166 +60,4 @@ function M.main()
})
end

function M.add_loader()
local name = "network-loader"

local entity = {
name = "network-loader",
type = "loader-1x1",
icon = Paths.graphics .. "/entities/express-loader.png",
icon_size = 64,
flags = { "placeable-neutral", "player-creation",
"fast-replaceable-no-build-while-moving" },
minable = {
mining_time = 0.2,
result = "network-loader",
},
max_health = 300,
corpse = "small-remnants",
collision_box = { { -0.4, -0.45 }, { 0.4, 0.45 } },
selection_box = { { -0.5, -0.5 }, { 0.5, 0.5 } },
drawing_box = { { -0.4, -0.4 }, { 0.4, 0.4 } },
animation_speed_coefficient = 32,
belt_animation_set = data.raw["transport-belt"]["express-transport-belt"]
.belt_animation_set,
container_distance = 0.75,
belt_length = 0.5,
fast_replaceable_group = "loader",
filter_count = 1,
-- https://wiki.factorio.com/Prototype/TransportBeltConnectable#speed
-- 360 items / sec
speed = 0.75,
structure = {
direction_in = {
sheet = {
filename = Paths.graphics .. "/entities/express-loader.png",
priority = "extra-high",
shift = { 0.15625, 0.0703125 },
width = 106 * 2,
height = 85 * 2,
y = 85 * 2,
scale = 0.25,
},
},
direction_out = {
sheet = {
filename = Paths.graphics .. "/entities/express-loader.png",
priority = "extra-high",
shift = { 0.15625, 0.0703125 },
width = 106 * 2,
height = 85 * 2,
scale = 0.25,
},
},
},
se_allow_in_space = true,
}

local item = {
name = name,
type = "item",
place_result = name,
icon = Paths.graphics .. "/items/express-loader.png",
icon_size = 64,
stack_size = 50,
subgroup = data.raw["item"]["iron-chest"].subgroup,
order = data.raw["item"]["iron-chest"].order,
}

local recipe = {
name = name,
type = "recipe",
enabled = true,
energy_required = 0.5,
ingredients = {},
result = name,
result_count = 1,
}

data:extend({ entity, item, recipe })
end

function M.add_network_tank()
local name = "network-tank"
local override_item_name = "storage-tank"

local entity = {
name = name,
type = "storage-tank",
flags = {
"placeable-neutral",
"player-creation",
"fast-replaceable-no-build-while-moving",
},
icon = Paths.graphics .. "/entities/network-tank.png",
icon_size = 64,
selection_box = { { -0.5, -0.5 }, { 0.5, 0.5 } },
collision_box = { { -0.4, -0.4 }, { 0.4, 0.4 } },
window_bounding_box = { { -1, -0.5 }, { 1, 0.5 } },
drawing_box = { { -0.5, -0.5 }, { 0.5, 0.5 } },
fluid_box = {
base_area = constants.TANK_AREA,
height = constants.TANK_HEIGHT,
pipe_covers = pipecoverspictures(),
pipe_connections =
{
{ position = { 0, 1 }, type = "input-output" },
},
},
two_direction_only = false,
pictures = {
picture = {
sheet = {
filename = Paths.graphics .. "/entities/network-tank2.png",
size = 128,
scale = 0.5,
},
},
window_background = {
filename = Paths.graphics .. "/empty-pixel.png",
size = 1,
},
fluid_background = {
filename = Paths.graphics .. "/empty-pixel.png",
size = {1, 1},
},
flow_sprite = {
filename = Paths.graphics .. "/empty-pixel.png",
size = 1,
},
gas_flow = {
filename = Paths.graphics .. "/empty-pixel.png",
size = 1,
},
},
flow_length_in_ticks = 1,
minable = {
mining_time = 0.5,
result = name,
},
se_allow_in_space = true,
allow_copy_paste = true,
additional_pastable_entities = { name },
max_health = 200,
}

local item = table.deepcopy(data.raw["item"][override_item_name])
item.name = name
item.place_result = name
item.icon = Paths.graphics .. "/items/network-tank.png"
item.size = 64

local recipe = {
name = name,
type = "recipe",
enabled = true,
energy_required = 0.5,
ingredients = {},
result = name,
result_count = 1,
}

data:extend({ entity, item, recipe })
end

M.main()
2 changes: 2 additions & 0 deletions locale/en/config.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ item-network-remote-action=Build, mine and upgrade remotely.
item-network-config-entities-per-tick=Number of Entities to update per tick.
item-network-config-queue-count=Number of priority queues.
item-network-config-queue-ticks=Minimum ticks per queue.
item-network-cheat-production-duplicate=CHEAT: Add production to the item network every X seconds.
item-network-cheat-infinite-duplicate=CHEAT: Duplicate anything sent to the network.

[mod-setting-description]
Expand All @@ -74,6 +75,7 @@ item-network-service-fuel=Add fuel to any entity with a burner.
item-network-config-entities-per-tick=This setting controls the number of entities that will be updated each tick. Higher numbers will transfer items and fluids faster, but will take more time.
item-network-service-alert=Useless if using remote action.
item-network-remote-action=Works on any surface. Make SE easy!
item-network-cheat-production-duplicate=CHEAT: This setting will add what has been produced to the network every X seconds.
item-network-cheat-infinite-duplicate=CHEAT: This setting will endlessly replicate anything sent to the network.

[in_nv]
Expand Down
10 changes: 9 additions & 1 deletion settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,20 @@ function M.main()
minimum_value = 1,
order = "102",
},
{
name = "item-network-cheat-production-duplicate",
type = "int-setting",
setting_type = "runtime-global",
default_value = 0,
minimum_value = 0,
order = "901",
},
{
name = "item-network-cheat-infinite-duplicate",
type = "bool-setting",
setting_type = "runtime-global",
default_value = false,
order = "900",
order = "902",
},
})
end
Expand Down
Loading

0 comments on commit d3e74fd

Please sign in to comment.