Sapiens / Сапиенс: localizations.lua 6

Английский оригинал Перевод на русский

Сожалеем, но текст оригинала доступен только зарегистрированным пользователям.

local function getTimeSplit(durationSeconds, dayLength, yearLength)
local result = {
years = 0,
days = 0,
hours = 0,
}

if durationSeconds >= yearLength then
result.years = math.floor(durationSeconds / yearLength)
durationSeconds = durationSeconds - result.years * yearLength
end

if durationSeconds >= dayLength then
result.days = math.floor(durationSeconds / dayLength)
durationSeconds = durationSeconds - result.days * dayLength
end

if durationSeconds > 0 then
result.hours = math.floor(durationSeconds / dayLength * 24)
end

return result
end

DrKirk 27.07.22 в 05:45

0

local function getTimeDurationDescriptionFromSplitTime(timeSplit)
local result = ""
local empty = true
if timeSplit.years > 0 then
local postfix = " год"
if timeSplit.years > 1 then
postfix = " лет"
end
result = mj:tostring(timeSplit.years) .. postfix
empty = false
end

if timeSplit.days > 0 then
local postfix = " день"
if timeSplit.days > 1 then
postfix = " дней"
end

if not empty then
result = result .. ", "
end

result = result .. mj:tostring(timeSplit.days) .. postfix
empty = false
end

if timeSplit.hours > 0 then
local postfix = " час"
if timeSplit.hours > 1 then
postfix = " часов"
end

if not empty then
result = result .. ", "
end

result = result .. mj:tostring(timeSplit.hours) .. postfix
empty = false
else
if empty then
return "< 1 час"
end
end

return result
end

DrKirk 27.07.22 в 05:43

0

function localizations.getTimeDurationDescription(durationSeconds, dayLength, yearLength)
local timeSplit = getTimeSplit(durationSeconds, dayLength, yearLength)
return getTimeDurationDescriptionFromSplitTime(timeSplit)
end

DrKirk 27.07.22 в 05:41

0

function localizations.getTimeRangeDescription(durationSecondsMin, durationSecondsMax, dayLength, yearLength)
local minHourCount = math.floor(durationSecondsMin / dayLength * 24)
local maxHourCount = math.floor(durationSecondsMax / dayLength * 24)
if minHourCount == maxHourCount then
return localizations.getTimeDurationDescription(durationSecondsMin, dayLength, yearLength)
end

if minHourCount == 0 then
local maxDescription = localizations.getTimeDurationDescription(durationSecondsMax, dayLength, yearLength)
return "< " .. maxDescription
end

local timeSplitMin = getTimeSplit(durationSecondsMin, dayLength, yearLength)
local timeSplitMax = getTimeSplit(durationSecondsMax, dayLength, yearLength)

if (timeSplitMin.years == 0 and timeSplitMax.years == 0) then
if (timeSplitMin.days == 0 and timeSplitMax.days == 0) then
return mj:tostring(timeSplitMin.hours) .. " - " .. mj:tostring(timeSplitMax.hours) .. " часов"
end
if (timeSplitMin.hours == 0 and timeSplitMax.hours == 0) then
return mj:tostring(timeSplitMin.days) .. " - " .. mj:tostring(timeSplitMax.days) .. " дней"
end
elseif (timeSplitMin.days == 0 and timeSplitMax.days == 0) and (timeSplitMin.hours == 0 and timeSplitMax.hours == 0) then
return mj:tostring(timeSplitMin.years) .. " - " .. mj:tostring(timeSplitMax.years) .. " лет"
end

local minDescription = getTimeDurationDescriptionFromSplitTime(timeSplitMin)
local maxDescription = getTimeDurationDescriptionFromSplitTime(timeSplitMax)

return minDescription .. " - " .. maxDescription

--[[local minHourCount = math.floor(durationSecondsMin / dayLength * 24)
local maxHourCount = math.floor(durationSecondsMax / dayLength * 24)
if minHourCount == maxHourCount then
return localizations.getTimeDurationDescription(durationSecondsMin, dayLength, yearLength)
end

local maxDescription = localizations.getTimeDurationDescription(durationSecondsMax, dayLength, yearLength)
if minHourCount == 0 then
return "< " .. maxDescription
end

local minDescription = localizations.getTimeDurationDescription(durationSecondsMin, dayLength, yearLength)
return minDescription .. " - " .. maxDescription]]
end

DrKirk 27.07.22 в 05:41

0

function localizations.getBiomeForestDescription(biomeTags)
local typeString = nil

if biomeTags.coniferous then
if biomeTags.birch then
typeString = "сосна и береза"
elseif biomeTags.bamboo then
typeString = "сосна и бамбук"
else
typeString = "сосна"
end
else
typeString = "береза"
end

if not typeString then
return "Нет деревьев."
end

local forestString = true
if biomeTags.mediumForest then
forestString = string.format("%s лес.", mj:capitalize(typeString))
elseif biomeTags.denseForest then
forestString = string.format("Густой %s лес.", typeString)
elseif biomeTags.sparseForest then
forestString = string.format("%s деревья.", mj:capitalize(typeString))
elseif biomeTags.verySparseForest then
forestString = string.format("Очень мало %s деревьев.", typeString)
else
return "Нет деревьев."
end

return forestString

end

DrKirk 27.07.22 в 05:35

0

function localizations.getBiomeMainDescription(biomeTags)
local descriptionString = nil
if biomeTags.tropical then
descriptionString = "Тропический"
elseif biomeTags.polar or biomeTags.icecap or biomeTags.heavySnowSummer or biomeTags.medSnowSummer or biomeTags.lightSnowSummer then
descriptionString = "Ледяной"
elseif biomeTags.temperate then
descriptionString = "Умеренный"
elseif biomeTags.dry then
descriptionString = "Сухой"

DrKirk 27.07.22 в 05:34

0

end

local mainAdded = false

local function addMain(value)
if descriptionString then
descriptionString = descriptionString .. " " .. value .. "."
else
descriptionString = mj:capitalize(value) .. "."
end
mainAdded = true
end

DrKirk 27.07.22 в 05:30

0

if biomeTags.desert then

DrKirk 27.07.22 в 05:30

0

addMain("пустыня")

DrKirk 27.07.22 в 05:30

0

elseif biomeTags.steppe then

DrKirk 27.07.22 в 05:29

0

addMain("степь")

DrKirk 27.07.22 в 05:29

0

elseif biomeTags.rainforest then

DrKirk 27.07.22 в 05:29

0

addMain("тропический лес")

DrKirk 27.07.22 в 05:29

0

elseif biomeTags.savanna then

DrKirk 27.07.22 в 05:29

0

addMain("саванна")

DrKirk 27.07.22 в 05:29

0

elseif biomeTags.tundra then

DrKirk 27.07.22 в 05:28

0

addMain("тундра")
end

DrKirk 27.07.22 в 05:28

0

if not mainAdded then
if not descriptionString then
return ""
end
return descriptionString .. "."
end
return descriptionString
end

DrKirk 27.07.22 в 05:27

0

function localizations.getBiomeTemperatureDescription(biomeTags)

local descriptionString = nil

if biomeTags.temperatureSummerVeryHot then

DrKirk 27.07.22 в 05:24

0

descriptionString = "Очень жаркое лето."

DrKirk 27.07.22 в 05:23

0

elseif biomeTags.temperatureSummerHot then

DrKirk 27.07.22 в 05:23

0

descriptionString = "Жаркое лето."

DrKirk 27.07.22 в 05:23

0

elseif biomeTags.temperatureSummerCold then

DrKirk 27.07.22 в 05:23

0

descriptionString = "Холодное лето."

DrKirk 27.07.22 в 05:23

0

elseif biomeTags.temperatureSummerVeryCold then

DrKirk 27.07.22 в 05:22

0

descriptionString = "Очень холодное лето."

DrKirk 27.07.22 в 05:22

0

else
descriptionString = "Умеренное лето."

DrKirk 27.07.22 в 05:17

0

end
if biomeTags.temperatureWinterVeryHot then

DrKirk 27.07.22 в 05:16

0

descriptionString = descriptionString .. " Очень жаркая зима."

DrKirk 27.07.22 в 05:15

0

elseif biomeTags.temperatureWinterHot then

DrKirk 27.07.22 в 05:15

0

descriptionString = descriptionString .. " Жаркая зимаr."

DrKirk 27.07.22 в 05:15

0

elseif biomeTags.temperatureWinterCold then

DrKirk 27.07.22 в 05:15

0

descriptionString = descriptionString .. " Холодная зима."

DrKirk 27.07.22 в 05:15

0

elseif biomeTags.temperatureWinterVeryCold then

DrKirk 27.07.22 в 05:14

0

descriptionString = descriptionString .. " Очень холодная зима."

DrKirk 27.07.22 в 05:14

0

else
descriptionString = descriptionString .. " Умеренная зима."
end

DrKirk 27.07.22 в 05:14

0

turn descriptionString
end

DrKirk 27.07.22 в 05:13

0

function localizations.getBiomeFullDescription(biomeTags) --b13
return localizations.getBiomeMainDescription(biomeTags) .. " " .. localizations.getBiomeForestDescription(biomeTags) .. " " .. localizations.getBiomeTemperatureDescription(biomeTags)
end

--mj:log("localizations count:", #(localizations.localizations))

return localizations

DrKirk 27.07.22 в 05:12

0
Минутку...