mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-01-24 03:47:58 +02:00
2944a907aa
Changes: - Changed requirements for placing structures on islands: instead of trying to squeeze in-between trees, now it needs a single corner to be on land (it still can't spawn in ocean). In result, islands with more dense forests should see special structures more often and more scattered around the island, rather than them spawning mostly on beaches (because they had no trees) - When area in which structure is going to be placed contains water, it's replaced with landfill - New structure: friendly small-cliff-base with cliffs, gun turrets and car - Captain's cabin now contains cliff-explosives that can be placed in hold's chests to remove them - Moved repeating code snippets into seperate functions
69 lines
1.9 KiB
Lua
69 lines
1.9 KiB
Lua
-- This file is part of thesixthroc's Pirate Ship softmod, licensed under GPLv3 and stored at https://github.com/danielmartin0/ComfyFactorio-Pirates.
|
|
|
|
|
|
-- local Memory = require 'maps.pirates.memory'
|
|
-- local Math = require 'maps.pirates.math'
|
|
-- local Balance = require 'maps.pirates.balance'
|
|
-- local Common = require 'maps.pirates.common'
|
|
local CoreData = require 'maps.pirates.coredata'
|
|
-- local Utils = require 'maps.pirates.utils_local'
|
|
-- local _inspect = require 'utils.inspect'.inspect
|
|
|
|
local Public = {}
|
|
local enum = {
|
|
SEA = 'Sea',
|
|
ISLAND = 'Island',
|
|
CROWSNEST = 'Crowsnest',
|
|
LOBBY = 'Lobby',
|
|
HOLD = 'Hold',
|
|
CABIN = 'Cabin',
|
|
CHANNEL = 'Channel',
|
|
DOCK = 'Dock',
|
|
}
|
|
Public.enum = enum
|
|
|
|
|
|
function Public.encode_surface_name(crewid, destination_index, type, subtype) -- crewid=0 is shared surfaces
|
|
local str
|
|
if subtype then
|
|
str = string.format('%03d-%03d-%s-%s', crewid, destination_index, type, subtype) --uses the fact that type and subtype resolve to strings
|
|
else
|
|
str = string.format('%03d-%03d-%s', crewid, destination_index, type)
|
|
end
|
|
return str
|
|
end
|
|
|
|
function Public.decode_surface_name(name)
|
|
local crewid = tonumber(string.sub(name, 1, 3)) or nil
|
|
local destination_index = tonumber(string.sub(name, 5, 7)) or nil
|
|
local type = nil
|
|
local subtype = nil
|
|
|
|
local substring = string.sub(name, 9, -1)
|
|
local pull = {}
|
|
for a, b in string.gmatch(substring, "(%w+)-(%w+)") do
|
|
pull[1] = a
|
|
pull[2] = b
|
|
end
|
|
if #pull == 0 then
|
|
type = substring
|
|
elseif #pull == 2 then
|
|
type = pull[1]
|
|
subtype = pull[2]
|
|
end
|
|
return {crewid = crewid, destination_index = destination_index, type = type, subtype = subtype}
|
|
end
|
|
|
|
function Public.fetch_iconized_map(destination)
|
|
local type = destination.type
|
|
|
|
if type == Public.enum.LOBBY then
|
|
return CoreData.Lobby_iconized_map()
|
|
elseif type == Public.enum.DOCK then
|
|
return CoreData.Dock_iconized_map()
|
|
else
|
|
return destination.iconized_map
|
|
end
|
|
end
|
|
|
|
return Public |