diff --git a/data.lua b/data.lua index 5178532..fb2baec 100644 --- a/data.lua +++ b/data.lua @@ -1,10 +1,15 @@ require("prototypes.item-groups") +require("prototypes.recipe-categories") +--Technology require("prototypes.technologies.storage-tanks") require("prototypes.technologies.asphalt") require("prototypes.technologies.burner") require("prototypes.technologies.warehouses") +--Pipes +require("prototypes.pipes.niobium-pipes") + --Tiles require ("prototypes.tiles.py-asphalt") require ("prototypes.tiles.py-limestone") @@ -29,10 +34,15 @@ require("prototypes.buildings.fluid-tanks.tanks-7000") require("prototypes.buildings.fluid-tanks.tanks-6500") require("prototypes.buildings.fluid-tanks.tanks-8000") +require("prototypes.buildings.valves.check-valve") +require("prototypes.buildings.valves.overflow-valve") +require("prototypes.buildings.valves.underflow-valve") + +--Other require("prototypes.buildings.accumulator-mk01") require("prototypes.buildings.radar") + +--Voiding require("prototypes.buildings.burner") require("prototypes.buildings.sinkhole") require("prototypes.buildings.gas-vent") - -require("prototypes.pipes.niobium-pipes") diff --git a/graphics/entity/py-tank-7000/horizontal.png b/graphics/entity/py-tank-7000/east.png similarity index 100% rename from graphics/entity/py-tank-7000/horizontal.png rename to graphics/entity/py-tank-7000/east.png diff --git a/graphics/entity/py-tank-7000/hr-horizontal.png.REMOVED.git-id b/graphics/entity/py-tank-7000/hr-east.png.REMOVED.git-id similarity index 100% rename from graphics/entity/py-tank-7000/hr-horizontal.png.REMOVED.git-id rename to graphics/entity/py-tank-7000/hr-east.png.REMOVED.git-id diff --git a/graphics/entity/py-tank-7000/hr-north.png.REMOVED.git-id b/graphics/entity/py-tank-7000/hr-north.png.REMOVED.git-id new file mode 100644 index 0000000..d64ac3e --- /dev/null +++ b/graphics/entity/py-tank-7000/hr-north.png.REMOVED.git-id @@ -0,0 +1 @@ +207af28723b30f817711e2e3894cddaa4bc47470 \ No newline at end of file diff --git a/graphics/entity/py-tank-7000/hr-vertical.png.REMOVED.git-id b/graphics/entity/py-tank-7000/hr-south.png.REMOVED.git-id similarity index 100% rename from graphics/entity/py-tank-7000/hr-vertical.png.REMOVED.git-id rename to graphics/entity/py-tank-7000/hr-south.png.REMOVED.git-id diff --git a/graphics/entity/py-tank-7000/hr-west.png.REMOVED.git-id b/graphics/entity/py-tank-7000/hr-west.png.REMOVED.git-id new file mode 100644 index 0000000..f4f39e6 --- /dev/null +++ b/graphics/entity/py-tank-7000/hr-west.png.REMOVED.git-id @@ -0,0 +1 @@ +6e760f4c1b90a6174b9ccd9b6f5b7888fe28c903 \ No newline at end of file diff --git a/graphics/entity/py-tank-7000/north.png b/graphics/entity/py-tank-7000/north.png new file mode 100644 index 0000000..be0a40d Binary files /dev/null and b/graphics/entity/py-tank-7000/north.png differ diff --git a/graphics/entity/py-tank-7000/vertical.png b/graphics/entity/py-tank-7000/south.png similarity index 100% rename from graphics/entity/py-tank-7000/vertical.png rename to graphics/entity/py-tank-7000/south.png diff --git a/graphics/entity/py-tank-7000/west.png b/graphics/entity/py-tank-7000/west.png new file mode 100644 index 0000000..9c6eb38 Binary files /dev/null and b/graphics/entity/py-tank-7000/west.png differ diff --git a/graphics/entity/py-valves/check-valve-shadow.png b/graphics/entity/py-valves/check-valve-shadow.png new file mode 100644 index 0000000..8feb3db Binary files /dev/null and b/graphics/entity/py-valves/check-valve-shadow.png differ diff --git a/graphics/entity/py-valves/check-valve.png b/graphics/entity/py-valves/check-valve.png new file mode 100644 index 0000000..969f698 Binary files /dev/null and b/graphics/entity/py-valves/check-valve.png differ diff --git a/graphics/entity/py-valves/hr-check-valve-shadow.png b/graphics/entity/py-valves/hr-check-valve-shadow.png new file mode 100644 index 0000000..2c27f6c Binary files /dev/null and b/graphics/entity/py-valves/hr-check-valve-shadow.png differ diff --git a/graphics/entity/py-valves/hr-check-valve.png b/graphics/entity/py-valves/hr-check-valve.png new file mode 100644 index 0000000..d0e9140 Binary files /dev/null and b/graphics/entity/py-valves/hr-check-valve.png differ diff --git a/graphics/entity/py-valves/hr-overflow-valve-shadow.png b/graphics/entity/py-valves/hr-overflow-valve-shadow.png new file mode 100644 index 0000000..0027a0f Binary files /dev/null and b/graphics/entity/py-valves/hr-overflow-valve-shadow.png differ diff --git a/graphics/entity/py-valves/hr-overflow-valve.png b/graphics/entity/py-valves/hr-overflow-valve.png new file mode 100644 index 0000000..03a78fc Binary files /dev/null and b/graphics/entity/py-valves/hr-overflow-valve.png differ diff --git a/graphics/entity/py-valves/hr-underflow-valve-shadow.png b/graphics/entity/py-valves/hr-underflow-valve-shadow.png new file mode 100644 index 0000000..a55aef0 Binary files /dev/null and b/graphics/entity/py-valves/hr-underflow-valve-shadow.png differ diff --git a/graphics/entity/py-valves/hr-underflow-valve.png b/graphics/entity/py-valves/hr-underflow-valve.png new file mode 100644 index 0000000..85b6173 Binary files /dev/null and b/graphics/entity/py-valves/hr-underflow-valve.png differ diff --git a/graphics/entity/py-valves/overflow-valve-shadow.png b/graphics/entity/py-valves/overflow-valve-shadow.png new file mode 100644 index 0000000..ea0f61e Binary files /dev/null and b/graphics/entity/py-valves/overflow-valve-shadow.png differ diff --git a/graphics/entity/py-valves/overflow-valve.png b/graphics/entity/py-valves/overflow-valve.png new file mode 100644 index 0000000..e30e98f Binary files /dev/null and b/graphics/entity/py-valves/overflow-valve.png differ diff --git a/graphics/entity/py-valves/py-valve-minus/80minus-horizontal-shadow.png b/graphics/entity/py-valves/py-valve-minus/80minus-horizontal-shadow.png new file mode 100644 index 0000000..feeb3c0 Binary files /dev/null and b/graphics/entity/py-valves/py-valve-minus/80minus-horizontal-shadow.png differ diff --git a/graphics/entity/py-valves/py-valve-minus/80minus-horizontal.png b/graphics/entity/py-valves/py-valve-minus/80minus-horizontal.png new file mode 100644 index 0000000..ef758e3 Binary files /dev/null and b/graphics/entity/py-valves/py-valve-minus/80minus-horizontal.png differ diff --git a/graphics/entity/py-valves/py-valve-minus/80minus-vertical-shadow.png b/graphics/entity/py-valves/py-valve-minus/80minus-vertical-shadow.png new file mode 100644 index 0000000..f554e1d Binary files /dev/null and b/graphics/entity/py-valves/py-valve-minus/80minus-vertical-shadow.png differ diff --git a/graphics/entity/py-valves/py-valve-minus/80minus-vertical.png b/graphics/entity/py-valves/py-valve-minus/80minus-vertical.png new file mode 100644 index 0000000..3d890a8 Binary files /dev/null and b/graphics/entity/py-valves/py-valve-minus/80minus-vertical.png differ diff --git a/graphics/entity/py-valves/py-valve-minus/hr-80minus-horizontal-shadow.png b/graphics/entity/py-valves/py-valve-minus/hr-80minus-horizontal-shadow.png new file mode 100644 index 0000000..f6add1c Binary files /dev/null and b/graphics/entity/py-valves/py-valve-minus/hr-80minus-horizontal-shadow.png differ diff --git a/graphics/entity/py-valves/py-valve-minus/hr-80minus-horizontal.png b/graphics/entity/py-valves/py-valve-minus/hr-80minus-horizontal.png new file mode 100644 index 0000000..24abe11 Binary files /dev/null and b/graphics/entity/py-valves/py-valve-minus/hr-80minus-horizontal.png differ diff --git a/graphics/entity/py-valves/py-valve-minus/hr-80minus-vertical-shadow.png b/graphics/entity/py-valves/py-valve-minus/hr-80minus-vertical-shadow.png new file mode 100644 index 0000000..b1417f0 Binary files /dev/null and b/graphics/entity/py-valves/py-valve-minus/hr-80minus-vertical-shadow.png differ diff --git a/graphics/entity/py-valves/py-valve-minus/hr-80minus-vertical.png b/graphics/entity/py-valves/py-valve-minus/hr-80minus-vertical.png new file mode 100644 index 0000000..3644730 Binary files /dev/null and b/graphics/entity/py-valves/py-valve-minus/hr-80minus-vertical.png differ diff --git a/graphics/entity/py-valves/underflow-valve-shadow.png b/graphics/entity/py-valves/underflow-valve-shadow.png new file mode 100644 index 0000000..ed070a8 Binary files /dev/null and b/graphics/entity/py-valves/underflow-valve-shadow.png differ diff --git a/graphics/entity/py-valves/underflow-valve.png b/graphics/entity/py-valves/underflow-valve.png new file mode 100644 index 0000000..562aa29 Binary files /dev/null and b/graphics/entity/py-valves/underflow-valve.png differ diff --git a/graphics/icons/check-valve.png b/graphics/icons/check-valve.png new file mode 100644 index 0000000..11b26fc Binary files /dev/null and b/graphics/icons/check-valve.png differ diff --git a/graphics/icons/overflow-valve.png b/graphics/icons/overflow-valve.png new file mode 100644 index 0000000..b17b8be Binary files /dev/null and b/graphics/icons/overflow-valve.png differ diff --git a/graphics/icons/underflow-valve.png b/graphics/icons/underflow-valve.png new file mode 100644 index 0000000..1af75f3 Binary files /dev/null and b/graphics/icons/underflow-valve.png differ diff --git a/info.json b/info.json index 7798fee..b75f053 100644 --- a/info.json +++ b/info.json @@ -1,7 +1,7 @@ { "name": "pyindustry", - "version": "1.0.1", - "factorio_version": "0.15", + "version": "1.0.2", + "factorio_version": "0.16", "title": "Pyanodons Industry", "author": "Pyanodon, Nexela", "contact": "", diff --git a/locale/en/en.cfg b/locale/en/en.cfg index 10b24ae..c1b375e 100644 --- a/locale/en/en.cfg +++ b/locale/en/en.cfg @@ -19,6 +19,10 @@ py-tank-6500=Tank 6500L py-tank-7000=Tank 7000L py-tank-8000=Tank 8000L +py-check-valve=Check Valve +py-overflow-valve=Overflow Valve +py-underflow-valve=Underflow Valve + niobium-pipe=Niobum pipe niobium-pipe-to-ground=Niobum underground pipe @@ -59,6 +63,10 @@ py-tank-4000=Medium capacity tank. py-tank-5000=Medium capacity tank. py-tank-6500=Good capacity tank. +py-check-valve=Allows flow only in direction of arrow. +py-overflow-valve=Allows flow when input is over 80% full. +py-underflow-valve=Allows flow when output is under 80% full. + poorman-wood-fence=At least you have something. wood-fence=Made of pure wood. concrete-wall=Hard and breakable. diff --git a/prototypes/buildings/accumulator-mk01.lua b/prototypes/buildings/accumulator-mk01.lua index 1c1b9fb..8bad985 100644 --- a/prototypes/buildings/accumulator-mk01.lua +++ b/prototypes/buildings/accumulator-mk01.lua @@ -1,92 +1,86 @@ local Recipe = require("stdlib/data/recipe") -------------------------------------------------------------------------------- ---[[Recipes]]-- -local recipe = Recipe { +local Item = require("stdlib/data/item") +local Entity = require("stdlib/data/entity") + +Recipe { type = "recipe", name = "accumulator-mk01", energy_required = 5, enabled = false, - ingredients = - { + ingredients = { {"battery", 20}, {"iron-plate", 40}, {"copper-plate", 40}, - {"steel-plate", 50}, -- {"nexelit-plate", 50}, + {"steel-plate", 50} -- {"nexelit-plate", 50}, -- {"niobium-plate", 10}, }, - result= "accumulator-mk01", - icon = "__pyindustry__/graphics/icons/accumulator-mk01.png", -}:extend() + result = "accumulator-mk01" +}:replace_ingredient("steel-plate", "nexelit-plate"):add_ingredient({"niobium-plate", 10}):add_unlock( + {"coal-processing-3", "electric-energy-accumulators-1"} +) -------------------------------------------------------------------------------- ---[[Items]]-- -local item = { +Item { type = "item", name = "accumulator-mk01", icon = "__pyindustry__/graphics/icons/accumulator-mk01.png", + icon_size = 32, flags = {"goes-to-quickbar"}, subgroup = "py-industry", order = "a", place_result = "accumulator-mk01", - stack_size = 50, + stack_size = 50 } -------------------------------------------------------------------------------- ---[[Entites]]-- -local entity = { + +Entity { type = "accumulator", name = "accumulator-mk01", icon = "__pyindustry__/graphics/icons/accumulator-mk01.png", + icon_size = 32, flags = {"placeable-neutral", "player-creation"}, minable = {hardness = 0.2, mining_time = 0.5, result = "accumulator-mk01"}, max_health = 150, corpse = "medium-remnants", collision_box = {{-1.9, -1.9}, {1.9, 1.9}}, selection_box = {{-2, -2}, {2, 2}}, - energy_source = - { + energy_source = { type = "electric", buffer_capacity = "20MJ", usage_priority = "terciary", input_flow_limit = "1400kW", output_flow_limit = "1400kW" }, - picture = - { + picture = { filename = "__pyindustry__/graphics/entity/accumulator-mk01/accumulator-idle.png", priority = "extra-high", width = 157, height = 244, - shift = {0.43, -1.781}, + shift = {0.43, -1.781} }, - charge_animation = - { + charge_animation = { filename = "__pyindustry__/graphics/entity/accumulator-mk01/accumulator-charging.png", width = 157, height = 244, line_length = 10, frame_count = 40, shift = {0.43, -1.781}, - animation_speed = 0.2, + animation_speed = 0.2 }, charge_cooldown = 30, charge_light = {intensity = 0.3, size = 7, color = {r = 1.0, g = 1.0, b = 1.0}}, - discharge_animation = - { + discharge_animation = { filename = "__pyindustry__/graphics/entity/accumulator-mk01/accumulator-discharging.png", width = 157, height = 244, line_length = 10, frame_count = 40, shift = {0.43, -1.781}, - animation_speed = 0.2, + animation_speed = 0.2 }, discharge_cooldown = 60, discharge_light = {intensity = 0.7, size = 7, color = {r = 1.0, g = 1.0, b = 1.0}}, - vehicle_impact_sound = { filename = "__base__/sound/car-metal-impact.ogg", volume = 0.65 }, - working_sound = - { - sound = - { + vehicle_impact_sound = {filename = "__base__/sound/car-metal-impact.ogg", volume = 0.65}, + working_sound = { + sound = { filename = "__pyindustry__/sounds/accumulator.ogg", volume = 0.6 }, @@ -96,33 +90,17 @@ local entity = { }, max_sounds_per_type = 5 }, - circuit_wire_connection_point = - { - shadow = - { + circuit_wire_connection_point = { + shadow = { red = {0.984375, 1.10938}, green = {0.890625, 1.10938} }, - wire = - { + wire = { red = {0.6875, 0.59375}, green = {0.6875, 0.71875} } }, circuit_wire_max_distance = 9, - default_output_signal = {type = "virtual", name = "signal-A"} + default_output_signal = {type = "virtual", name = "signal-A"}, + circuit_connector_sprites = _G.circuit_connector_definitions["accumulator"].sprites } - -if _G.get_circuit_connector_sprites then - entity.circuit_connector_sprites = _G.get_circuit_connector_sprites({0.46875, 0.5}, {0.46875, 0.8125}, 26) -else - entity.circuit_connector_sprites = _G.circuit_connector_definitions["accumulator"].sprites -end - - -------------------------------------------------------------------------------- -data:extend{item, entity} - -recipe:replace_ingredient("steel-plate", "nexelit-plate"):add_ingredient({"niobium-plate", 10}) -recipe:add_unlock({"coal-processing-3", "electric-energy-accumulators-1"}) - diff --git a/prototypes/buildings/burner.lua b/prototypes/buildings/burner.lua index 5d41ffb..117a59b 100644 --- a/prototypes/buildings/burner.lua +++ b/prototypes/buildings/burner.lua @@ -1,6 +1,8 @@ +local Item = require("stdlib/data/item") local Recipe = require("stdlib/data/recipe") +local Entity = require("stdlib/data/entity") -local recipe = Recipe { +Recipe { type = "recipe", name = "py-burner", energy_required = 10, @@ -14,10 +16,11 @@ local recipe = Recipe { result = "py-burner" }:add_unlock("py-burner") -local item = { +Item { type = "item", name = "py-burner", icon = "__pyindustry__/graphics/icons/burner.png", + icon_size = 32, flags = {"goes-to-quickbar"}, subgroup = "py-industry", order = "a", @@ -25,11 +28,11 @@ local item = { stack_size = 50 } -local entity = - { +Entity { type = "furnace", name = "py-burner", icon = "__pyindustry__/graphics/icons/burner.png", + icon_size = 32, flags = {"placeable-neutral", "placeable-player", "player-creation"}, minable = {mining_time = 1, result = "py-burner"}, max_health = 200, @@ -58,7 +61,7 @@ local entity = }, collision_box = {{-1.2, -1.2}, {1.2, 1.2}}, selection_box = {{-1.5, -1.5}, {1.5, 1.5}}, - crafting_categories = {"smelting"}, + crafting_categories = {"py-incineration"}, result_inventory_size = 1, energy_usage = "180kW", crafting_speed = 1, @@ -124,4 +127,3 @@ local entity = }, fast_replaceable_group = "py-burner" } -data:extend {recipe, item, entity} \ No newline at end of file diff --git a/prototypes/buildings/containers/connectors.lua b/prototypes/buildings/containers/connectors.lua index 8fa07e6..a8bfebe 100644 --- a/prototypes/buildings/containers/connectors.lua +++ b/prototypes/buildings/containers/connectors.lua @@ -13,7 +13,7 @@ function connectors.sprites(con_shift, shadow_shift) scale = 0.5 }, led_red = { - filename = "__base__/graphics/entity/circuit-connector/circuit-connector-led-red.png", + filename = "__base__/graphics/entity/circuit-connector/circuit-connector-led-red-glow.png", priority = "low", width = 20, height = 16, @@ -22,7 +22,7 @@ function connectors.sprites(con_shift, shadow_shift) shift = red_green_shift }, led_green = { - filename = "__base__/graphics/entity/circuit-connector/circuit-connector-led-green.png", + filename = "__base__/graphics/entity/circuit-connector/circuit-connector-led-green-glow.png", priority = "low", width = 20, height = 16, @@ -31,7 +31,7 @@ function connectors.sprites(con_shift, shadow_shift) shift = red_green_shift }, led_blue = { - filename = "__base__/graphics/entity/circuit-connector/circuit-connector-led-blue.png", + filename = "__base__/graphics/entity/circuit-connector/circuit-connector-led-blue-glow.png", priority = "low", width = 20, height = 16, diff --git a/prototypes/buildings/containers/shed.lua b/prototypes/buildings/containers/shed.lua index 12db0ac..ae7431c 100644 --- a/prototypes/buildings/containers/shed.lua +++ b/prototypes/buildings/containers/shed.lua @@ -1,27 +1,28 @@ --[[ Copyright (c) 2017 David-John Miller AKA Anoyomouse * Part of the Warehousing mod --]] -local Technology = require("stdlib/data/technology") +local Recipe = require("stdlib/data/recipe") +local Item = require("stdlib/data/item") +local Entity = require("stdlib/data/entity") local connectors = require("prototypes/buildings/containers/connectors") local function get_ingredients(name) - local ingredients if name == "passive-provider" then - ingredients = { + return { {"py-shed-basic", 1}, {"logistic-chest-passive-provider", 1}, {"iron-plate", 5}, {"advanced-circuit", 2} } elseif name == "active-provider" then - ingredients = { + return { {"py-shed-basic", 1}, {"logistic-chest-active-provider", 1}, {"iron-plate", 5}, {"advanced-circuit", 2} } elseif name == "storage" then - ingredients = { + return { {"py-shed-basic", 1}, {"logistic-chest-storage", 1}, {"iron-plate", 5}, @@ -29,35 +30,34 @@ local function get_ingredients(name) {"steel-chest", 5} } elseif name == "requester" then - ingredients = { + return { {"py-shed-basic", 1}, {"logistic-chest-requester", 1}, {"iron-plate", 5}, {"advanced-circuit", 2} } elseif name == "buffer" then - ingredients = { + return { {"py-shed-basic", 1}, {"logistic-chest-buffer", 1}, {"iron-plate", 5}, {"advanced-circuit", 2} } else - ingredients = { + return { {"steel-plate", 20}, {"iron-plate", 40}, {"stone-brick", 10}, {"wooden-chest", 5} } end - return ingredients end local function define_shed(name, logistics_name) local entity_type = logistics_name and "logistic-container" or "container" local full_name = "py-shed-" .. name - local recipe = { + local recipe = Recipe { type = "recipe", name = full_name, enabled = "false", @@ -65,21 +65,23 @@ local function define_shed(name, logistics_name) result = full_name } - local item = { + Item { type = "item", name = full_name, icon = "__pyindustry__/graphics/icons/containers/shed-" .. name .. ".png", + icon_size = 32, flags = {"goes-to-quickbar"}, subgroup = "py-containers-shed", order = entity_type .. "[" .. full_name .. "]", place_result = full_name, stack_size = 15 } - local entity = - { + + local entity = Entity { type = entity_type, name = full_name, - icon = "__pyindustry__/graphics/icons/containers/shed-" .. name .. ".png", + icon = "__pyindustry__/graphics/icons/containers/shed-" .. name .. ".png", + icon_size = 32, flags = {"placeable-neutral", "placeable-player", "player-creation"}, minable = {mining_time = 2, result = full_name}, max_health = 250, @@ -126,15 +128,14 @@ local function define_shed(name, logistics_name) if logistics_name then entity.minable.hardness = 0.2; - entity.logistic_mode = logistics_name; - Technology("py-warehouse-logistics-research"):add_effect(recipe) + entity.logistic_mode = logistics_name + recipe:add_unlock("py-warehouse-logistics-research") if (logistics_name == "storage") then entity.inventory_size = 150; end else - Technology("py-warehouse-research"):add_effect(recipe) + recipe:add_unlock("py-warehouse-research") end - data:extend{recipe, item, entity} end define_shed("basic", nil) @@ -142,7 +143,4 @@ define_shed("passive-provider", "passive-provider") define_shed("storage", "storage") define_shed("active-provider", "active-provider") define_shed("requester", "requester") -if data.raw.item["logistic-chest-buffer"] then - define_shed("buffer", "buffer") -end - +define_shed("buffer", "buffer") diff --git a/prototypes/buildings/containers/storehouse.lua b/prototypes/buildings/containers/storehouse.lua index 501bf2f..7d02d68 100644 --- a/prototypes/buildings/containers/storehouse.lua +++ b/prototypes/buildings/containers/storehouse.lua @@ -1,27 +1,28 @@ --[[ Copyright (c) 2017 David-John Miller AKA Anoyomouse * Part of the Warehousing mod --]] -local Technology = require("stdlib/data/technology") +local Recipe = require("stdlib/data/recipe") +local Item = require("stdlib/data/item") +local Entity = require("stdlib/data/entity") local connectors = require("prototypes/buildings/containers/connectors") local function get_ingredients(name) - local ingredients if name == "passive-provider" then - ingredients = { + return { {"py-storehouse-basic", 1}, {"logistic-chest-passive-provider", 1}, {"iron-plate", 5}, {"advanced-circuit", 2} } elseif name == "active-provider" then - ingredients = { + return { {"py-storehouse-basic", 1}, {"logistic-chest-active-provider", 1}, {"iron-plate", 5}, {"advanced-circuit", 2} } elseif name == "storage" then - ingredients = { + return { {"py-storehouse-basic", 1}, {"logistic-chest-storage", 1}, {"iron-plate", 5}, @@ -29,35 +30,35 @@ local function get_ingredients(name) {"steel-chest", 5} } elseif name == "requester" then - ingredients = { + return { {"py-storehouse-basic", 1}, {"logistic-chest-requester", 1}, {"iron-plate", 5}, {"advanced-circuit", 2} } elseif name == "buffer" then - ingredients = { + return { {"py-storehouse-basic", 1}, {"logistic-chest-buffer", 1}, {"iron-plate", 5}, {"advanced-circuit", 2} } else - ingredients = { + return { {"steel-plate", 20}, {"iron-plate", 40}, {"stone-brick", 10}, {"wooden-chest", 5} } end - return ingredients end local function define_storehouse(name, logistics_name) local entity_type = logistics_name and "logistic-container" or "container" local full_name = "py-storehouse-" .. name - local recipe = { + local recipe = + Recipe { type = "recipe", name = full_name, enabled = "false", @@ -65,10 +66,11 @@ local function define_storehouse(name, logistics_name) result = full_name } - local item = { + Item { type = "item", name = full_name, icon = "__pyindustry__/graphics/icons/containers/storehouse-" .. name .. ".png", + icon_size = 32, flags = {"goes-to-quickbar"}, subgroup = "py-containers-storehouse", order = entity_type .. "[" .. full_name .. "]", @@ -76,10 +78,12 @@ local function define_storehouse(name, logistics_name) stack_size = 15 } - local entity = { + local entity = + Entity { type = entity_type, name = full_name, icon = "__pyindustry__/graphics/icons/containers/storehouse-" .. name .. ".png", + icon_size = 32, flags = {"placeable-neutral", "placeable-player", "player-creation"}, minable = {mining_time = 2, result = full_name}, max_health = 250, @@ -122,16 +126,15 @@ local function define_storehouse(name, logistics_name) } if logistics_name then - Technology("py-warehouse-logistics-research"):add_effect(recipe) + recipe:add_unlock("py-warehouse-logistics-research") entity.minable.hardness = 0.2 entity.logistic_mode = logistics_name if (logistics_name == "storage") then entity.inventory_size = 300 end else - Technology("py-warehouse-research"):add_effect(recipe) + recipe:add_unlock("py-warehouse-research") end - data:extend {recipe, item, entity} end define_storehouse("basic", nil) @@ -139,6 +142,4 @@ define_storehouse("passive-provider", "passive-provider") define_storehouse("storage", "storage") define_storehouse("active-provider", "active-provider") define_storehouse("requester", "requester") -if data.raw.item["logistic-chest-buffer"] then - define_storehouse("buffer", "buffer") -end +define_storehouse("buffer", "buffer") diff --git a/prototypes/buildings/containers/warehouse.lua b/prototypes/buildings/containers/warehouse.lua index 61c9a7c..61e5da9 100644 --- a/prototypes/buildings/containers/warehouse.lua +++ b/prototypes/buildings/containers/warehouse.lua @@ -1,27 +1,28 @@ --[[ Copyright (c) 2017 David-John Miller AKA Anoyomouse * Part of the Warehousing mod --]] -local Technology = require("stdlib/data/technology") +local Recipe = require("stdlib/data/recipe") +local Item = require("stdlib/data/item") +local Entity = require("stdlib/data/entity") local connectors = require("prototypes/buildings/containers/connectors") local function get_ingredients(name) - local ingredients if name == "passive-provider" then - ingredients = { + return { {"py-warehouse-basic", 1}, {"logistic-chest-passive-provider", 1}, {"iron-plate", 20}, {"advanced-circuit", 5} } elseif name == "active-provider" then - ingredients = { + return { {"py-warehouse-basic", 1}, {"logistic-chest-active-provider", 1}, {"iron-plate", 5}, {"advanced-circuit", 2} } elseif name == "storage" then - ingredients = { + return { {"py-warehouse-basic", 1}, {"logistic-chest-storage", 1}, {"iron-plate", 20}, @@ -29,35 +30,35 @@ local function get_ingredients(name) {"steel-chest", 15} } elseif name == "requester" then - ingredients = { + return { {"py-warehouse-basic", 1}, {"logistic-chest-requester", 1}, {"iron-plate", 20}, {"advanced-circuit", 5} } elseif name == "buffer" then - ingredients = { + return { {"py-warehouse-basic", 1}, {"logistic-chest-requester", 1}, {"iron-plate", 20}, {"advanced-circuit", 5} } else - ingredients = { + return { {"steel-plate", 60}, {"iron-plate", 100}, {"stone-brick", 25}, {"wooden-chest", 10} } end - return ingredients end local function define_warehouse(name, logistics_name) local entity_type = logistics_name and "logistic-container" or "container" local full_name = "py-warehouse-" .. name - local recipe = { + local recipe = + Recipe { type = "recipe", name = full_name, enabled = "false", @@ -65,10 +66,11 @@ local function define_warehouse(name, logistics_name) result = full_name } - local item = { + Item { type = "item", name = full_name, icon = "__pyindustry__/graphics/icons/containers/warehouse-" .. name .. ".png", + icon_size = 32, flags = {"goes-to-quickbar"}, subgroup = "py-containers-warehouse", order = entity_type .. "[" .. full_name .. "]", @@ -76,10 +78,12 @@ local function define_warehouse(name, logistics_name) stack_size = 15 } - local entity = { + local entity = + Entity { type = entity_type, name = full_name, icon = "__pyindustry__/graphics/icons/containers/warehouse-" .. name .. ".png", + icon_size = 32, flags = {"placeable-neutral", "placeable-player", "player-creation"}, minable = {mining_time = 2, result = full_name}, max_health = 350, @@ -124,16 +128,15 @@ local function define_warehouse(name, logistics_name) entity.max_health = 450 entity.minable.hardness = 0.2 entity.logistic_mode = logistics_name - Technology("py-warehouse-logistics-research"):add_effect(recipe) + recipe:add_unlock("py-warehouse-logistics-research") if (logistics_name == "storage") then entity.inventory_size = 2000 elseif (logistics_name == "buffer" or logistics_name == "requester") then entity.logistic_slots_count = 12 end else - Technology("py-warehouse-research"):add_effect(recipe) + recipe:add_unlock("py-warehouse-research") end - data:extend {recipe, item, entity} end define_warehouse("basic", nil) @@ -141,6 +144,4 @@ define_warehouse("passive-provider", "passive-provider") define_warehouse("storage", "storage") define_warehouse("active-provider", "active-provider") define_warehouse("requester", "requester") -if data.raw.item["logistic-chest-buffer"] then - define_warehouse("buffer", "buffer") -end +define_warehouse("buffer", "buffer") diff --git a/prototypes/buildings/fluid-tanks/tanks-1500.lua b/prototypes/buildings/fluid-tanks/tanks-1500.lua index 26ac646..1e3b22a 100644 --- a/prototypes/buildings/fluid-tanks/tanks-1500.lua +++ b/prototypes/buildings/fluid-tanks/tanks-1500.lua @@ -1,8 +1,9 @@ local Pipes = require("stdlib.data.pipes") local Recipe = require("stdlib/data/recipe") -local pipecoverspictures = _G.pipecoverspictures +local Item = require("stdlib/data/item") +local Entity = require("stdlib/data/entity") -local recipe = { +Recipe { type = "recipe", name = "py-tank-1500", energy_required = 15, @@ -13,12 +14,13 @@ local recipe = { {"steel-plate", 10} }, result = "py-tank-1500" -} +}:add_unlock("py-storage-tanks") -local item = { +Item { type = "item", name = "py-tank-1500", icon = "__pyindustry__/graphics/icons/py-tank-1500.png", + icon_size = 32, flags = {"goes-to-quickbar"}, subgroup = "py-storage-tanks", order = "a-c[py-items]", @@ -26,10 +28,11 @@ local item = { stack_size = 10 } -local entity = { +Entity { type = "storage-tank", name = "py-tank-1500", icon = "__pyindustry__/graphics/icons/py-tank-1500.png", + icon_size = 32, flags = {"placeable-player", "player-creation"}, minable = {hardness = 0.2, mining_time = 3, result = "py-tank-1500"}, max_health = 500, @@ -39,7 +42,7 @@ local entity = { two_direction_only = true, fluid_box = { base_area = 150, - pipe_covers = pipecoverspictures(), + pipe_covers = _G.pipecoverspictures(), pipe_connections = { {position = {0, -2}}, {position = {2, 0}}, @@ -74,39 +77,7 @@ local entity = { apparent_volume = 1.5, max_sounds_per_type = 3 }, - circuit_wire_max_distance = 9 + circuit_wire_max_distance = 9, + circuit_wire_connection_points = _G.circuit_connector_definitions["storage-tank"].points, + circuit_connector_sprites = _G.circuit_connector_definitions["storage-tank"].sprites } - -if _G.get_circuit_connector_sprites then - entity.circuit_connector_sprites = { - _G.get_circuit_connector_sprites({0, 0}, nil, 0), - _G.get_circuit_connector_sprites({0, 0}, nil, 0), - _G.get_circuit_connector_sprites({0, 0}, nil, 0), - _G.get_circuit_connector_sprites({0, 0}, nil, 0) - } - entity.circuit_wire_connection_points = { - { - shadow = {red = {0, 0}, green = {0, 0}}, - wire = {red = {0, 0}, green = {0, 0}} - }, - { - shadow = {red = {0, 0}, green = {0, 0}}, - wire = {red = {0, 0}, green = {0, 0}} - }, - { - shadow = {red = {0, 0}, green = {0, 0}}, - wire = {red = {0, 0}, green = {0, 0}} - }, - { - shadow = {red = {0, 0}, green = {0, 0}}, - wire = {red = {0, 0}, green = {0, 0}} - } - } -else - entity.circuit_wire_connection_points = _G.circuit_connector_definitions["storage-tank"].points - entity.circuit_connector_sprites = _G.circuit_connector_definitions["storage-tank"].sprites -end - -Recipe:extend {recipe, item, entity} - -Recipe("py-tank-1500"):add_unlock("py-storage-tanks") diff --git a/prototypes/buildings/fluid-tanks/tanks-3000.lua b/prototypes/buildings/fluid-tanks/tanks-3000.lua index 93776cc..a04caf8 100644 --- a/prototypes/buildings/fluid-tanks/tanks-3000.lua +++ b/prototypes/buildings/fluid-tanks/tanks-3000.lua @@ -1,8 +1,9 @@ local Pipes = require("stdlib.data.pipes") local Recipe = require("stdlib/data/recipe") -local pipecoverspictures = _G.pipecoverspictures +local Item = require("stdlib/data/item") +local Entity = require("stdlib/data/entity") -local recipe = { +Recipe { type = "recipe", name = "py-tank-3000", energy_required = 15, @@ -12,12 +13,13 @@ local recipe = { {"pipe", 20}, }, result = "py-tank-3000" -} +}:add_unlock("py-storage-tanks") -local item = { +Item { type = "item", name = "py-tank-3000", icon = "__pyindustry__/graphics/icons/py-tank-3000.png", + icon_size = 32, flags = {"goes-to-quickbar"}, subgroup = "py-storage-tanks", order = "a-c[py-items]", @@ -25,10 +27,11 @@ local item = { stack_size = 10 } -local entity = { +Entity { type = "storage-tank", name = "py-tank-3000", icon = "__pyindustry__/graphics/icons/py-tank-3000.png", + icon_size = 32, flags = {"placeable-player", "player-creation"}, minable = {hardness = 0.2, mining_time = 3, result = "py-tank-3000"}, max_health = 100, @@ -38,7 +41,7 @@ local entity = { two_direction_only = true, fluid_box = { base_area = 300, - pipe_covers = pipecoverspictures(), + pipe_covers = _G.pipecoverspictures(), pipe_connections = { {position = {-1.5, -0.5}}, {position = {-1.5, 0.5}}, @@ -82,39 +85,7 @@ local entity = { apparent_volume = 1.5, max_sounds_per_type = 3 }, - circuit_wire_max_distance = 9 + circuit_wire_max_distance = 9, + circuit_wire_connection_points = _G.circuit_connector_definitions["storage-tank"].points, + circuit_connector_sprites = _G.circuit_connector_definitions["storage-tank"].sprites } - -if _G.get_circuit_connector_sprites then - entity.circuit_connector_sprites = { - _G.get_circuit_connector_sprites({0, 0}, nil, 0), - _G.get_circuit_connector_sprites({0, 0}, nil, 0), - _G.get_circuit_connector_sprites({0, 0}, nil, 0), - _G.get_circuit_connector_sprites({0, 0}, nil, 0) - } - entity.circuit_wire_connection_points = { - { - shadow = {red = {0, 0}, green = {0, 0}}, - wire = {red = {0, 0}, green = {0, 0}} - }, - { - shadow = {red = {0, 0}, green = {0, 0}}, - wire = {red = {0, 0}, green = {0, 0}} - }, - { - shadow = {red = {0, 0}, green = {0, 0}}, - wire = {red = {0, 0}, green = {0, 0}} - }, - { - shadow = {red = {0, 0}, green = {0, 0}}, - wire = {red = {0, 0}, green = {0, 0}} - } - } -else - entity.circuit_wire_connection_points = _G.circuit_connector_definitions["storage-tank"].points - entity.circuit_connector_sprites = _G.circuit_connector_definitions["storage-tank"].sprites -end - -Recipe:extend {recipe, item, entity} - -Recipe("py-tank-3000"):add_unlock("py-storage-tanks") diff --git a/prototypes/buildings/fluid-tanks/tanks-4000.lua b/prototypes/buildings/fluid-tanks/tanks-4000.lua index 85c6197..a807249 100644 --- a/prototypes/buildings/fluid-tanks/tanks-4000.lua +++ b/prototypes/buildings/fluid-tanks/tanks-4000.lua @@ -1,8 +1,9 @@ local Pipes = require("stdlib.data.pipes") local Recipe = require("stdlib/data/recipe") -local pipecoverspictures = _G.pipecoverspictures +local Item = require("stdlib/data/item") +local Entity = require("stdlib/data/entity") -local recipe = { +Recipe { type = "recipe", name = "py-tank-4000", energy_required = 15, @@ -13,12 +14,13 @@ local recipe = { {"steel-plate", 30} }, result = "py-tank-4000" -} +}:add_unlock("py-storage-tanks") -local item = { +Item { type = "item", name = "py-tank-4000", icon = "__pyindustry__/graphics/icons/py-tank-4000.png", + icon_size = 32, flags = {"goes-to-quickbar"}, subgroup = "py-storage-tanks", order = "a-c[py-items]", @@ -26,10 +28,11 @@ local item = { stack_size = 10 } -local entity = { +Entity { type = "storage-tank", name = "py-tank-4000", icon = "__pyindustry__/graphics/icons/py-tank-4000.png", + icon_size = 32, flags = {"placeable-player", "player-creation"}, minable = {hardness = 0.2, mining_time = 3, result = "py-tank-4000"}, max_health = 500, @@ -39,7 +42,7 @@ local entity = { two_direction_only = true, fluid_box = { base_area = 400, - pipe_covers = pipecoverspictures(), + pipe_covers = _G.pipecoverspictures(), pipe_connections = { {position = {0, -2}}, {position = {2, 0}}, @@ -74,39 +77,7 @@ local entity = { apparent_volume = 1.5, max_sounds_per_type = 3 }, - circuit_wire_max_distance = 9 + circuit_wire_max_distance = 9, + circuit_wire_connection_points = _G.circuit_connector_definitions["storage-tank"].points, + circuit_connector_sprites = _G.circuit_connector_definitions["storage-tank"].sprites } - -if _G.get_circuit_connector_sprites then - entity.circuit_connector_sprites = { - _G.get_circuit_connector_sprites({0, 0}, nil, 0), - _G.get_circuit_connector_sprites({0, 0}, nil, 0), - _G.get_circuit_connector_sprites({0, 0}, nil, 0), - _G.get_circuit_connector_sprites({0, 0}, nil, 0) - } - entity.circuit_wire_connection_points = { - { - shadow = {red = {0, 0}, green = {0, 0}}, - wire = {red = {0, 0}, green = {0, 0}} - }, - { - shadow = {red = {0, 0}, green = {0, 0}}, - wire = {red = {0, 0}, green = {0, 0}} - }, - { - shadow = {red = {0, 0}, green = {0, 0}}, - wire = {red = {0, 0}, green = {0, 0}} - }, - { - shadow = {red = {0, 0}, green = {0, 0}}, - wire = {red = {0, 0}, green = {0, 0}} - } - } -else - entity.circuit_wire_connection_points = _G.circuit_connector_definitions["storage-tank"].points - entity.circuit_connector_sprites = _G.circuit_connector_definitions["storage-tank"].sprites -end - -Recipe:extend {recipe, item, entity} - -Recipe("py-tank-4000"):add_unlock("py-storage-tanks") diff --git a/prototypes/buildings/fluid-tanks/tanks-5000.lua b/prototypes/buildings/fluid-tanks/tanks-5000.lua index 3c19233..b556864 100644 --- a/prototypes/buildings/fluid-tanks/tanks-5000.lua +++ b/prototypes/buildings/fluid-tanks/tanks-5000.lua @@ -1,8 +1,9 @@ local Pipes = require("stdlib.data.pipes") local Recipe = require("stdlib/data/recipe") -local pipecoverspictures = _G.pipecoverspictures +local Item = require("stdlib/data/item") +local Entity = require("stdlib/data/entity") -local recipe = { +Recipe { type = "recipe", name = "py-tank-5000", energy_required = 15, @@ -14,12 +15,13 @@ local recipe = { {"steel-plate", 30} }, result = "py-tank-5000" -} +}:add_unlock("py-storage-tanks") -local item = { +Item { type = "item", name = "py-tank-5000", icon = "__pyindustry__/graphics/icons/py-tank-5000.png", + icon_size = 32, flags = {"goes-to-quickbar"}, subgroup = "py-storage-tanks", order = "a-c[py-items]", @@ -27,10 +29,11 @@ local item = { stack_size = 10 } -local entity = { +Entity { type = "storage-tank", name = "py-tank-5000", icon = "__pyindustry__/graphics/icons/py-tank-5000.png", + icon_size = 32, flags = {"placeable-player", "player-creation"}, minable = {hardness = 0.2, mining_time = 3, result = "py-tank-5000"}, max_health = 500, @@ -40,7 +43,7 @@ local entity = { selection_box = {{-2.5, -2.5}, {2.5, 2.5}}, fluid_box = { base_area = 500, - pipe_covers = pipecoverspictures(), + pipe_covers = _G.pipecoverspictures(), pipe_connections = { {position = {0, -3}}, {position = {3, 0}}, @@ -75,39 +78,7 @@ local entity = { apparent_volume = 1.5, max_sounds_per_type = 3 }, - circuit_wire_max_distance = 9 + circuit_wire_max_distance = 9, + circuit_wire_connection_points = _G.circuit_connector_definitions["storage-tank"].points, + circuit_connector_sprites = _G.circuit_connector_definitions["storage-tank"].sprites } - -if _G.get_circuit_connector_sprites then - entity.circuit_connector_sprites = { - _G.get_circuit_connector_sprites({0, 0}, nil, 0), - _G.get_circuit_connector_sprites({0, 0}, nil, 0), - _G.get_circuit_connector_sprites({0, 0}, nil, 0), - _G.get_circuit_connector_sprites({0, 0}, nil, 0) - } - entity.circuit_wire_connection_points = { - { - shadow = {red = {0, 0}, green = {0, 0}}, - wire = {red = {0, 0}, green = {0, 0}} - }, - { - shadow = {red = {0, 0}, green = {0, 0}}, - wire = {red = {0, 0}, green = {0, 0}} - }, - { - shadow = {red = {0, 0}, green = {0, 0}}, - wire = {red = {0, 0}, green = {0, 0}} - }, - { - shadow = {red = {0, 0}, green = {0, 0}}, - wire = {red = {0, 0}, green = {0, 0}} - } - } -else - entity.circuit_wire_connection_points = _G.circuit_connector_definitions["storage-tank"].points - entity.circuit_connector_sprites = _G.circuit_connector_definitions["storage-tank"].sprites -end - -Recipe:extend {recipe, item, entity} - -Recipe("py-tank-5000"):add_unlock("py-storage-tanks") diff --git a/prototypes/buildings/fluid-tanks/tanks-6500.lua b/prototypes/buildings/fluid-tanks/tanks-6500.lua index ef2f03b..3378aa5 100644 --- a/prototypes/buildings/fluid-tanks/tanks-6500.lua +++ b/prototypes/buildings/fluid-tanks/tanks-6500.lua @@ -1,8 +1,9 @@ local Pipes = require("stdlib.data.pipes") local Recipe = require("stdlib/data/recipe") -local pipecoverspictures = _G.pipecoverspictures +local Item = require("stdlib/data/item") +local Entity = require("stdlib/data/entity") -local recipe = { +Recipe { type = "recipe", name = "py-tank-6500", energy_required = 15, @@ -14,12 +15,13 @@ local recipe = { {"steel-plate", 30} }, result = "py-tank-6500" -} +}:add_unlock("py-storage-tanks") -local item = { +Item { type = "item", name = "py-tank-6500", icon = "__pyindustry__/graphics/icons/py-tank-6500.png", + icon_size = 32, flags = {"goes-to-quickbar"}, subgroup = "py-storage-tanks", order = "a-c[py-items]", @@ -27,10 +29,11 @@ local item = { stack_size = 10 } -local entity = { +Entity { type = "storage-tank", name = "py-tank-6500", icon = "__pyindustry__/graphics/icons/py-tank-6500.png", + icon_size = 32, flags = {"placeable-player", "player-creation"}, minable = {hardness = 0.2, mining_time = 3, result = "py-tank-6500"}, max_health = 500, @@ -40,7 +43,7 @@ local entity = { two_direction_only = true, fluid_box = { base_area = 650, - pipe_covers = pipecoverspictures(), + pipe_covers = _G.pipecoverspictures(), pipe_connections = { {position = {0, -3}}, {position = {3, 0}}, @@ -75,38 +78,7 @@ local entity = { apparent_volume = 1.5, max_sounds_per_type = 3 }, - circuit_wire_max_distance = 9 + circuit_wire_max_distance = 9, + circuit_wire_connection_points = _G.circuit_connector_definitions["storage-tank"].points, + circuit_connector_sprites = _G.circuit_connector_definitions["storage-tank"].sprites } - -if _G.get_circuit_connector_sprites then - entity.circuit_connector_sprites = { - _G.get_circuit_connector_sprites({0, 0}, nil, 0), - _G.get_circuit_connector_sprites({0, 0}, nil, 0), - _G.get_circuit_connector_sprites({0, 0}, nil, 0), - _G.get_circuit_connector_sprites({0, 0}, nil, 0) - } - entity.circuit_wire_connection_points = { - { - shadow = {red = {0, 0}, green = {0, 0}}, - wire = {red = {0, 0}, green = {0, 0}} - }, - { - shadow = {red = {0, 0}, green = {0, 0}}, - wire = {red = {0, 0}, green = {0, 0}} - }, - { - shadow = {red = {0, 0}, green = {0, 0}}, - wire = {red = {0, 0}, green = {0, 0}} - }, - { - shadow = {red = {0, 0}, green = {0, 0}}, - wire = {red = {0, 0}, green = {0, 0}} - } - } -else - entity.circuit_wire_connection_points = _G.circuit_connector_definitions["storage-tank"].points - entity.circuit_connector_sprites = _G.circuit_connector_definitions["storage-tank"].sprites -end - -Recipe:extend {recipe, item, entity} -Recipe("py-tank-6500"):add_unlock("py-storage-tanks") diff --git a/prototypes/buildings/fluid-tanks/tanks-7000.lua b/prototypes/buildings/fluid-tanks/tanks-7000.lua index c8d260d..733ee2b 100644 --- a/prototypes/buildings/fluid-tanks/tanks-7000.lua +++ b/prototypes/buildings/fluid-tanks/tanks-7000.lua @@ -1,8 +1,9 @@ local Pipes = require("stdlib.data.pipes") local Recipe = require("stdlib/data/recipe") -local pipecoverspictures = _G.pipecoverspictures +local Item = require("stdlib/data/item") +local Entity = require("stdlib/data/entity") -local recipe = { +Recipe { type = "recipe", name = "py-tank-7000", energy_required = 15, @@ -14,12 +15,13 @@ local recipe = { {"steel-plate", 10} }, result = "py-tank-7000" -} +}:add_unlock("py-storage-tanks") -local item = { +Item { type = "item", name = "py-tank-7000", icon = "__pyindustry__/graphics/icons/py-tank-7000.png", + icon_size = 32, flags = {"goes-to-quickbar"}, subgroup = "py-storage-tanks", order = "a-c[py-items]", @@ -27,77 +29,77 @@ local item = { stack_size = 10 } -local entity = { +Entity { type = "storage-tank", name = "py-tank-7000", icon = "__pyindustry__/graphics/icons/py-tank-7000.png", + icon_size = 32, flags = {"placeable-player", "player-creation"}, minable = {hardness = 0.2, mining_time = 3, result = "py-tank-7000"}, max_health = 100, corpse = "medium-remnants", - collision_box = {{-3.3, -1.3}, {3.3, 1.3}}, - selection_box = {{-3.5, -1.5}, {3.5, 1.5}}, - --two_direction_only = true, + collision_box = {{-1.3, -3.3}, {1.3, 3.3}}, + selection_box = {{-1.5, -3.5}, {1.5, 3.5}}, fluid_box = { base_area = 700, - pipe_covers = pipecoverspictures(), + pipe_covers = _G.pipecoverspictures(), pipe_connections = { - {position = {4.0, -1.0}}, - {position = {4.0, 1.0}} + {position = {-1.0, -4.0}}, + {position = {1.0, -4.0}} } }, window_bounding_box = {{-0.0, 0.0}, {0.0, 0.0}}, pictures = { picture = { north = { - filename = "__pyindustry__/graphics/entity/py-tank-7000/horizontal.png", + filename = "__pyindustry__/graphics/entity/py-tank-7000/north.png", + width = 127, + height = 293, + shift = {0.5, -1}, + hr_version = { + filename = "__pyindustry__/graphics/entity/py-tank-7000/hr-north.png", + width = 253, + height = 585, + shift = {0.5, -1.0}, + scale = 0.5 + } + }, + east = { + filename = "__pyindustry__/graphics/entity/py-tank-7000/east.png", width = 250, height = 150, - shift = {0.32, -0.20}, + shift = {0.35, -0.15}, hr_version = { - filename = "__pyindustry__/graphics/entity/py-tank-7000/hr-horizontal.png", + filename = "__pyindustry__/graphics/entity/py-tank-7000/hr-east.png", width = 499, height = 299, - shift = {0.32, -0.20}, + shift = {0.35, -0.15}, scale = 0.5 } }, - east = { - filename = "__pyindustry__/graphics/entity/py-tank-7000/vertical.png", + south = { + filename = "__pyindustry__/graphics/entity/py-tank-7000/south.png", width = 120, height = 239, - shift = {0.3, -0.2}, + shift = {0.34, -0.0}, hr_version = { - filename = "__pyindustry__/graphics/entity/py-tank-7000/hr-vertical.png", + filename = "__pyindustry__/graphics/entity/py-tank-7000/hr-south.png", width = 239, height = 477, - shift = {0.3, -0.2}, + shift = {0.34, -0.0}, scale = 0.5 } }, - south = { - filename = "__pyindustry__/graphics/entity/py-tank-7000/horizontal.png", + west = { + filename = "__pyindustry__/graphics/entity/py-tank-7000/west.png", width = 250, height = 150, - shift = {0.32, -0.20}, + shift = {0.35, -0.15}, hr_version = { - filename = "__pyindustry__/graphics/entity/py-tank-7000/hr-horizontal.png", + filename = "__pyindustry__/graphics/entity/py-tank-7000/hr-west.png", width = 499, height = 299, - shift = {0.32, -0.20}, - scale = 0.5 - } - }, - west = { - filename = "__pyindustry__/graphics/entity/py-tank-7000/vertical.png", - width = 120, - height = 239, - shift = {0.3, -0.2}, - hr_version = { - filename = "__pyindustry__/graphics/entity/py-tank-7000/hr-vertical.png", - width = 239, - height = 477, - shift = {0.3, -0.2}, + shift = {0.35, -0.15}, scale = 0.5 } } @@ -117,39 +119,7 @@ local entity = { apparent_volume = 1.5, max_sounds_per_type = 3 }, - circuit_wire_max_distance = 9 + circuit_wire_max_distance = 9, + circuit_wire_connection_points = _G.circuit_connector_definitions["storage-tank"].points, + circuit_connector_sprites = _G.circuit_connector_definitions["storage-tank"].sprites } - -if _G.get_circuit_connector_sprites then - entity.circuit_connector_sprites = { - _G.get_circuit_connector_sprites({0, 0}, nil, 0), - _G.get_circuit_connector_sprites({0, 0}, nil, 0), - _G.get_circuit_connector_sprites({0, 0}, nil, 0), - _G.get_circuit_connector_sprites({0, 0}, nil, 0) - } - entity.circuit_wire_connection_points = { - { - shadow = {red = {0, 0}, green = {0, 0}}, - wire = {red = {0, 0}, green = {0, 0}} - }, - { - shadow = {red = {0, 0}, green = {0, 0}}, - wire = {red = {0, 0}, green = {0, 0}} - }, - { - shadow = {red = {0, 0}, green = {0, 0}}, - wire = {red = {0, 0}, green = {0, 0}} - }, - { - shadow = {red = {0, 0}, green = {0, 0}}, - wire = {red = {0, 0}, green = {0, 0}} - } - } -else - entity.circuit_wire_connection_points = _G.circuit_connector_definitions["storage-tank"].points - entity.circuit_connector_sprites = _G.circuit_connector_definitions["storage-tank"].sprites -end - -Recipe:extend {recipe, item, entity} - -Recipe("py-tank-7000"):add_unlock("py-storage-tanks") diff --git a/prototypes/buildings/fluid-tanks/tanks-8000.lua b/prototypes/buildings/fluid-tanks/tanks-8000.lua index 196f8e9..3655e70 100644 --- a/prototypes/buildings/fluid-tanks/tanks-8000.lua +++ b/prototypes/buildings/fluid-tanks/tanks-8000.lua @@ -1,8 +1,9 @@ local Pipes = require("stdlib/data/pipes") local Recipe = require("stdlib/data/recipe") -local pipecoverspictures = _G.pipecoverspictures +local Item = require("stdlib/data/item") +local Entity = require("stdlib/data/entity") -local recipe = { +Recipe { type = "recipe", name = "py-tank-8000", energy_required = 15, @@ -14,12 +15,13 @@ local recipe = { {"steel-plate", 40} }, result = "py-tank-8000" -} +}:add_unlock("py-storage-tanks") -local item = { +Item { type = "item", name = "py-tank-8000", icon = "__pyindustry__/graphics/icons/py-tank-8000.png", + icon_size = 32, flags = {"goes-to-quickbar"}, subgroup = "py-storage-tanks", order = "a-c[py-items]", @@ -27,10 +29,11 @@ local item = { stack_size = 10 } -local entity = { +Entity { type = "storage-tank", name = "py-tank-8000", icon = "__pyindustry__/graphics/icons/py-tank-8000.png", + icon_size = 32, flags = {"placeable-player", "player-creation"}, minable = {hardness = 0.2, mining_time = 3, result = "py-tank-8000"}, max_health = 500, @@ -40,7 +43,7 @@ local entity = { two_direction_only = true, fluid_box = { base_area = 800, - pipe_covers = pipecoverspictures(), + pipe_covers = _G.pipecoverspictures(), pipe_connections = { {position = {0.5, -3.5}}, {position = {-0.5, -3.5}}, @@ -79,42 +82,11 @@ local entity = { apparent_volume = 1.5, max_sounds_per_type = 3 }, - circuit_wire_max_distance = 9 + circuit_wire_max_distance = 9, + circuit_wire_connection_points = _G.circuit_connector_definitions["storage-tank"].points, + circuit_connector_sprites = _G.circuit_connector_definitions["storage-tank"].sprites } -if _G.get_circuit_connector_sprites then - entity.circuit_connector_sprites = { - _G.get_circuit_connector_sprites({0, 0}, nil, 0), - _G.get_circuit_connector_sprites({0, 0}, nil, 0), - _G.get_circuit_connector_sprites({0, 0}, nil, 0), - _G.get_circuit_connector_sprites({0, 0}, nil, 0) - } - entity.circuit_wire_connection_points = { - { - shadow = {red = {0, 0}, green = {0, 0}}, - wire = {red = {0, 0}, green = {0, 0}} - }, - { - shadow = {red = {0, 0}, green = {0, 0}}, - wire = {red = {0, 0}, green = {0, 0}} - }, - { - shadow = {red = {0, 0}, green = {0, 0}}, - wire = {red = {0, 0}, green = {0, 0}} - }, - { - shadow = {red = {0, 0}, green = {0, 0}}, - wire = {red = {0, 0}, green = {0, 0}} - } - } -else - entity.circuit_wire_connection_points = _G.circuit_connector_definitions["storage-tank"].points - entity.circuit_connector_sprites = _G.circuit_connector_definitions["storage-tank"].sprites -end - -Recipe:extend {recipe, item, entity} - -Recipe("py-tank-8000"):add_unlock("py-storage-tanks") Recipe("plankton-farm"):replace_ingredient("storage-tank", "py-tank-8000"):replace_ingredient("stone-brick", "py-asphalt") Recipe("mixer"):replace_ingredient("storage-tank", "py-tank-8000") Recipe("py-heat-exchanger"):replace_ingredient("storage-tank", "py-tank-8000") diff --git a/prototypes/buildings/gas-vent.lua b/prototypes/buildings/gas-vent.lua index 0c31496..1ebf5b5 100644 --- a/prototypes/buildings/gas-vent.lua +++ b/prototypes/buildings/gas-vent.lua @@ -18,6 +18,7 @@ local item = { type = "item", name = "py-gas-vent", icon = "__pyindustry__/graphics/icons/py-gas-vent.png", + icon_size = 32, flags = {"goes-to-quickbar"}, subgroup = "py-industry", order = "a", @@ -30,6 +31,7 @@ local entity = type = "assembling-machine", name = "py-gas-vent", icon = "__pyindustry__/graphics/icons/py-gas-vent.png", + icon_size = 32, flags = {"placeable-neutral", "placeable-player", "player-creation"}, minable = {mining_time = 1, result = "py-gas-vent"}, max_health = 400, @@ -64,7 +66,7 @@ local entity = }, collision_box = {{-0.2, -0.2}, {0.2, 0.2}}, selection_box = {{-0.5, -0.5}, {0.5, 0.5}}, - crafting_categories = {"chemistry"}, + crafting_categories = {"py-venting"}, energy_usage = "1kW", ingredient_count = 2, crafting_speed = 1, diff --git a/prototypes/buildings/radar.lua b/prototypes/buildings/radar.lua index e822f92..5f08b59 100644 --- a/prototypes/buildings/radar.lua +++ b/prototypes/buildings/radar.lua @@ -1,4 +1,6 @@ local Recipe = require("stdlib/data/recipe") +local Item = require("stdlib/data/item") +local Entity = require("stdlib/data/entity") Recipe { type = "recipe", @@ -12,12 +14,13 @@ Recipe { }, result = "py-local-radar", enabled = true -}:extend() +} -local item = { +Item { type = "item", name = "py-local-radar", icon = "__pyindustry__/graphics/icons/radar.png", + icon_size = 32, flags = {"goes-to-quickbar"}, subgroup = "py-industry", order = "d[radar]-a[radar]", @@ -25,10 +28,11 @@ local item = { stack_size = 50 } -local radar = { +Entity { type = "radar", name = "py-local-radar", icon = "__pyindustry__/graphics/icons/radar.png", + icon_size = 32, flags = {"placeable-player", "player-creation"}, minable = {hardness = 0.2, mining_time = 0.5, result = "py-local-radar"}, max_health = 250, @@ -140,5 +144,3 @@ local radar = { }, radius_minimap_visualisation_color = {r = 0.059, g = 0.092, b = 0.235, a = 0.275} } - -Recipe:extend{item, radar} diff --git a/prototypes/buildings/sinkhole.lua b/prototypes/buildings/sinkhole.lua index 08c14c9..a5a5244 100644 --- a/prototypes/buildings/sinkhole.lua +++ b/prototypes/buildings/sinkhole.lua @@ -20,6 +20,7 @@ local item = { type = "item", name = "py-sinkhole", icon = "__pyindustry__/graphics/icons/py-sinkhole.png", + icon_size = 32, flags = {"goes-to-quickbar"}, subgroup = "py-industry", order = "a", @@ -32,6 +33,7 @@ local entity = type = "assembling-machine", name = "py-sinkhole", icon = "__pyindustry__/graphics/icons/py-sinkhole.png", + icon_size = 32, flags = {"placeable-neutral", "placeable-player", "player-creation"}, minable = {mining_time = 1, result = "py-sinkhole"}, max_health = 400, @@ -66,7 +68,7 @@ local entity = }, collision_box = {{-1.2, -1.2}, {1.2, 1.2}}, selection_box = {{-1.5, -1.5}, {1.5, 1.5}}, - crafting_categories = {"chemistry"}, + crafting_categories = {"py-incineration"}, energy_usage = "1kW", ingredient_count = 4, crafting_speed = 1, diff --git a/prototypes/buildings/valves/check-valve.lua b/prototypes/buildings/valves/check-valve.lua new file mode 100644 index 0000000..e0ac865 --- /dev/null +++ b/prototypes/buildings/valves/check-valve.lua @@ -0,0 +1,120 @@ +local Recipe = require("stdlib/data/recipe") +local Item = require("stdlib/data/item") +local Entity = require("stdlib/data/entity") + +Recipe { + type = "recipe", + name = "py-check-valve", + energy_required = 2, + enabled = false, + ingredients = { + {"steel-plate", 1}, + {"iron-gear-wheel", 1}, + {"pipe", 1} + }, + result = "py-check-valve" +}:add_unlock("fluid-handling") + +Item { + type = "item", + name = "py-check-valve", + icon = "__pyindustry__/graphics/icons/check-valve.png", + icon_size = 32, + flags = {"goes-to-quickbar"}, + subgroup = "py-pipes", + order = "pipe[niobium]-flow-a", + place_result = "py-check-valve", + stack_size = 50 +} + +Entity { + name = "py-check-valve", + type = "storage-tank", + minable = {mining_time = 1, result = "py-check-valve"}, + icon = "__pyindustry__/graphics/icons/check-valve.png", + icon_size = 32, + flags = {"placeable-player", "player-creation", "placeable-neutral", "placeable-enemy"}, + corpse = "small-remnants", + max_health = data.raw["pipe"]["pipe"].max_health, + resistances = data.raw["pipe"]["pipe"].resistances, + fast_replaceable_group = data.raw["pipe"]["pipe"].fast_replaceable_group, + collision_box = data.raw["pipe"]["pipe"].collision_box, + selection_box = data.raw["pipe"]["pipe"].selection_box, + window_bounding_box = {{0, 0}, {0, 0}}, + flow_length_in_ticks = 0, + two_direction_only = false, + working_sound = nil, + fluid_box = { + base_area = 1, + pipe_covers = _G.pipecoverspictures(), + pipe_connections = { + {position = {0, 1}, type = "output"}, + {position = {0, -1}} + } + }, + pictures = { + gas_flow = Entity.empty_pictures(), + fluid_background = Entity.empty_pictures(), + window_background = Entity.empty_pictures(), + flow_sprite = Entity.empty_pictures(), + picture = { + sheets = { + { + filename = "__pyindustry__/graphics/entity/py-valves/check-valve.png", + priority = "extra-high", + frames = 4, + width = 32, + height = 64, + shift = {0.0, -0.5}, + hr_version = { + filename = "__pyindustry__/graphics/entity/py-valves/hr-check-valve.png", + priority = "extra-high", + frames = 4, + width = 64, + height = 128, + shift = {0.0, -0.5}, + scale = 0.5 + } + }, + { + filename = "__pyindustry__/graphics/entity/py-valves/check-valve-shadow.png", + priority = "extra-high", + draw_as_shadow = true, + frames = 4, + width = 45, + height = 24, + shift = {0.5, -0.0}, + hr_version = { + filename = "__pyindustry__/graphics/entity/py-valves/hr-check-valve-shadow.png", + priority = "extra-high", + frames = 4, + draw_as_shadow = true, + width = 90, + height = 48, + shift = {0.5, -0.0} + } + } + } + } + }, + circuit_wire_connection_points = { + { + shadow = {red = {0.171875, 0.140625}, green = {0.171875, 0.265625}}, + wire = {red = {-0.53125, -0.15625}, green = {-0.53125, 0}} + }, + { + shadow = {red = {0.890625, 0.703125}, green = {0.75, 0.75}}, + wire = {red = {0.34375, 0.28125}, green = {0.34375, 0.4375}} + }, + { + shadow = {red = {0.15625, 0.0625}, green = {0.09375, 0.125}}, + wire = {red = {-0.53125, -0.09375}, green = {-0.53125, 0.03125}} + }, + { + shadow = {red = {0.796875, 0.703125}, green = {0.625, 0.75}}, + wire = {red = {0.40625, 0.28125}, green = {0.40625, 0.4375}} + } + }, + circuit_connector_sprites = _G.circuit_connector_definitions["inserter"].sprites, + circuit_wire_max_distance = data.raw["storage-tank"]["storage-tank"].circuit_wire_max_distance +} diff --git a/prototypes/buildings/valves/overflow-valve.lua b/prototypes/buildings/valves/overflow-valve.lua new file mode 100644 index 0000000..4b29347 --- /dev/null +++ b/prototypes/buildings/valves/overflow-valve.lua @@ -0,0 +1,122 @@ +local Recipe = require("stdlib/data/recipe") +local Item = require("stdlib/data/item") +local Entity = require("stdlib/data/entity") + +Recipe { + type = "recipe", + name = "py-overflow-valve", + energy_required = 2, + enabled = false, + ingredients = { + {"electronic-circuit", 1}, + {"steel-plate", 1}, + {"iron-gear-wheel", 1}, + {"pipe", 1} + }, + result = "py-overflow-valve" +}:add_unlock("fluid-handling") + +Item { + type = "item", + name = "py-overflow-valve", + icon = "__pyindustry__/graphics/icons/overflow-valve.png", + icon_size = 32, + flags = {"goes-to-quickbar"}, + subgroup = "py-pipes", + order = "pipe[niobium]-flow-b", + place_result = "py-overflow-valve", + stack_size = 50 +} + +Entity { + name = "py-overflow-valve", + type = "storage-tank", + minable = {mining_time = 1, result = "py-overflow-valve"}, + icon = "__pyindustry__/graphics/icons/overflow-valve.png", + icon_size = 32, + flags = {"placeable-player", "player-creation", "placeable-neutral", "placeable-enemy"}, + corpse = "small-remnants", + max_health = data.raw["pipe"]["pipe"].max_health, + resistances = data.raw["pipe"]["pipe"].resistances, + fast_replaceable_group = data.raw["pipe"]["pipe"].fast_replaceable_group, + collision_box = data.raw["pipe"]["pipe"].collision_box, + selection_box = data.raw["pipe"]["pipe"].selection_box, + window_bounding_box = {{0, 0}, {0, 0}}, + flow_length_in_ticks = 0, + two_direction_only = false, + working_sound = nil, + fluid_box = { + base_area = 1, + base_level = 0.8, + pipe_covers = _G.pipecoverspictures(), + pipe_connections = { + {position = {0, 1}, type = "output"}, + {position = {0, -1}} + } + }, + pictures = { + gas_flow = Entity.empty_pictures(), + fluid_background = Entity.empty_pictures(), + window_background = Entity.empty_pictures(), + flow_sprite = Entity.empty_pictures(), + picture = { + sheets = { + { + filename = "__pyindustry__/graphics/entity/py-valves/overflow-valve.png", + priority = "extra-high", + frames = 2, + width = 32, + height = 64, + shift = {0.0, -0.5}, + hr_version = { + filename = "__pyindustry__/graphics/entity/py-valves/hr-overflow-valve.png", + priority = "extra-high", + frames = 2, + width = 64, + height = 128, + shift = {0.0, -0.5}, + scale = 0.5 + } + }, + { + filename = "__pyindustry__/graphics/entity/py-valves/overflow-valve-shadow.png", + priority = "extra-high", + draw_as_shadow = true, + frames = 2, + width = 45, + height = 24, + shift = {0.5, -0.0}, + hr_version = { + filename = "__pyindustry__/graphics/entity/py-valves/hr-overflow-valve-shadow.png", + priority = "extra-high", + frames = 2, + draw_as_shadow = true, + width = 90, + height = 48, + shift = {0.5, -0.0} + } + } + } + } + }, + circuit_wire_connection_points = { + { + shadow = {red = {0.171875, 0.140625}, green = {0.171875, 0.265625}}, + wire = {red = {-0.53125, -0.15625}, green = {-0.53125, 0}} + }, + { + shadow = {red = {0.890625, 0.703125}, green = {0.75, 0.75}}, + wire = {red = {0.34375, 0.28125}, green = {0.34375, 0.4375}} + }, + { + shadow = {red = {0.15625, 0.0625}, green = {0.09375, 0.125}}, + wire = {red = {-0.53125, -0.09375}, green = {-0.53125, 0.03125}} + }, + { + shadow = {red = {0.796875, 0.703125}, green = {0.625, 0.75}}, + wire = {red = {0.40625, 0.28125}, green = {0.40625, 0.4375}} + } + }, + circuit_connector_sprites = _G.circuit_connector_definitions["inserter"].sprites, + circuit_wire_max_distance = data.raw["storage-tank"]["storage-tank"].circuit_wire_max_distance +} diff --git a/prototypes/buildings/valves/underflow-valve.lua b/prototypes/buildings/valves/underflow-valve.lua new file mode 100644 index 0000000..55ecff9 --- /dev/null +++ b/prototypes/buildings/valves/underflow-valve.lua @@ -0,0 +1,122 @@ +local Recipe = require("stdlib/data/recipe") +local Item = require("stdlib/data/item") +local Entity = require("stdlib/data/entity") + +Recipe { + type = "recipe", + name = "py-underflow-valve", + energy_required = 2, + enabled = false, + ingredients = { + {"electronic-circuit", 1}, + {"steel-plate", 1}, + {"iron-gear-wheel", 1}, + {"pipe", 1} + }, + result = "py-underflow-valve" +}:add_unlock("fluid-handling") + +Item { + type = "item", + name = "py-underflow-valve", + icon = "__pyindustry__/graphics/icons/underflow-valve.png", + icon_size = 32, + flags = {"goes-to-quickbar"}, + subgroup = "py-pipes", + order = "pipe[niobium]-flow-c", + place_result = "py-underflow-valve", + stack_size = 50 +} + +Entity { + name = "py-underflow-valve", + type = "storage-tank", + minable = {mining_time = 1, result = "py-underflow-valve"}, + icon = "__pyindustry__/graphics/icons/overflow-valve.png", + icon_size = 32, + flags = {"placeable-player", "player-creation", "placeable-neutral", "placeable-enemy"}, + corpse = "small-remnants", + max_health = data.raw["pipe"]["pipe"].max_health, + resistances = data.raw["pipe"]["pipe"].resistances, + fast_replaceable_group = data.raw["pipe"]["pipe"].fast_replaceable_group, + collision_box = data.raw["pipe"]["pipe"].collision_box, + selection_box = data.raw["pipe"]["pipe"].selection_box, + window_bounding_box = {{0, 0}, {0, 0}}, + flow_length_in_ticks = 0, + two_direction_only = false, + working_sound = nil, + fluid_box = { + base_area = 1, + base_level = -0.2, + pipe_covers = _G.pipecoverspictures(), + pipe_connections = { + {position = {0, 1}, type = "output"}, + {position = {0, -1}} + } + }, + pictures = { + gas_flow = Entity.empty_pictures(), + fluid_background = Entity.empty_pictures(), + window_background = Entity.empty_pictures(), + flow_sprite = Entity.empty_pictures(), + picture = { + sheets = { + { + filename = "__pyindustry__/graphics/entity/py-valves/underflow-valve.png", + priority = "extra-high", + frames = 2, + width = 32, + height = 64, + shift = {0.0, -0.5}, + hr_version = { + filename = "__pyindustry__/graphics/entity/py-valves/hr-underflow-valve.png", + priority = "extra-high", + frames = 2, + width = 64, + height = 128, + shift = {0.0, -0.5}, + scale = 0.5 + } + }, + { + filename = "__pyindustry__/graphics/entity/py-valves/underflow-valve-shadow.png", + priority = "extra-high", + draw_as_shadow = true, + frames = 2, + width = 45, + height = 24, + shift = {0.5, -0.0}, + hr_version = { + filename = "__pyindustry__/graphics/entity/py-valves/hr-underflow-valve-shadow.png", + priority = "extra-high", + draw_as_shadow = true, + frames = 2, + width = 90, + height = 48, + shift = {0.5, -0.0} + } + } + } + } + }, + circuit_wire_connection_points = { + { + shadow = {red = {0.171875, 0.140625}, green = {0.171875, 0.265625}}, + wire = {red = {-0.53125, -0.15625}, green = {-0.53125, 0}} + }, + { + shadow = {red = {0.890625, 0.703125}, green = {0.75, 0.75}}, + wire = {red = {0.34375, 0.28125}, green = {0.34375, 0.4375}} + }, + { + shadow = {red = {0.15625, 0.0625}, green = {0.09375, 0.125}}, + wire = {red = {-0.53125, -0.09375}, green = {-0.53125, 0.03125}} + }, + { + shadow = {red = {0.796875, 0.703125}, green = {0.625, 0.75}}, + wire = {red = {0.40625, 0.28125}, green = {0.40625, 0.4375}} + } + }, + circuit_connector_sprites = _G.circuit_connector_definitions["inserter"].sprites, + circuit_wire_max_distance = data.raw["storage-tank"]["storage-tank"].circuit_wire_max_distance +} diff --git a/prototypes/pipes/niobium-pipes.lua b/prototypes/pipes/niobium-pipes.lua index 79fe510..ae3ef15 100644 --- a/prototypes/pipes/niobium-pipes.lua +++ b/prototypes/pipes/niobium-pipes.lua @@ -1,5 +1,6 @@ local Recipe = require("stdlib/data/recipe") local Item = require("stdlib/data/item") +local Entity = require("stdlib/data/entity") data.raw["pipe-to-ground"]["pipe-to-ground"].fast_replaceable_group = "pipe-to-ground" local function py_pipepictures() @@ -467,7 +468,7 @@ local function py_pipecoverspictures() end --NIOBIUM PIPES -local recipe_niobium_pipe = Recipe { +Recipe { type = "recipe", name = "niobium-pipe", enabled = false, @@ -477,21 +478,22 @@ local recipe_niobium_pipe = Recipe { }, result = "niobium-pipe", result_count = 2 -}:extend() +}:add_unlock({"coal-processing-2", "py-storage-tanks"}):replace_ingredient("copper-plate", "niobium-plate") -local niobium_pipe_ = Item { +Item { type = "item", name = "niobium-pipe", icon = "__pyindustry__/graphics/icons/niobium-pipe.png", + icon_size = 32, flags = {"goes-to-quickbar"}, subgroup = "py-pipes", order = "pipe[niobium]a", place_result = "niobium-pipe", stack_size = 100 -}:extend() +} --NIOBIUM PIPES TO GROUND -local recipe_niobium_pipe_to_ground = Recipe { +Recipe { type = "recipe", name = "niobium-pipe-to-ground", enabled = false, @@ -502,21 +504,19 @@ local recipe_niobium_pipe_to_ground = Recipe { }, result = "niobium-pipe-to-ground", result_count = 2 -}:extend() +}:add_unlock({"coal-processing-2", "py-storage-tanks"}):replace_ingredient("copper-plate", "niobium-plate") -local niobium_pipe_to_ground_ = Item { +Item { type = "item", name = "niobium-pipe-to-ground", icon = "__pyindustry__/graphics/icons/niobium-pipe-to-ground.png", + icon_size = 32, flags = {"goes-to-quickbar"}, subgroup = "py-pipes", order = "pipe[niobium]b", place_result = "niobium-pipe-to-ground", stack_size = 100 -}:extend() - -recipe_niobium_pipe:add_unlock({"coal-processing-2", "py-storage-tanks"}):replace_ingredient("copper-plate", "niobium-plate") -recipe_niobium_pipe_to_ground:add_unlock({"coal-processing-2", "py-storage-tanks"}):replace_ingredient("copper-plate", "niobium-plate") +} local recipes = { "xyhiphoe-pool", "hydrocyclone", "compressor", "genlab", "kmauts-enclosure", "nmf", "py-heat-exchanger", @@ -526,10 +526,11 @@ for _, recipe in pairs(recipes) do Recipe(recipe):replace_ingredient("pipe", "niobium-pipe") end -local pipe = { +Entity { type = "pipe", name = "niobium-pipe", icon = "__pyindustry__/graphics/icons/niobium-pipe.png", + icon_size = 32, flags = {"placeable-neutral", "player-creation"}, minable = {hardness = 0.3, mining_time = 0.5, result = "niobium-pipe"}, max_health = 200, @@ -567,10 +568,11 @@ local pipe = { vertical_window_bounding_box = {{-0.28125, -0.46875}, {0.03125, 0.125}} } -local pipe_to_ground = { +Entity { type = "pipe-to-ground", name = "niobium-pipe-to-ground", icon = "__pyindustry__/graphics/icons/niobium-pipe-to-ground.png", + icon_size = 32, flags = {"placeable-neutral", "player-creation"}, minable = {hardness = 0.3, mining_time = 0.5, result = "niobium-pipe-to-ground"}, max_health = 50, @@ -657,5 +659,3 @@ local pipe_to_ground = { } } } - -data:extend {pipe, pipe_to_ground} diff --git a/prototypes/recipe-categories.lua b/prototypes/recipe-categories.lua new file mode 100644 index 0000000..0184545 --- /dev/null +++ b/prototypes/recipe-categories.lua @@ -0,0 +1,10 @@ +data:extend { + { + type = "recipe-category", + name = "py-incineration" + }, + { + type = "recipe-category", + name = "py-venting" + } +} diff --git a/prototypes/technologies/asphalt.lua b/prototypes/technologies/asphalt.lua index 52c0cd3..bb865d4 100644 --- a/prototypes/technologies/asphalt.lua +++ b/prototypes/technologies/asphalt.lua @@ -1,4 +1,6 @@ -local technology = { +local Technology = require("stdlib/data/technology") + +Technology { type = "technology", name = "py-asphalt", icon = "__pyindustry__/graphics/technology/py-asphalt.png", @@ -6,16 +8,13 @@ local technology = { order = "c-a", prerequisites = {"concrete"}, effects = {}, - unit = - { + unit = { count = 10, ingredients = { {"science-pack-1", 1}, - {"science-pack-2", 1}, + {"science-pack-2", 1} }, time = 35 - }, + } } -data:extend({technology}) - -- add prereq "coal-processing-1" diff --git a/prototypes/technologies/burner.lua b/prototypes/technologies/burner.lua index bbf0fd1..d149385 100644 --- a/prototypes/technologies/burner.lua +++ b/prototypes/technologies/burner.lua @@ -1,4 +1,6 @@ -local technology = { +local Technology = require("stdlib/data/technology") + +Technology { type = "technology", name = "py-burner", icon = "__pyindustry__/graphics/technology/burner.png", @@ -14,4 +16,3 @@ local technology = { time = 45 } } -data:extend {technology} \ No newline at end of file diff --git a/prototypes/technologies/storage-tanks.lua b/prototypes/technologies/storage-tanks.lua index f548897..7def347 100644 --- a/prototypes/technologies/storage-tanks.lua +++ b/prototypes/technologies/storage-tanks.lua @@ -1,4 +1,6 @@ -local technology = { +local Technology = require("stdlib/data/technology") + +Technology { type = "technology", name = "py-storage-tanks", icon = "__pyindustry__/graphics/technology/storage-tanks.png", @@ -6,13 +8,11 @@ local technology = { order = "c-a", prerequisites = {"fluid-handling"}, effects = {}, - unit = - { + unit = { count = 35, ingredients = { - {"science-pack-1", 2}, + {"science-pack-1", 2} }, time = 45 - }, + } } -data:extend({technology}) diff --git a/prototypes/technologies/warehouses.lua b/prototypes/technologies/warehouses.lua index 91c8d62..eaa3d2c 100644 --- a/prototypes/technologies/warehouses.lua +++ b/prototypes/technologies/warehouses.lua @@ -1,4 +1,6 @@ -local warehouse = { +local Technology = require("stdlib/data/technology") + +Technology { type = "technology", name = "py-warehouse-research", icon = "__pyindustry__/graphics/technology/warehouse-research.png", @@ -12,7 +14,8 @@ local warehouse = { }, order = "c-a" } -local logistic_warehouse = { + +Technology { type = "technology", name = "py-warehouse-logistics-research", icon = "__pyindustry__/graphics/technology/warehouse-logistics-research.png", @@ -31,5 +34,3 @@ local logistic_warehouse = { }, order = "c-k-a" } - -data:extend{warehouse, logistic_warehouse} diff --git a/prototypes/tiles/py-asphalt.lua b/prototypes/tiles/py-asphalt.lua index d1944f2..d90eeb0 100644 --- a/prototypes/tiles/py-asphalt.lua +++ b/prototypes/tiles/py-asphalt.lua @@ -22,6 +22,7 @@ local item = { type="item", name="py-asphalt", icon="__pyindustry__/graphics/icons/py-asphalt-icon.png", + icon_size = 32, flags={"goes-to-main-inventory"}, subgroup = "py-tiles", order = "a-asphalt", diff --git a/prototypes/tiles/py-coal-tile.lua b/prototypes/tiles/py-coal-tile.lua index 1cb8ea2..7a8c48a 100644 --- a/prototypes/tiles/py-coal-tile.lua +++ b/prototypes/tiles/py-coal-tile.lua @@ -20,6 +20,7 @@ local item = { type="item", name="py-coal-tile", icon="__pyindustry__/graphics/icons/py-coal-tile-icon.png", + icon_size = 32, flags={"goes-to-main-inventory"}, subgroup = "py-tiles", order = "a-coal-tile", diff --git a/prototypes/tiles/py-limestone.lua b/prototypes/tiles/py-limestone.lua index d6de8ae..50d5eea 100644 --- a/prototypes/tiles/py-limestone.lua +++ b/prototypes/tiles/py-limestone.lua @@ -25,6 +25,7 @@ local item = { type="item", name="py-limestone", icon="__pyindustry__/graphics/icons/py-limestone-icon.png", + icon_size = 32, flags={"goes-to-main-inventory"}, subgroup = "py-tiles", order = "a-limestone", diff --git a/prototypes/wall/concrete-wall.lua b/prototypes/wall/concrete-wall.lua index a83947d..1bf3191 100644 --- a/prototypes/wall/concrete-wall.lua +++ b/prototypes/wall/concrete-wall.lua @@ -18,7 +18,8 @@ local recipe = { local item = { type="item", name="concrete-wall", - icon="__pyindustry__/graphics/icons/concrete-wall.png", + icon="__pyindustry__/graphics/icons/concrete-wall.png", + icon_size = 32, flags={"goes-to-main-inventory"}, subgroup = "py-walls", order = "z", @@ -31,6 +32,7 @@ local entity = { type = "wall", name = "concrete-wall", icon = "__pyindustry__/graphics/icons/concrete-wall.png", + icon_size = 32, flags = {"placeable-neutral", "player-creation"}, collision_box = {{-0.29, -0.29}, {0.29, 0.29}}, selection_box = {{-0.5, -0.5}, {0.5, 0.5}}, diff --git a/prototypes/wall/poorman-wood-fence.lua b/prototypes/wall/poorman-wood-fence.lua index 56a6c95..0eb2f92 100644 --- a/prototypes/wall/poorman-wood-fence.lua +++ b/prototypes/wall/poorman-wood-fence.lua @@ -16,7 +16,8 @@ local recipe = { local item = { type="item", name="poorman-wood-fence", - icon="__pyindustry__/graphics/icons/poorman-wood-fence.png", + icon="__pyindustry__/graphics/icons/poorman-wood-fence.png", + icon_size = 32, flags={"goes-to-main-inventory"}, subgroup = "py-walls", order = "z", @@ -29,6 +30,7 @@ local entity = { type = "wall", name = "poorman-wood-fence", icon = "__pyindustry__/graphics/icons/poorman-wood-fence.png", + icon_size = 32, flags = {"placeable-neutral", "player-creation"}, collision_box = {{-0.29, -0.29}, {0.29, 0.29}}, selection_box = {{-0.5, -0.5}, {0.5, 0.5}}, diff --git a/prototypes/wall/wood-fence.lua b/prototypes/wall/wood-fence.lua index 9520d2a..26281be 100644 --- a/prototypes/wall/wood-fence.lua +++ b/prototypes/wall/wood-fence.lua @@ -1,146 +1,152 @@ local Recipe = require("stdlib/data/recipe") +local Item = require("stdlib/data/item") +local Entity = require("stdlib/data/entity") ---[[Recipes]]-- -local recipe = { +Recipe { type = "recipe", name = "wood-fence", category = "crafting", enabled = false, - ingredients = - { - {type="item", name="wood", amount=2}, + ingredients = { + {type = "item", name = "wood", amount = 2} }, - result = "wood-fence", -} + result = "wood-fence" +}:add_unlock("py-asphalt"):replace_ingredient("wood", "treated-wood") ---[[Items]]-- -local item = { - type="item", - name="wood-fence", - icon="__pyindustry__/graphics/icons/wood-fence.png", - flags={"goes-to-main-inventory"}, +Item { + type = "item", + name = "wood-fence", + icon = "__pyindustry__/graphics/icons/wood-fence.png", + icon_size = 32, + flags = {"goes-to-main-inventory"}, subgroup = "py-walls", order = "z", - place_result = "wood-fence", - stack_size = 100, + place_result = "wood-fence", + stack_size = 100 } ---[[Entites]]-- -local entity = { - type = "wall", - name = "wood-fence", - icon = "__pyindustry__/graphics/icons/wood-fence.png", - flags = {"placeable-neutral", "player-creation"}, - collision_box = {{-0.29, -0.29}, {0.29, 0.29}}, - selection_box = {{-0.5, -0.5}, {0.5, 0.5}}, - --drawing_box = {{-1.5,-1.5},{1.5,1.5}}, - minable = {mining_time = 1, result = "wood-fence"}, - max_health = 100, - corpse = "wall-remnants", - repair_sound = { filename = "__base__/sound/manual-repair-simple.ogg" }, - mined_sound = { filename = "__base__/sound/deconstruct-bricks.ogg" }, - repair_speed_modifier = 4, - fast_replaceable_group = "wall", - vehicle_impact_sound = { filename = "__base__/sound/car-stone-impact.ogg", volume = 1.0 }, - connected_gate_visualization = { filename = "__core__/graphics/arrows/underground-lines.png",priority = "high",width = 64,height = 64,scale = 0.5 }, - wall_diode_green = - { - filename = "__base__/graphics/entity/gate/wall-diode-green.png", - width = 21, - height = 22, - shift = {0, -0.78125} - }, - wall_diode_green_light = - { - minimum_darkness = 0.3, - color = {g=1}, - shift = {0, -0.78125}, - size = 1, - intensity = 0.3 - }, - wall_diode_red = - { - filename = "__base__/graphics/entity/gate/wall-diode-red.png", - width = 21, - height = 22, - shift = {0, -0.78125} - }, - wall_diode_red_light = - { - minimum_darkness = 0.3, - color = {r=1}, - shift = {0, -0.78125}, - size = 1, - intensity = 0.3 - }, - resistances = - { - { type = "physical", decrease = 5, percent = 40 }, - { type = "explosion", decrease = 2, percent = 40 }, - { type = "fire", percent = 20 }, - { type = "acid", percent = 20 }, - }, - pictures = - { - single ={{ - filename = "__pyindustry__/graphics/walls/wood-fence/single.png", - priority = "extra-high", width = 32, height = 49, shift = {0, -0.0} - }}, - straight_vertical = - { - { - filename = "__pyindustry__/graphics/walls/wood-fence/vertical.png", - priority = "extra-high", width = 32, height = 55, shift = {0, -0.0} - }, - }, - straight_horizontal = - { - { - filename = "__pyindustry__/graphics/walls/wood-fence/horizontal.png", - priority = "extra-high", width = 32, height = 48, shift = {0, -0.0} - }, - }, - corner_right_down = - { - { - filename = "__pyindustry__/graphics/walls/wood-fence/corner-right.png", - priority = "extra-high", width = 32, height = 48, shift = {0, -0.0} - } - }, - corner_left_down = - { - { - filename = "__pyindustry__/graphics/walls/wood-fence/corner-left.png", - priority = "extra-high", width = 44, height = 48, shift = {0.2, -0.0} - } - }, - t_up = - { - { - filename = "__pyindustry__/graphics/walls/wood-fence/t-down.png", - priority = "extra-high", width = 32, height = 48, shift = {0, -0.0} - } - }, - ending_right = - { - { - filename = "__pyindustry__/graphics/walls/wood-fence/end-right.png", - priority = "extra-high", width = 32, height = 48, shift = {0, -0.0} - } - }, - ending_left = - { - { - filename = "__pyindustry__/graphics/walls/wood-fence/end-left.png", - priority = "extra-high", width = 32, height = 48, shift = {0, -0.0} - } - } - } - +Entity { + type = "wall", + name = "wood-fence", + icon = "__pyindustry__/graphics/icons/wood-fence.png", + icon_size = 32, + flags = {"placeable-neutral", "player-creation"}, + collision_box = {{-0.29, -0.29}, {0.29, 0.29}}, + selection_box = {{-0.5, -0.5}, {0.5, 0.5}}, + --drawing_box = {{-1.5,-1.5},{1.5,1.5}}, + minable = {mining_time = 1, result = "wood-fence"}, + max_health = 100, + corpse = "wall-remnants", + repair_sound = {filename = "__base__/sound/manual-repair-simple.ogg"}, + mined_sound = {filename = "__base__/sound/deconstruct-bricks.ogg"}, + repair_speed_modifier = 4, + fast_replaceable_group = "wall", + vehicle_impact_sound = {filename = "__base__/sound/car-stone-impact.ogg", volume = 1.0}, + connected_gate_visualization = {filename = "__core__/graphics/arrows/underground-lines.png", priority = "high", width = 64, height = 64, scale = 0.5}, + wall_diode_green = { + filename = "__base__/graphics/entity/gate/wall-diode-green.png", + width = 21, + height = 22, + shift = {0, -0.78125} + }, + wall_diode_green_light = { + minimum_darkness = 0.3, + color = {g = 1}, + shift = {0, -0.78125}, + size = 1, + intensity = 0.3 + }, + wall_diode_red = { + filename = "__base__/graphics/entity/gate/wall-diode-red.png", + width = 21, + height = 22, + shift = {0, -0.78125} + }, + wall_diode_red_light = { + minimum_darkness = 0.3, + color = {r = 1}, + shift = {0, -0.78125}, + size = 1, + intensity = 0.3 + }, + resistances = { + {type = "physical", decrease = 5, percent = 40}, + {type = "explosion", decrease = 2, percent = 40}, + {type = "fire", percent = 20}, + {type = "acid", percent = 20} + }, + pictures = { + single = { + { + filename = "__pyindustry__/graphics/walls/wood-fence/single.png", + priority = "extra-high", + width = 32, + height = 49, + shift = {0, -0.0} + } + }, + straight_vertical = { + { + filename = "__pyindustry__/graphics/walls/wood-fence/vertical.png", + priority = "extra-high", + width = 32, + height = 55, + shift = {0, -0.0} + } + }, + straight_horizontal = { + { + filename = "__pyindustry__/graphics/walls/wood-fence/horizontal.png", + priority = "extra-high", + width = 32, + height = 48, + shift = {0, -0.0} + } + }, + corner_right_down = { + { + filename = "__pyindustry__/graphics/walls/wood-fence/corner-right.png", + priority = "extra-high", + width = 32, + height = 48, + shift = {0, -0.0} + } + }, + corner_left_down = { + { + filename = "__pyindustry__/graphics/walls/wood-fence/corner-left.png", + priority = "extra-high", + width = 44, + height = 48, + shift = {0.2, -0.0} + } + }, + t_up = { + { + filename = "__pyindustry__/graphics/walls/wood-fence/t-down.png", + priority = "extra-high", + width = 32, + height = 48, + shift = {0, -0.0} + } + }, + ending_right = { + { + filename = "__pyindustry__/graphics/walls/wood-fence/end-right.png", + priority = "extra-high", + width = 32, + height = 48, + shift = {0, -0.0} + } + }, + ending_left = { + { + filename = "__pyindustry__/graphics/walls/wood-fence/end-left.png", + priority = "extra-high", + width = 32, + height = 48, + shift = {0, -0.0} + } + } + } } - ---[[Extend Data]]-- -data:extend{recipe, item, entity} - ---coal-processing-1 -Recipe("wood-fence"):add_unlock("py-asphalt"):replace_ingredient("wood", "treated-wood") diff --git a/stdlib/area/area.lua b/stdlib/area/area.lua index 65380d0..c1239e3 100644 --- a/stdlib/area/area.lua +++ b/stdlib/area/area.lua @@ -449,10 +449,6 @@ function Area.shrink_to_surface_size(area, surface) return area end -------------------------------------------------------------------------------- ---[[Entity Helpers]]-- -------------------------------------------------------------------------------- - --- Set the metatable on a stored area without returning a new area. Usefull for restoring -- metatables to saved areas in global -- @tparam Concepts.BoundingBox area diff --git a/stdlib/core.lua b/stdlib/core.lua index 0989d82..2c0a3af 100644 --- a/stdlib/core.lua +++ b/stdlib/core.lua @@ -68,7 +68,7 @@ function Core.fail_if_not_type(var, types) end --- Returns true if the passed variable is a table. --- @tparam mixed tab The variable to check +-- @tparam mixed var The variable to check -- @treturn boolean If the variable is a table function Core.table(var) return type(var) == "table" diff --git a/stdlib/data/category.lua b/stdlib/data/category.lua index 2aba31d..ff71f49 100644 --- a/stdlib/data/category.lua +++ b/stdlib/data/category.lua @@ -43,11 +43,7 @@ function Category:get(category_name, category_type, create_new) for type_name in pairs(types) do local object = data.raw[type_name][category_name] if object then - local mt = { - type = "category", - __index = self - } - return setmetatable(object, mt) + return setmetatable(object, self._mt):extend() end end @@ -57,4 +53,11 @@ function Category:get(category_name, category_type, create_new) end Category:set_caller(Category.get) +Category._mt = { + type = "category", + __index = Category, + __call = Category.get, + __tostring = Category.tostring +} + return Category diff --git a/stdlib/data/core.lua b/stdlib/data/core.lua index ffd3874..1d944c1 100644 --- a/stdlib/data/core.lua +++ b/stdlib/data/core.lua @@ -1,3 +1,6 @@ +--- Data Stage Core +-- @module Data Core + if _G.remote and _G.script then error("Data Modules can only be required in the data stage", 2) end @@ -6,8 +9,8 @@ local Core = { _default_options = { ["silent"] = false, ["fail"] = false, - ['verbose'] = false, - }, + ["verbose"] = false + } } setmetatable(Core, {__index = require("stdlib/core")}) @@ -29,55 +32,72 @@ function Core.map_to_types(type, map) if data.raw[type] then return {[type] = true} else - error("Category "..type.. " does not exist", 2) + error("Category " .. type .. " does not exist", 2) end else return map end end -function Core.get_object(object, class) - if Core.table(object) then - return object.name and object.type == class and object - elseif type(object) == "string" then - return data.raw[class][object] - end -end +--- Quickly duplicate an existing prototype into a new one. +-- @tparam string data_type The type of the object to duplicate +-- @tparam string orig_name The name of the object to duplicate +-- @tpara string new_name The new name to use. +-- @tparam[opt] string|boolean mining_result If true set mining_result to new_name, if truthy set mining_result to value +function Core.duplicate(data_type, orig_name, new_name, mining_result) + mining_result = type(mining_result) == "boolean" and new_name or mining_result + if data.raw[data_type] and data.raw[data_type][orig_name] then + local proto = table.deepcopy(data.raw[data_type][orig_name]) + proto.name = new_name -function Core.valid(this, name) - if name then - return getmetatable(this).type == name and this or nil - else - return getmetatable(this).type and this or nil - end -end + if mining_result then + if proto.minable and proto.minable.result then + proto.minable.result = mining_result + end + end -function Core.save_options(this, opts) - if getmetatable(this) then - getmetatable(this).opts = opts - end - return this -end + if proto.place_result then + proto.place_result = new_name + end -function Core.extend(this, proto_array) - if proto_array then - data:extend(proto_array and #proto_array > 0 and proto_array or {proto_array}) - elseif this and ((this.name and this.type) or this:valid()) then - data:extend{this} + if proto.result then + proto.result = new_name + end + + return (proto) else - error("Could not extend data", 2) + error("Unknown Prototype " .. data_type .. "/" .. orig_name) end - return this end -function Core.extended(this) - return this.name and this.type and data.raw[this.type][this.name] +--Prettier monolith extracting +function Core.extract_monolith(filename, x, y, w, h) + return { + type = "monolith", + top_monolith_border = 0, + right_monolith_border = 0, + bottom_monolith_border = 0, + left_monolith_border = 0, + monolith_image = { + filename = filename, + priority = "extra-high-no-scale", + width = w, + height = h, + x = x, + y = y + } + } end -function Core.tostring(this) - return this.name and this.type and this.name or "" +function Core.get_object(object, class) + if Core.table(object) then + return object.name and object.type and object + elseif type(object) == "string" then + return data.raw[class] and data.raw[class][object] + end end +-- [[PICTURES]] --- Quick to use empty picture. -- @treturn table an empty pictures table function Core.empty_picture() @@ -103,9 +123,9 @@ function Core.empty_pictures() height = empty.height, line_length = 1, frame_count = 1, - shift = { 0, 0}, + shift = {0, 0}, animation_speed = 1, - direction_count=1 + direction_count = 1 } end @@ -113,6 +133,7 @@ function Core.empty_animation() return Core.empty_pictures() end +-- [[METHODS]] --- Quick to use empty animation. -- @treturn table an empty animations table function Core.empty_animations() @@ -128,14 +149,12 @@ function Core.empty_connection_points(count) local points = {} for i = 1, count or 1, 1 do points[i] = { - shadow = - { + shadow = { copper = {0, 0}, green = {0, 0}, red = {0, 0} }, - wire = - { + wire = { copper = {0, 0}, green = {0, 0}, red = {0, 0} @@ -145,4 +164,137 @@ function Core.empty_connection_points(count) return points end +function Core.extend_array(proto_array) + if proto_array then + data:extend(proto_array and #proto_array > 0 and proto_array or {proto_array}) + end +end + +--- Is this a valid object +-- @tparam[opt] string class if present is the object a member of the class +-- @treturn self +function Core:valid(class) + if class then + return getmetatable(self).type == class and self or nil + else + return getmetatable(self).type and self or nil + end +end + +--- Save options to the metatable +-- @tparam table opts +function Core:save_options(opts) + if getmetatable(self) then + getmetatable(self).opts = opts + end + return self +end + +--- Extend object(s) into the data table +-- @tparam[opt] boolean force Extend even if it is already extended +-- @treturn self +function Core:extend(force) + if self and ((self.name and self.type) or self:valid()) then + if not self:extended() or force then + local t = data.raw[self.type] + if t == nil then + t = {} + data.raw[self.type] = t + end + t[self.name] = self + end + else + error("Could not extend data", 2) + end + return self +end + +--- Copies a recipe to a new recipe. +-- @tparam string new_name The new name for the recipe. +-- @treturn self +function Core:copy(new_name, mining_result) + self.fail_if_missing(new_name, "New name is required") + if self:valid() then + mining_result = mining_result or new_name + --local from = self.name + local copy = table.deepcopy(self) + copy.name = new_name + + -- For Entities + if mining_result then + if copy.minable and copy.minable.result then + copy.minable.result = mining_result + end + end + + -- For items + if copy.place_result then + copy.place_result = new_name + end + + -- For recipes, need also to check results!! + if copy.result and self:valid("recipe") then + copy.result = new_name + --copy:replace_result(from, new_name) + end + + return self(copy):extend() + else + error("Cannot Copy invalid prototype", 4) + end +end + +function Core:execute(func, ...) + if self:valid() then + func(self, ...) + end + return self +end + +function Core:add_flag(flag) + if self:valid() then + self.flags = self.flags or {} + for _, existing in pairs(self.flags) do + if existing == flag then + return self + end + end + self.flags[#self.flags + 1] = flag + end + return self +end + +function Core:remove_flag(flag) + if self:valid() then + self.flags = self.flags or {} + for i, existing in pairs(self.flags) do + if existing == flag then + self.flags[i] = nil + return self + end + end + end + return self +end + +function Core:set_fields(tab) + if self:valid() then + for k, v in pairs(tab) do + rawset(self, k, v) + end + end +end + +--- Has this object been extended +-- @treturn self +function Core:extended() + return self.name and self.type and data.raw[self.type] and data.raw[self.type][self.name] +end + +--- Get the objects name. +-- @treturn string the objects name +function Core:tostring() + return self.name and self.type and self.name or "" +end + return Core diff --git a/stdlib/data/data.lua b/stdlib/data/data.lua index 3b5231e..ebc6180 100644 --- a/stdlib/data/data.lua +++ b/stdlib/data/data.lua @@ -4,6 +4,45 @@ local Data = {} --luacheck: allow defined top setmetatable(Data, {__index = require("stdlib/data/core")}) +--- Returns a valid thing object reference. This is the main getter +-- @tparam string|table thing The thing to use, if string the thing must be in data.raw[type], tables are not verified +-- @tparam[opt] string type the thing type +-- @tparam table opts Logging options to pass +-- @treturn Entity +function Data:new(thing, class, opts) + self.fail_if_missing(thing, "thing is required") + + local object = self.get_object(thing, class or thing.type) + + if object then + return setmetatable(thing, Data._mt):extend():save_options(opts) + else + local msg = "Data: "..tostring(thing).." is malformed." + error(msg, 4) + end +end +Data:set_caller(Data.new) + +function Data.new_style(style) + data.raw["gui-style"].default[style.name] = style +end + +function Data.disable_control(control) + if data.raw["custom-input"] and data.raw["custom-input"][control] then + data.raw["custom-input"][control].enabled = false + end +end + +function Data.new_sound(name, file) + Data.fail_if_missing(name) + Data.fail_if_missing(file) + return Data { + type = "sound", + name = name, + filename = file + } +end + --- Change subroup and/or order -- @tparam string data_type -- @tparam string name @@ -49,81 +88,12 @@ function Data.get_icon(data_type, name) return data and data.icon end ---Quickly duplicate an existing prototype into a new one. -function Data.duplicate(data_type, orig_name, new_name, mining_result) - mining_result = type(mining_result) == "boolean" and new_name or mining_result - if data.raw[data_type][orig_name] then - local proto = table.deepcopy(data.raw[data_type][orig_name]) - proto.name = new_name - if mining_result then - if proto.minable and proto.minable.result then - proto.minable.result = mining_result - end - end - if proto.place_result then - proto.place_result = new_name - end - if proto.result then - proto.result = new_name - end - return(proto) - else - error("Unknown Prototype "..data_type.."/".. orig_name ) - end -end - ---Prettier monolith extracting -function Data.extract_monolith(filename, x, y, w, h) - return { - type = "monolith", - - top_monolith_border = 0, - right_monolith_border = 0, - bottom_monolith_border = 0, - left_monolith_border = 0, - - monolith_image = { - filename = filename, - priority = "extra-high-no-scale", - width = w, - height = h, - x = x, - y = y, - }, - } -end - ---Entity! -function Data.create_sound_old(name, file_or_sound_table, volume) - Data.fail_if_missing(name) - Data.fail_if_missing(file_or_sound_table) - local sound = { - type = "explosion", - name = name, - animations = Data.empty_animations() - } - - if type(file_or_sound_table) == "table" then - sound.sound = file_or_sound_table - else - sound.sound = { - filename = file_or_sound_table, - volume = volume or 1 - } - end - data:extend{sound} -end - -function Data.create_sound(name, file) - Data.fail_if_missing(name) - Data.fail_if_missing(file) - local sound = { - type = "sound", - name = name, - filename = file - } - data:extend{sound} -end +Data._mt = { + type = "data", + __index = Data, + __call = Data.get, + __tostring = Data.tostring +} return Data -- render layers diff --git a/stdlib/data/developer/developer.lua b/stdlib/data/developer/developer.lua index c553e4c..2a5960b 100644 --- a/stdlib/data/developer/developer.lua +++ b/stdlib/data/developer/developer.lua @@ -23,7 +23,7 @@ end function Developer.make_test_entities(name) if not data.raw["simple-entity"]["debug-chunk-marker"] then if not name then error("developer chunk markers need mod name") end - local markers = { + Data { type = "simple-entity", name = "debug-chunk-marker", localised_name = "Debug Chunk Markers", @@ -57,7 +57,6 @@ function Developer.make_test_entities(name) } } } - Data:extend{markers} end if not data.raw["electric-energy-interface"]["debug-energy-interface"] then @@ -73,7 +72,7 @@ function Developer.make_test_entities(name) power.vehicle_impact_sound = nil power.working_sound = nil - Data:extend{power} + data:extend{power} end if not data.raw["electric-pole"]["debug-substation"] then @@ -92,7 +91,7 @@ function Developer.make_test_entities(name) pole.vehicle_impact_sound = nil pole.working_sound = nil - Data:extend{pole} + data:extend{pole} end data.raw.tile["lab-dark-1"].map_color = {r=100, g=100, b=100} diff --git a/stdlib/data/entity.lua b/stdlib/data/entity.lua new file mode 100644 index 0000000..c072fb8 --- /dev/null +++ b/stdlib/data/entity.lua @@ -0,0 +1,34 @@ +--- Entity class +-- @classmod Entity + +local Entity = {} +setmetatable(Entity, {__index = require("stdlib/data/core")}) + +--- Returns a valid entity object reference. This is the main getter +-- @tparam string|table entity The entity to use, if string the entity must be in data.raw[type], tables are not verified +-- @tparam[opt] string type the entity type +-- @tparam table opts Logging options to pass +-- @treturn Entity +function Entity:get(entity, type, opts) + self.fail_if_missing(entity, "entity is required") + + local object = self.get_object(entity, type) + + if object then + return setmetatable(object, Entity._mt):extend():save_options(opts) + else + local msg = "Entity: "..tostring(entity).." does not exist." + self.log(msg, opts) + end + return self +end +Entity:set_caller(Entity.get) + +Entity._mt = { + type = "entity", + __index = Entity, + __call = Entity.get, + __tostring = Entity.tostring +} + +return Entity diff --git a/stdlib/data/fluid.lua b/stdlib/data/fluid.lua index d9e40d7..85195ea 100644 --- a/stdlib/data/fluid.lua +++ b/stdlib/data/fluid.lua @@ -10,7 +10,7 @@ function Fluid:get(fluid, opts) local object = self.get_object(fluid, "fluid") if object then - return setmetatable(object, Fluid._mt):save_options(opts) + return setmetatable(object, Fluid._mt):extend():save_options(opts) end local msg = "Fluid: "..tostring(fluid).." does not exist." diff --git a/stdlib/data/item.lua b/stdlib/data/item.lua index 15999cc..d0d069c 100644 --- a/stdlib/data/item.lua +++ b/stdlib/data/item.lua @@ -26,11 +26,9 @@ local item_types = { } function Item:get(item, itype, opts) - local object + local object = self.get_object(item) - if self.table(item) and item.type then - object = self.get_object(item, item.type) - else + if not object then for _, type_name in pairs(itype and {itype} or item_types) do object = self.get_object(item, type_name) if object then @@ -40,7 +38,7 @@ function Item:get(item, itype, opts) end if object then - return setmetatable(object, Item._mt):save_options(opts) + return setmetatable(object, Item._mt):extend():save_options(opts) end local msg = "Item: " .. (itype and (itype .. "/") or "") .. tostring(item) .. " does not exist." @@ -49,32 +47,6 @@ function Item:get(item, itype, opts) end Item:set_caller(Item.get) -function Item:add_flag(flag) - if self:valid() then - self.flags = self.flags or {} - for _, existing in pairs(self.flags) do - if existing == flag then - return self - end - end - self.flags[#self.flags + 1] = flag - end - return self -end - -function Item:remove_flag(flag) - if self:valid() then - self.flags = self.flags or {} - for i, existing in pairs(self.flags) do - if existing == flag then - self.flags[i] = nil - return self - end - end - end - return self -end - Item._mt = { type = "item", __index = Item, diff --git a/stdlib/data/recipe.lua b/stdlib/data/recipe.lua index a3ae7c7..f0d09e0 100644 --- a/stdlib/data/recipe.lua +++ b/stdlib/data/recipe.lua @@ -17,7 +17,7 @@ function Recipe:get(recipe, opts) local object = self.get_object(recipe, "recipe") if object then - return setmetatable(object, Recipe._mt):save_options(opts) + return setmetatable(object, Recipe._mt):extend():save_options(opts) else local msg = "Recipe: "..tostring(recipe).." does not exist." self.log(msg, opts) @@ -26,22 +26,6 @@ function Recipe:get(recipe, opts) end Recipe:set_caller(Recipe.get) ---- Copies a recipe to a new recipe. --- @tparam string new_name The new name for the recipe. --- @treturn Recipe -function Recipe:copy(new_name) - self.fail_if_missing(new_name, "New name is required") - if self:valid("recipe") then - local copy = table.deepcopy(self) - copy.name = new_name - - data:extend{copy} - return Recipe(new_name) - else - return self - end -end - -- Returns a formated ingredient or prodcut table local function format(ingredient, result_count) --[[ @@ -436,7 +420,6 @@ end -- @tparam[opt] string|Concepts.product normal -- @tparam[opt] string|Concepts.product|boolean expensive -- @tparam[opt] string main_product --- @note normal or expensive is required function Recipe:replace_result(result_name, normal, expensive, main_product) if self:valid() and normal or expensive then result_name = format(result_name) diff --git a/stdlib/data/technology.lua b/stdlib/data/technology.lua index b7cc2f4..a750ce3 100644 --- a/stdlib/data/technology.lua +++ b/stdlib/data/technology.lua @@ -45,7 +45,7 @@ function Technology:get(tech, opts) self.fail_if_missing(tech, "tech is required") local object = self.get_object(tech, "technology") if object then - return setmetatable(object, self._mt):save_options(opts) + return setmetatable(object, self._mt):extend():save_options(opts) else local msg = "Technology: " .. tostring(tech) .. " does not exist." self.log(msg, opts) diff --git a/stdlib/event/changes.lua b/stdlib/event/changes.lua index e3990e1..599e094 100644 --- a/stdlib/event/changes.lua +++ b/stdlib/event/changes.lua @@ -1,3 +1,7 @@ +--- Changes +-- @module Changes +-- @usage require("stdlib/event/changes") + local Changes = {_module_name = "Changes"} setmetatable(Changes, {__index = require('stdlib/core')}) diff --git a/stdlib/utils/iterators.lua b/stdlib/utils/iterators.lua index 499b5a4..307550b 100644 --- a/stdlib/utils/iterators.lua +++ b/stdlib/utils/iterators.lua @@ -11,12 +11,19 @@ iter.ipairs = ipairs function iter.spairs(t, order) -- collect the keys local keys = {} - for k in pairs(t) do keys[#keys+1] = k end + for k in pairs(t) do + keys[#keys + 1] = k + end -- if order function given, sort by it by passing the table and keys a, b, -- otherwise just sort the keys if order then - table.sort(keys, function(a,b) return order(t, a, b) end) + table.sort( + keys, + function(a, b) + return order(t, a, b) + end + ) else table.sort(keys) end @@ -45,4 +52,40 @@ function iter.top(t, stop) end end +function iter.wrap(t, start, reverse) + --[[ + -- Returns an iterator that iterates over integer keys in table `t` from the specified start position, wrapping + -- around and ending when it reaches `start` again. + -- + -- `dir` specifies the direction to iterate (negative values for reverse, otherwise forward) + -- `start` specifies the start location. If `nil`, the first returned item will be at the at the start of the table + -- (or the end of the table, if `dir` is negative) + -- + -- Behavior if the table changes size during iteration is undefined. + ]] + local dir = (reverse and -1) or 1 + local len = #t + local i = start + start = start or (reverse and len) or 1 + + return function() + if i == nil then + i = start + return i, t[i] + end + + i = i + dir + if i < 1 then + i = i + len + elseif i > len then + i = i - len + end + + if i == start then + return nil + end + return i, t[i] + end +end + return iter diff --git a/stdlib/utils/table.lua b/stdlib/utils/table.lua index b649f36..fe13655 100644 --- a/stdlib/utils/table.lua +++ b/stdlib/utils/table.lua @@ -202,6 +202,7 @@ end -- @tparam table tblA first table -- @tparam table tblB second table -- @tparam[opt=false] boolean array_merge set to true to merge the tables as an array or false for an associative array +-- @tparam[opt=false] boolean raw use rawset for associated array -- @treturn array|table an array or an associated array where tblA and tblB have been merged function table.merge(tblA, tblB, array_merge, raw) if not tblB then