User:Bongolium500/Lua tests: Difference between revisions

From Tardis Wiki, the free Doctor Who reference
(Created page with "All modules invoked here will be subpages of Module:Bongolium500. {{#invoke:Bongolium500/learning|hello}} {{#invoke:Bongolium500/story cite|getinfo}}")
 
No edit summary
Line 4: Line 4:


{{#invoke:Bongolium500/story cite|getinfo}}
{{#invoke:Bongolium500/story cite|getinfo}}
<pre>
for n = 1, #queryResult do
    local current = queryResult[n]
    local output = ""
    local data = {["partOf"] = "", ["series"] = "", ["seriesNumber"] = "", ["season"] = "", ["Writer"] = "", ["publisher"] = ""}
    for i=1, #properties do
    if current["Writer"] ~= nil and type(current["Writer"]) ~= "table" then --]]
    data[properties[i]] = data[properties[i]] .. current["Writer"]
    elseif type(current["Writer"]) == "table" then
    for i = 1, #current["Writer"] do
    data[properties[i]] = data[properties[i]] .. current["Writer"][i]
    if i == #current["Writer"]-1 then
    data[properties[i]] = data[properties[i]] .. " and "
    elseif i == #current["Writer"] then
    data[properties[i]] = data[properties[i]]
    else
    data[properties[i]] = data[properties[i]] .. ", "
    end
    end
    end
    end
    output = output .. data["Writer"]
    util_vars.vardefine(current[1], output)
    end
    testtext = util_vars.var("Rose (TV story)")
    return testtext
end
end</pre>

Revision as of 18:05, 15 November 2021

All modules invoked here will be subpages of Module:Bongolium500.

Script error: The function "hello" does not exist.

Script error: No such module "Bongolium500/story cite".

for n = 1, #queryResult do
	    	local current = queryResult[n]
	    	local output = ""
	    	local data = {["partOf"] = "", ["series"] = "", ["seriesNumber"] = "", ["season"] = "", ["Writer"] = "", ["publisher"] = ""}
	    	for i=1, #properties do
		    	if current["Writer"] ~= nil and type(current["Writer"]) ~= "table" then --]]
		    		data[properties[i]] = data[properties[i]] .. current["Writer"]
		    	elseif type(current["Writer"]) == "table" then
		    		for i = 1, #current["Writer"] do
		    			data[properties[i]] = data[properties[i]] .. current["Writer"][i]
		    			if i == #current["Writer"]-1 then
		    				data[properties[i]] = data[properties[i]] .. " and "
		    			elseif i == #current["Writer"] then
		    				data[properties[i]] = data[properties[i]]
		    			else
		    				data[properties[i]] = data[properties[i]] .. ", "
		    			end
		    		end
		    	end
	    	end
	    	output = output .. data["Writer"]
	    	util_vars.vardefine(current[1], output)
	    end
	    testtext = util_vars.var("Rose (TV story)")
	    return testtext
	end
end