Home
Random
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Sandbox/Matroc/Ship prefix
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
-- Module:Ship prefix - testing module for existing template Ship prefix -- which give the len of certain ship prefixes?? -- Created several tables in alphabetical order for easy viewing/editorial purposes -- Joined all the tables into one for processing -- Direct invoke: {{#invoke:Ship prefix|prefix|HMS Hood}} -- Template:Ship prefix -- {{#invoke:Ship prefix|prefix|{{{1|}}}}}<noinclude> -- {{documentation}} -- </noinclude> local p = {} function p.prefix(frame) local prefix_list = {} local t1 = {} local t2 = { 'CS', 'MS', 'MV', 'PS', 'RV', 'SM', 'SS' } local t3 = { 'ARA', 'ARC', 'CSS', 'GTS', 'HMS', 'HMT', 'HMC', 'INS', 'KDM', 'NRP', 'ORP', 'RMS', 'RFA', 'SMS', 'TCG', 'USS' } local t4 = { 'CCGS', 'CFAV', 'HDMS', 'HMAS', 'HMCS', 'HMVS', 'HMQS', 'HTMS', 'RMAS', 'USAS', 'USNS', 'USRC', 'RNLB', 'HMBS' } local t5 = { 'HNLMS', 'HMNZS', 'HSwMS', 'USAFS', 'USCGC' } local t6 = {} for k,v in ipairs(t1) do table.insert(prefix_list, v) end for k,v in ipairs(t2) do table.insert(prefix_list, v) end for k,v in ipairs(t3) do table.insert(prefix_list, v) end for k,v in ipairs(t4) do table.insert(prefix_list, v) end for k,v in ipairs(t5) do table.insert(prefix_list, v) end for k,v in ipairs(t6) do table.insert(prefix_list, v) end local prefix_len = 0 local shipname = "" shipname = frame.args[1] or "--" if shipname == nil then prefix_len = 0 elseif shipname == "--" then prefix_len = 0 -- if shipname = "" prefix_len already set to 0 else shipname = (shipname:gsub("(%s.*)","")) for i,v in pairs(prefix_list) do if shipname == v then prefix_len = string.len(v) break end -- END IF end -- END FOR end -- END IF return prefix_len end -- END FUNCTION prefix return p
Summary:
Please note that all contributions to Stockhub may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Template used on this page:
Module:Sandbox/Matroc/Ship prefix/doc
(
edit
)