mirror of
https://github.com/Oarcinae/FactorioScenarioMultiplayerSpawn.git
synced 2025-02-07 13:07:58 +02:00
Change resource placement in semi-circle to use degrees not radians in settings.
This commit is contained in:
parent
71a35efad3
commit
57187624a8
@ -456,14 +456,14 @@ OCFG = {
|
|||||||
-- Distance in tiles from the edge of spawn that resources are placed. Only applicable for circular spawns.
|
-- Distance in tiles from the edge of spawn that resources are placed. Only applicable for circular spawns.
|
||||||
distance_to_edge = 20,
|
distance_to_edge = 20,
|
||||||
|
|
||||||
-- At what angle (in radians) do resources start.
|
-- At what angle (in degrees) do resources start.
|
||||||
-- 0 means starts directly east.
|
-- 0 means starts directly east.
|
||||||
-- Resources are placed clockwise from there.
|
-- Resources are placed clockwise from there.
|
||||||
angle_offset = 2.09, -- Approx SSW.
|
angle_offset = 120, -- Approx SSW.
|
||||||
|
|
||||||
-- At what andle do we place the last resource.
|
-- At what andle do we place the last resource.
|
||||||
-- angle_offset and angle_final determine spacing and placement.
|
-- angle_offset and angle_final determine spacing and placement.
|
||||||
angle_final = 4.18, -- Approx NNW.
|
angle_final = 240, -- Approx NNW.
|
||||||
|
|
||||||
-- Vertical offset in tiles for the deposit resource placement. Starting from top-left corner.
|
-- Vertical offset in tiles for the deposit resource placement. Starting from top-left corner.
|
||||||
-- Only applicable for square spawns.
|
-- Only applicable for square spawns.
|
||||||
@ -648,8 +648,8 @@ OCFG = {
|
|||||||
---@class OarcConfigSpawnResourcePlacementSettings
|
---@class OarcConfigSpawnResourcePlacementSettings
|
||||||
---@field enabled boolean Autoplace resources. This will ignore the fixed x_offset/y_offset values in solid_resources. Only works for solid_resources at the moment, not oil patches/water.
|
---@field enabled boolean Autoplace resources. This will ignore the fixed x_offset/y_offset values in solid_resources. Only works for solid_resources at the moment, not oil patches/water.
|
||||||
---@field distance_to_edge number Distance in tiles from the edge of spawn that resources are placed. Only applicable for circular spawns.
|
---@field distance_to_edge number Distance in tiles from the edge of spawn that resources are placed. Only applicable for circular spawns.
|
||||||
---@field angle_offset number At what angle (in radians) do resources start. 0 means starts directly east. Resources are placed clockwise from there. Only applicable for circular spawns.
|
---@field angle_offset integer At what angle (in degrees) do resources start. 0 means starts directly east. Resources are placed clockwise from there. Only applicable for circular spawns.
|
||||||
---@field angle_final number At what andle do we place the last resource. angle_offset and angle_final determine spacing and placement. Only applicable for circular spawns.
|
---@field angle_final integer At what andle do we place the last resource. angle_offset and angle_final determine spacing and placement. Only applicable for circular spawns.
|
||||||
---@field vertical_offset number Vertical offset in tiles for the deposit resource placement. Only applicable for square spawns.
|
---@field vertical_offset number Vertical offset in tiles for the deposit resource placement. Only applicable for square spawns.
|
||||||
---@field horizontal_offset number Horizontal offset in tiles for the deposit resource placement. Only applicable for square spawns.
|
---@field horizontal_offset number Horizontal offset in tiles for the deposit resource placement. Only applicable for square spawns.
|
||||||
---@field linear_spacing number Spacing between resource deposits in tiles. Only applicable for square spawns.
|
---@field linear_spacing number Spacing between resource deposits in tiles. Only applicable for square spawns.
|
||||||
|
@ -70,8 +70,8 @@ OCFG_KEYS =
|
|||||||
|
|
||||||
["resource_placement_circle_SUBHEADER"] = {mod_key = "" , ocfg_keys = {""}, type = "subheader", text = {"oarc-settings-section-subheader-resource-placement-circular"}},
|
["resource_placement_circle_SUBHEADER"] = {mod_key = "" , ocfg_keys = {""}, type = "subheader", text = {"oarc-settings-section-subheader-resource-placement-circular"}},
|
||||||
["resource_placement.distance_to_edge"] = {mod_key = "oarc-mod-resource-placement-distance-to-edge" , ocfg_keys = {"resource_placement", "distance_to_edge"}, type = "integer"},
|
["resource_placement.distance_to_edge"] = {mod_key = "oarc-mod-resource-placement-distance-to-edge" , ocfg_keys = {"resource_placement", "distance_to_edge"}, type = "integer"},
|
||||||
["resource_placement.angle_offset"] = {mod_key = "oarc-mod-resource-placement-angle-offset" , ocfg_keys = {"resource_placement", "angle_offset"}, type = "double"},
|
["resource_placement.angle_offset"] = {mod_key = "oarc-mod-resource-placement-angle-offset" , ocfg_keys = {"resource_placement", "angle_offset"}, type = "integer"},
|
||||||
["resource_placement.angle_final"] = {mod_key = "oarc-mod-resource-placement-angle-final" , ocfg_keys = {"resource_placement", "angle_final"}, type = "double"},
|
["resource_placement.angle_final"] = {mod_key = "oarc-mod-resource-placement-angle-final" , ocfg_keys = {"resource_placement", "angle_final"}, type = "integer"},
|
||||||
|
|
||||||
["resource_placement_square_SUBHEADER"] = {mod_key = "" , ocfg_keys = {""}, type = "subheader", text = {"oarc-settings-section-subheader-resource-placement-square"}},
|
["resource_placement_square_SUBHEADER"] = {mod_key = "" , ocfg_keys = {""}, type = "subheader", text = {"oarc-settings-section-subheader-resource-placement-square"}},
|
||||||
["resource_placement.vertical_offset"] = {mod_key = "oarc-mod-resource-placement-vertical-offset" , ocfg_keys = {"resource_placement", "vertical_offset"}, type = "integer"},
|
["resource_placement.vertical_offset"] = {mod_key = "oarc-mod-resource-placement-vertical-offset" , ocfg_keys = {"resource_placement", "vertical_offset"}, type = "integer"},
|
||||||
|
@ -352,15 +352,16 @@ function PlaceResourcesInSemiCircle(surface, position, size_mod, amount_mod)
|
|||||||
local shuffled_list = FYShuffle(r_list)
|
local shuffled_list = FYShuffle(r_list)
|
||||||
|
|
||||||
-- This places resources in a semi-circle
|
-- This places resources in a semi-circle
|
||||||
local angle_offset = global.ocfg.resource_placement.angle_offset
|
local angle_offset_radians = math.rad(global.ocfg.resource_placement.angle_offset)
|
||||||
|
local angle_final_radians = math.rad(global.ocfg.resource_placement.angle_final)
|
||||||
local num_resources = table_size(global.ocfg.surfaces_config[surface.name].spawn_config.solid_resources)
|
local num_resources = table_size(global.ocfg.surfaces_config[surface.name].spawn_config.solid_resources)
|
||||||
local theta = ((global.ocfg.resource_placement.angle_final - global.ocfg.resource_placement.angle_offset) / (num_resources-1));
|
local theta = ((angle_final_radians - angle_offset_radians) / (num_resources-1));
|
||||||
local count = 0
|
local count = 0
|
||||||
|
|
||||||
local radius = global.ocfg.spawn_general.spawn_radius_tiles - global.ocfg.resource_placement.distance_to_edge
|
local radius = global.ocfg.spawn_general.spawn_radius_tiles - global.ocfg.resource_placement.distance_to_edge
|
||||||
|
|
||||||
for _, r_name in pairs(shuffled_list) do
|
for _, r_name in pairs(shuffled_list) do
|
||||||
local angle = (theta * count) + angle_offset;
|
local angle = (theta * count) + angle_offset_radians;
|
||||||
|
|
||||||
local tx = (radius * math.cos(angle)) + position.x
|
local tx = (radius * math.cos(angle)) + position.x
|
||||||
local ty = (radius * math.sin(angle)) + position.y
|
local ty = (radius * math.sin(angle)) + position.y
|
||||||
|
@ -115,8 +115,8 @@ oarc-mod-spawn-general-shape=This is the shape of the spawn area.
|
|||||||
|
|
||||||
oarc-mod-resource-placement-enabled=You should leave this enabled unless you are manually specifying resource placements in the custom scenario!
|
oarc-mod-resource-placement-enabled=You should leave this enabled unless you are manually specifying resource placements in the custom scenario!
|
||||||
oarc-mod-resource-placement-distance-to-edge=This is the distance from the edge of the spawn area that resources will be placed. Only applicable for circle/octagon shaped spawns.
|
oarc-mod-resource-placement-distance-to-edge=This is the distance from the edge of the spawn area that resources will be placed. Only applicable for circle/octagon shaped spawns.
|
||||||
oarc-mod-resource-placement-angle-offset=This is the starting angle offset (in radians) for the resource placement. At what angle (in radians) do resources start. 0 = east. 3.14 = west. Resources are placed clockwise starting at this angle. Only applicable for circle/octagon shaped spawns.
|
oarc-mod-resource-placement-angle-offset=This is the starting angle offset (in degrees) for the resource placement. At what angle (in degrees) do resources start. 0 = east. 90 = south. Resources are placed clockwise starting at this angle. Only applicable for circle/octagon shaped spawns.
|
||||||
oarc-mod-resource-placement-angle-final=This is the final angle offset (in radians) for the resource placement. At what angle (in radians) do resources end. 0 = east. 3.14 = west. Resources are placed clockwise ending at this angle. Only applicable for circle/octagon shaped spawns.
|
oarc-mod-resource-placement-angle-final=This is the final angle offset (in degrees) for the resource placement. At what angle (in degrees) do resources end. 0 = east. 90 = south. Resources are placed clockwise ending at this angle. Only applicable for circle/octagon shaped spawns.
|
||||||
oarc-mod-resource-placement-vertical-offset=This is the vertical offset (in tiles) for the resource placement from the top-left of the spawn. Only applicable for square shaped spawns.
|
oarc-mod-resource-placement-vertical-offset=This is the vertical offset (in tiles) for the resource placement from the top-left of the spawn. Only applicable for square shaped spawns.
|
||||||
oarc-mod-resource-placement-horizontal-offset=This is the horizontal offset (in tiles) for the resource placement from the top-left of the spawn. Only applicable for square shaped spawns.
|
oarc-mod-resource-placement-horizontal-offset=This is the horizontal offset (in tiles) for the resource placement from the top-left of the spawn. Only applicable for square shaped spawns.
|
||||||
oarc-mod-resource-placement-linear-spacing=This is the linear spacing (in tiles) between resources. Only applicable for square shaped spawns.
|
oarc-mod-resource-placement-linear-spacing=This is the linear spacing (in tiles) between resources. Only applicable for square shaped spawns.
|
||||||
|
9
migrations/oarc-mod_V2.0.4.lua
Normal file
9
migrations/oarc-mod_V2.0.4.lua
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
--If angle offset and angle final are the same as the default radian values, migrate them?
|
||||||
|
if (settings.global["oarc-mod-resource-placement-angle-offset"].value == 2) and
|
||||||
|
(settings.global["oarc-mod-resource-placement-angle-final"].value == 4) then
|
||||||
|
settings.global["oarc-mod-resource-placement-angle-offset"] = { value = 120 }
|
||||||
|
settings.global["oarc-mod-resource-placement-angle-final"] = { value = 240 }
|
||||||
|
global.ocfg.resource_placement.angle_offset = 120
|
||||||
|
global.ocfg.resource_placement.angle_final = 240
|
||||||
|
log("Migrated resource placement angle offset and final from default radian values to degrees")
|
||||||
|
end
|
12
settings.lua
12
settings.lua
@ -345,21 +345,21 @@ data:extend({
|
|||||||
order = "i2"
|
order = "i2"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type = "double-setting",
|
type = "int-setting",
|
||||||
name = "oarc-mod-resource-placement-angle-offset",
|
name = "oarc-mod-resource-placement-angle-offset",
|
||||||
setting_type = "runtime-global",
|
setting_type = "runtime-global",
|
||||||
default_value = 2.09,
|
default_value = 120,
|
||||||
minimum_value = 0,
|
minimum_value = 0,
|
||||||
maximum_value = 6.28,
|
maximum_value = 359,
|
||||||
order = "i3"
|
order = "i3"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type = "double-setting",
|
type = "int-setting",
|
||||||
name = "oarc-mod-resource-placement-angle-final",
|
name = "oarc-mod-resource-placement-angle-final",
|
||||||
setting_type = "runtime-global",
|
setting_type = "runtime-global",
|
||||||
default_value = 4.18,
|
default_value = 240,
|
||||||
minimum_value = 0,
|
minimum_value = 0,
|
||||||
maximum_value = 6.28,
|
maximum_value = 359,
|
||||||
order = "i4"
|
order = "i4"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user