Module

WorldSwitch

From Dogcraft Wiki

No edit summary
No edit summary
Line 2: Line 2:


function p.subworld(frame)
function p.subworld(frame)
input = mw.ustring.lower(frame[1] .. frame[2])
input = mw.ustring.lower(frame.args[1] .. frame.args[2])
subworlds = {"husky", "beagle", "akita", "corgi", "labrador", "shepherd"}
subworlds = {"husky", "beagle", "akita", "corgi", "labrador", "shepherd"}
for key,value in ipairs(subworlds) do  
for key,value in ipairs(subworlds) do  

Revision as of 22:43, 22 May 2022

{{#invoke:WorldSwitch|subworld|Survial 4|Husky}} generates: husky

{{#invoke:WorldSwitch|world|Survial 4|Husky}} generates: Script error: The function "world" does not exist.


local p = {} --p stands for package

function p.subworld(frame)
	input = mw.ustring.lower(frame.args[1] .. frame.args[2])
	subworlds = {"husky", "beagle", "akita", "corgi", "labrador", "shepherd"}
	for key,value in ipairs(subworlds) do 
		if (mw.ustring.find(input, value, 1, true) ~= nil) then
			return value
		end
	end
end

return p
This page was last modified on 22 May 2022, at 22:43. (3 months ago)