Module

WorldSwitch

From Dogcraft Wiki

m (added streamtown)
(Switching to using Module:World (basically only leaving input handling in this module))
Line 1: Line 1:
local p = {} --p stands for package
local p = {} --p stands for package
local worldTools = require('Module:World')


-- HELPERS
-- HELPERS
Line 36: Line 37:
function p.parentWorld(frame)
function p.parentWorld(frame)
input = mw.ustring.lower(frame.args[1] .. frame.args[2])
input = mw.ustring.lower(frame.args[1] .. frame.args[2])
subworld = subworld(input)
return worldTools.getParentWorld(input)
subworlds = {}
-- subworld = subworld(input)
subworlds["survival 4"] = {"husky", "beagle"}
-- subworlds = {}
subworlds["survival 5"] = {"akita", "corgi", "labrador", "shepherd"}
-- subworlds["survival 4"] = {"husky", "beagle"}
subworlds["survival 6"] = {"sheltie", "retriever", "streamtown"}
-- subworlds["survival 5"] = {"akita", "corgi", "labrador", "shepherd"}
for key,value in ipairs(subworlds["survival 4"]) do
-- subworlds["survival 6"] = {"sheltie", "retriever", "streamtown"}
if (mw.ustring.find(subworld, value, 1, true) ~= nil) then
-- for key,value in ipairs(subworlds["survival 4"]) do
return "survival 4"
-- if (mw.ustring.find(subworld, value, 1, true) ~= nil) then
end
-- return "survival 4"
end
-- end
for key,value in ipairs(subworlds["survival 5"]) do
-- end
if (mw.ustring.find(subworld, value, 1, true) ~= nil) then
-- for key,value in ipairs(subworlds["survival 5"]) do
return "survival 5"
-- if (mw.ustring.find(subworld, value, 1, true) ~= nil) then
end
-- return "survival 5"
end
-- end
for key,value in ipairs(subworlds["survival 6"]) do
-- end
if (mw.ustring.find(subworld, value, 1, true) ~= nil) then
-- for key,value in ipairs(subworlds["survival 6"]) do
return "survival 6"
-- if (mw.ustring.find(subworld, value, 1, true) ~= nil) then
end
-- return "survival 6"
end
-- end
-- end
end
end
Line 62: Line 64:
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", "sheltie", "retriever", "streamtown"}
return worldTools.extractSubworld(input)
for key,value in ipairs(subworlds) do  
-- subworlds = {"husky", "beagle", "akita", "corgi", "labrador", "shepherd", "sheltie", "retriever", "streamtown"}
if (mw.ustring.find(input, value, 1, true) ~= nil) then
-- for key,value in ipairs(subworlds) do  
return value
-- if (mw.ustring.find(input, value, 1, true) ~= nil) then
end
-- return value
end
-- end
return ''--return 'not found'
-- end
-- return ''--return 'not found'
end
end


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", "survival 6", "creative", "patreon", "hub", "amplified", "MCMMO", "skyblock"}
return worldTools.extractWorld(input)
for key,value in ipairs(worlds) do  
-- worlds = {"survival 1", "survival 2", "survival 3", "survival 4", "survival 5", "survival 6", "creative", "patreon", "hub", "amplified", "MCMMO", "skyblock"}
if (mw.ustring.find(input, value, 1, true) ~= nil) then
-- for key,value in ipairs(worlds) do  
return value
-- if (mw.ustring.find(input, value, 1, true) ~= nil) then
end
-- return value
end
-- end
if (mw.ustring.find(input, 'survival', 1, true) ~= nil) then
-- end
return 'survival 1'
-- if (mw.ustring.find(input, 'survival', 1, true) ~= nil) then
end
-- return 'survival 1'
return ''--return 'not found'
-- end
-- return ''--return 'not found'
end
end


return p
return p

Revision as of 00:48, 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')

-- HELPERS

-- get world from a string
function world(input)
	input = mw.ustring.lower(input)
	worlds = {"survival 1", "survival 2", "survival 3", "survival 4", "survival 5", "survival 6", "creative", "patreon", "hub", "amplified", "MCMMO", "skyblock"}
	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 1'
	end
	return ''--return 'not found'
end
	

-- get the subworld from a string
function subworld(input)
	input = mw.ustring.lower(input)
	subworlds = {"husky", "beagle", "akita", "corgi", "labrador", "shepherd", "sheltie", "retriever", "streamtown"}
	for key,value in ipairs(subworlds) do 
		if (mw.ustring.find(input, value, 1, true) ~= nil) then
			return value
		end
	end
	return ''--return 'not found'
end


-- MODES

function p.parentWorld(frame)
	input = mw.ustring.lower(frame.args[1] .. frame.args[2])
	return worldTools.getParentWorld(input)
	-- subworld = subworld(input)
	-- subworlds = {}
	-- subworlds["survival 4"] = {"husky", "beagle"}
	-- subworlds["survival 5"] = {"akita", "corgi", "labrador", "shepherd"}
	-- subworlds["survival 6"] = {"sheltie", "retriever", "streamtown"}
	-- for key,value in ipairs(subworlds["survival 4"]) do
	-- 	if (mw.ustring.find(subworld, value, 1, true) ~= nil) then
	-- 		return "survival 4"
	-- 	end
	-- end
	-- for key,value in ipairs(subworlds["survival 5"]) do
	-- 	if (mw.ustring.find(subworld, value, 1, true) ~= nil) then
	-- 		return "survival 5"
	-- 	end
	-- end
	-- for key,value in ipairs(subworlds["survival 6"]) do
	-- 	if (mw.ustring.find(subworld, value, 1, true) ~= nil) then
	-- 		return "survival 6"
	-- 	end
	-- end
end
	
	

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

function p.world(frame)
	input = mw.ustring.lower(frame.args[1] .. frame.args[2])
	return worldTools.extractWorld(input)
	-- worlds = {"survival 1", "survival 2", "survival 3", "survival 4", "survival 5", "survival 6", "creative", "patreon", "hub", "amplified", "MCMMO", "skyblock"}
	-- 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 1'
	-- end
	-- return ''--return 'not found'
end

return p
This page was last modified on 29 December 2023, at 00:48. (3 months ago)
Background SRN Opening by Montenator