Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Editing Module:AeroWikiListTools

From Aeronautica Official Wiki
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.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
Line 1: Line 1:
-- Created by @Sqwishyish on discord
-- Contact me for any issues
local getArgs = require('Module:Arguments').getArgs
local getArgs = require('Module:Arguments').getArgs


Line 15: Line 12:
p.split_list = makeInvokeFunc('_split_list')
p.split_list = makeInvokeFunc('_split_list')
p._split_list = function (args)
p._split_list = function (args)
-- Get arguments passed from function call
local input_string = args[1]
local input_string = args[1] -- List string to modify
local template = args[2]
local template = args[2] -- String to put at each {split}
local missing_string = args[3] -- String to return when either the template or the input is nil
     local new_string = ''
     local new_string = ''
      
      
    -- Check if input string exists
     if input_string == nil or template == nil then
     if input_string == nil or template == nil then
return missing_string
return 'Unknown/None'
     end
     end
   
 
    -- Check if input string is not 'None'
    if input_string == 'None' then
return 'None'
    end
-- Split string by commas and append the template at each {split} point
     for split in string.gmatch(input_string , '([^,]+)') do
     for split in string.gmatch(input_string , '([^,]+)') do
         new_string = new_string .. template:gsub('{split}', split:match('^%s*(.-)%s*$')) .. ' '
         new_string = new_string .. template:gsub('{split}', split:match('^%s*(.-)%s*$')) .. ' '
     end
     end
      
      
    -- Remove comma on end of list
     if template:sub(-1) == ',' then
     if template:sub(-1) == ',' then
     new_string = new_string:sub(1, -3)
     new_string = new_string:sub(1, -3)
Line 43: Line 30:
     end
     end
      
      
    -- Return the new string to the list
     return new_string
     return new_string
end
end
return p
return p
Please note that all contributions to Aeronautica Official Wiki are considered to be released under the Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) (see Aeronautica Official Wiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, 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. Do not submit copyrighted work without permission!
Cancel Editing help (opens in new window)

Template used on this page:

Cookies help us deliver our services. By using our services, you agree to our use of cookies.