Skip to content

Commit

Permalink
fix(SE): fixed compatibility startup crash
Browse files Browse the repository at this point in the history
  • Loading branch information
fgardt committed Nov 27, 2023
1 parent c856a6c commit 214e44f
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 18 deletions.
8 changes: 8 additions & 0 deletions const.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
local const = {}

const.ROOT = "__vehicle-deployer__"
const.PREFIX = "VD_"
const.ENTITY = const.PREFIX .. "vehicle-deployer"
const.CATEGORY = const.PREFIX .. "vehicle-deployment"

return const
9 changes: 5 additions & 4 deletions control.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
local const = require("const")
local ev = defines.events
local deploy_offset = 3.5

Expand Down Expand Up @@ -48,10 +49,10 @@ local function deployer_built(event)
end

-- register all build events and filter for vehicle-deployer
script.on_event(ev.on_built_entity, deployer_built, { { filter = "name", name = "VD_vehicle-deployer" } })
script.on_event(ev.on_robot_built_entity, deployer_built, { { filter = "name", name = "VD_vehicle-deployer" } })
script.on_event(ev.script_raised_built, deployer_built, { { filter = "name", name = "VD_vehicle-deployer" } })
script.on_event(ev.script_raised_revive, deployer_built, { { filter = "name", name = "VD_vehicle-deployer" } })
script.on_event(ev.on_built_entity, deployer_built, { { filter = "name", name = const.ENTITY } })
script.on_event(ev.on_robot_built_entity, deployer_built, { { filter = "name", name = const.ENTITY } })
script.on_event(ev.script_raised_built, deployer_built, { { filter = "name", name = const.ENTITY } })
script.on_event(ev.script_raised_revive, deployer_built, { { filter = "name", name = const.ENTITY } })


script.on_event(ev.on_entity_destroyed, function(event)
Expand Down
4 changes: 3 additions & 1 deletion prototypes/compatibility/space-exploration.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
local const = require("const")

if not mods["space-exploration"] then return end

local deployer = data.raw.furnace["vehicle-deployer"]
local deployer = data.raw.furnace[const.ENTITY]

deployer.se_allow_in_space = true
21 changes: 11 additions & 10 deletions prototypes/deployer.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local graphics_path = "__vehicle-deployer__/graphics/"
local const = require("const")
local graphics_path = const.ROOT .. "/graphics/"

-- icon
---@type data.IconData
Expand All @@ -14,14 +15,14 @@ local entity_graphics_path = graphics_path .. "entity/vehicle-deployer/"
---@type data.FurnacePrototype
local entity = {
type = "furnace",
name = "VD_vehicle-deployer",
name = const.ENTITY,
icons = { deployer_icon },

source_inventory_size = 1,
result_inventory_size = 0,
base_productivity = 0,
crafting_speed = 1,
crafting_categories = { "VD_vehicle-deployment" },
crafting_categories = { const.CATEGORY },
allowed_effects = { "consumption", "pollution" },
module_specification = { module_slots = 0 },

Expand All @@ -44,7 +45,7 @@ local entity = {
selection_box = { { -1.5, -1.0 }, { 1.5, 1.0 } },
minable = {
mining_time = 0.75,
result = "VD_vehicle-deployer"
result = const.ENTITY
},

flags = {
Expand Down Expand Up @@ -250,13 +251,13 @@ local entity = {
---@type data.ItemPrototype
local item = {
type = "item",
name = "VD_vehicle-deployer",
name = const.ENTITY,
icons = { deployer_icon },

stack_size = 10,
default_request_amount = 5,

place_result = "VD_vehicle-deployer",
place_result = const.ENTITY,
subgroup = "transport",
order = "z[vehicle-deployer]"
}
Expand All @@ -265,14 +266,14 @@ local item = {
---@type data.RecipePrototype
local recipe = {
type = "recipe",
name = "VD_vehicle-deployer",
name = const.ENTITY,
enabled = false,
ingredients = {
{ "processing-unit", 50 },
{ "steel-plate", 15 },
{ "electric-engine-unit", 10 }
},
result = "VD_vehicle-deployer",
result = const.ENTITY,
result_count = 1,
energy_required = 10
}
Expand All @@ -281,14 +282,14 @@ local recipe = {
---@type data.TechnologyPrototype
local technology = {
type = "technology",
name = "VD_vehicle-deployer",
name = const.ENTITY,
icon = graphics_path .. "technology/vehicle-deployer.png",
icon_mipmaps = 4,
icon_size = 256,
effects = {
{
type = "unlock-recipe",
recipe = "VD_vehicle-deployer"
recipe = const.ENTITY
}
},
prerequisites = { "utility-science-pack" },
Expand Down
8 changes: 5 additions & 3 deletions prototypes/vehicle-recipes.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
local const = require("const")

-- add deploy recipe category
data:extend({ {
type = "recipe-category",
name = "VD_vehicle-deployment"
name = const.CATEGORY
} --[[@as data.RecipeCategory]]
})

Expand Down Expand Up @@ -48,10 +50,10 @@ for name, vehicle in pairs(vehicles) do
for _, item in pairs(items) do
data:extend({ {
type = "recipe",
name = "VD_vehicle-deploy-" .. name .. "-" .. item.name,
name = const.PREFIX .. "vehicle-deploy-" .. name .. "-" .. item.name,
hide_from_player_crafting = true,
enabled = true,
category = "VD_vehicle-deployment",
category = const.CATEGORY,
ingredients = { { item.name, 1 } },
result = item.name,
energy_required = 10,
Expand Down

0 comments on commit 214e44f

Please sign in to comment.