Module

WorldSwitch

From Dogcraft Wiki

No edit summary
m (Removing unused commented out functions (its still in the history if needed))
 
(7 intermediate revisions by the same user not shown)
Line 1: Line 1:
local p = {} --p stands for package
local p = {} --p stands for package
local worldTools = require('Module:World')


-- get the parent world for a specific subworld
function p.parentWorld(frame)
input = mw.ustring.lower(frame.args[1] .. frame.args[2])
return worldTools.getParentWorld(input)
end
-- get the subworld
-- (usually would expect a world + subworld combo as the first two #invoke args, but works with any setup as long as either the first or the second arg has a string)
-- returns an empty string when it doesn't find anything
function p.subworld(frame)
function p.subworld(frame)
input = mw.ustring.lower(frame.args[1] .. frame.args[2])
input = mw.ustring.lower(frame.args[1] .. frame.args[2])
subworlds = {"husky", "beagle", "akita", "corgi", "labrador", "shepherd"}
return worldTools.extractSubworld(input)
for key,value in ipairs(subworlds) do
if (mw.ustring.find(input, value, 1, true) ~= nil) then
return value
end
end
return 'not found'
end
end


-- get the world
-- (usually would expect a world + subworld combo as the first two #invoke args, but works with any setup as long as either the first or the second arg has a string)
-- returns an empty string when it doesn't find anything
function p.world(frame)
function p.world(frame)
input = mw.ustring.lower(frame.args[1] .. frame.args[2])
input = mw.ustring.lower(frame.args[1] .. frame.args[2])
worlds = {"survival 1", "survival 2", "survival 3", "survival 4", "survival 5", "creative", "patreon", "amplified", "mcmmo", "skyblock"}
return worldTools.extractWorld(input)
for key,value in ipairs(worlds) do
if (mw.ustring.find(input, value, 1, true) ~= nil) then
return value
end
end
if (mw.ustring.find(input, 'survival', 1, true) ~= nil) then
return 'survival'
end
return 'not found'
end
end


return p
return p

Latest revision as of 01:06, 29 December 2023

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

{{#invoke:WorldSwitch|world|Survial 4|Husky}} generates: survival 4


local p = {} --p stands for package
local worldTools = require('Module:World')


-- get the parent world for a specific subworld
function p.parentWorld(frame)
	input = mw.ustring.lower(frame.args[1] .. frame.args[2])
	return worldTools.getParentWorld(input)
end
	
	
-- get the subworld 
-- (usually would expect a world + subworld combo as the first two #invoke args, but works with any setup as long as either the first or the second arg has a string)
-- returns an empty string when it doesn't find anything
function p.subworld(frame)
	input = mw.ustring.lower(frame.args[1] .. frame.args[2])
	return worldTools.extractSubworld(input)
end


-- get the world 
-- (usually would expect a world + subworld combo as the first two #invoke args, but works with any setup as long as either the first or the second arg has a string)
-- returns an empty string when it doesn't find anything
function p.world(frame)
	input = mw.ustring.lower(frame.args[1] .. frame.args[2])
	return worldTools.extractWorld(input)
end

return p