Anonimo

Modulo:FunzioniGeneriche: differenze tra le versioni

Da Wikitrek.
Ship name extraction
Nessun oggetto della modifica
(Ship name extraction)
Riga 219: Riga 219:
return Match .. " - " .. string.upper(string.sub(Match, 1, 1))
return Match .. " - " .. string.upper(string.sub(Match, 1, 1))
end
end
--- Extarct the name of a ship from full designation
--- Extract the name of a ship from its full designation
--
--
-- @param frame The interface to the parameters passed to {{#invoke:}}
-- @param frame The interface to the parameters passed to {{#invoke:}}
-- @return Bare name
-- @return Bare name- of the ship
function p.ShipName(frame)
function p.ShipName(frame)
local FullName = frame.args[1]
local FullName = frame.args[1]
local Prefixes = {"USS ", "IKS ", "ECS "}
local Prefixes = {"USS ", "IKS ", "ECS "}
-- Removes prefix
for _, Prefix in ipairs(Prefixes) do
for _, Prefix in ipairs(Prefixes) do
FullName = FullName:gsub((Prefix), "")
FullName = FullName:gsub((Prefix), "")
end
end
--Removes suffix
FullName = FullName:gsub("%s[^%s]+$", "")
FullName = FullName:gsub("%s[^%s]+$", "")