Editing Module:EcopediaString

From Eco - English Wiki

Your changes will be displayed to readers once an authorized user accepts them. (help)

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:
-- Module:GetEcopedia (https://wiki.play.eco/en/Module:GetEcopedia)
local p = {}
local p = {}


function p.main(param)
-- Grabs args from the parent frame
local Utils = require('Module:Utils')
-- Trims and parses the args into a table, then returns the table
local args = Utils.normaliseArgs(param)
function norm()
local String = ""
    local origArgs = mw.getCurrentFrame():getParent().args
     local EcopediaList = mw.loadData("Module:EcopediaData")
    local args = {}
    local String = EcopediaList[args.num]
   
    for k, v in pairs( origArgs ) do
        v = mw.text.trim( tostring( v ) )
        if v ~= '' then
            args[k] = v
        end
    end
   
    return args
end
 
-- Main entry point for the Module
function p.main()
-- get args from the Template
    local args = norm()
   
    -- assign variables for page
    local page = args.page
 
    -- load list of pages
    local completeList = require( "Module:Ecopedia" )
    local pageList = completeList.ecopedia 
-- sectionTypes constants
local bodySec = "EcopediaSection"
local headerSec = "EcopediaHeader"
-- create text to be returned"
local text = ""
     -- make sure page is not nil
    if page ~= nil then
-- make sure page exists in ecopedia
local p = pageList[page]
if p ~= nil then
-- main heading
text = text .. "\'\'\'" .. p.displayName .. "\'\'\'\n\n"
-- loop through sections (i = array position, j= {sectionType, text} )
for i=1, #p.sectionsText do
-- create a local of the current section
local sec = p.sectionsText[i]
if (sec[1] == bodySec) then
text = text .. sec[2] .. "\n\n"
end -- if bodySec
if (sec[1] == headerSec) then
text = text .. "\'\'\'" .. sec[2] .. "\'\'\'\n\n"
end -- if headerSec
end -- sections for loop
end -- if exists in Ecopedia
else
text = "PAGE " .. page .. " NOT FOUND"
    end -- if page not nil
return String
return text
end
end


return p
return p
Please note that all contributions to Eco - English Wiki are considered to be released under the CC BY-NC-SA 4.0 (see Eco: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!

To protect the wiki against automated edit spam, please solve the following captcha:

Cancel Editing help (opens in new window)

Template used on this page: