66 469
contributi
Nessun oggetto della modifica |
Nessun oggetto della modifica |
||
(6 versioni intermedie di uno stesso utente non sono mostrate) | |||
Riga 218: | Riga 218: | ||
local Match = string.match(TestString, "[^%s]+$") | local Match = string.match(TestString, "[^%s]+$") | ||
return Match .. " - " .. string.upper(string.sub(Match, 1, 1)) | return Match .. " - " .. string.upper(string.sub(Match, 1, 1)) | ||
end | |||
--- Extract the name of a ship from its full designation | |||
-- | |||
-- @param frame The interface to the parameters passed to {{#invoke:}} | |||
-- @return Bare name- of the ship | |||
function p.ShipName(frame) | |||
local FullName = frame.args[1] | |||
local Prefixes = {"USS ", "IKS ", "ECS ", "''", "<i>", "</i>"} | |||
-- Removes prefix | |||
for _, Prefix in ipairs(Prefixes) do | |||
FullName = FullName:gsub((Prefix), "") | |||
end | |||
--Removes suffix | |||
FullName = FullName:gsub("%s[^%s]+$", "") | |||
return FullName | |||
end | end | ||
--- Test function to check properties sorting | --- Test function to check properties sorting |