Module:Move7: Difference between revisions

From Wavu Wiki, the 🌊 wavy Tekken wiki
No edit summary
No edit summary
Line 10: Line 10:
return frame:expandTemplate{ title = 'MoveData', args = frame:getParent().args }
return frame:expandTemplate{ title = 'MoveData', args = frame:getParent().args }
else
else
local parent = cargo.query(tables, 'input,target,damage,parent', { where = "id='" .. parentId .. "'" })[1]
local leads = {}
if parent == nil then
while (true) do
return 'Error: parent = "' .. parentId .. '" not found'
local parent = cargo.query(tables, 'input,target,damage,parent', { where = "id='" .. parentId .. "'" })[1]
if parent == nil then
return 'Error: parent = "' .. parentId .. '" not found'
end
 
for k, v in pairs(parent) do
if k ~= 'parent' then
if leads[k .. 'Lead'] == nil then
leads[k .. 'Lead'] = v
else
leads[k .. 'Lead'] = v .. leads[k .. 'Lead']
end
end
end
if parent['parent'] == "" then
break
end
end
end
Line 19: Line 36:
args[k] = v
args[k] = v
end
end
for k, v in pairs(parent) do
for k, v in pairs(leads) do
if k ~= 'parent' then
args[k] = v
args[k .. 'Lead'] = v
end
end
end

Revision as of 13:35, 22 August 2023

Documentation for this module may be created at Module:Move7/doc

local p = {};
local cargo = mw.ext.cargo
local tables = 'MoveDataCargoTest'

p.fields = 'id,name,input,target,damage,reach,tracksLeft,tracksRight,startup,recv,tot,crush,block,hit,ch,notes'

p.display = function(frame)
	local parentId = frame:getParent().args['parent']
	if parentId == nil or parentId == "" then
		return frame:expandTemplate{ title = 'MoveData', args = frame:getParent().args }
	else
		local leads = {}
		while (true) do
			local parent = cargo.query(tables, 'input,target,damage,parent', { where = "id='" .. parentId .. "'" })[1]
			if parent == nil then
				return 'Error: parent = "' .. parentId .. '" not found'
			end

			for k, v in pairs(parent) do
				if k ~= 'parent' then
					if leads[k .. 'Lead'] == nil then
						leads[k .. 'Lead'] = v
					else
						leads[k .. 'Lead'] = v .. leads[k .. 'Lead']
					end
				end
			end
			
			if parent['parent'] == "" then
				break
			end
		end
		
		local args = {}
		for k, v in pairs(frame:getParent().args) do
			args[k] = v
		end
		for k, v in pairs(leads) do
			args[k] = v
		end
		
		return frame:expandTemplate{ title = 'MoveData', args = args }
	end
end

p.queryOverride = function(frame)
	local args = frame:getParent().args
	local id = args[1]
	if id == nil then
		return "Error: no id"
	end
	id = id:gsub("%s+", "")
	
	local result = cargo.query(tables, p.fields, { where = "id = '" .. id .. "'" })[1]
	if result == nil then
		return "Error: move with id = '" .. id .. "' not found"
	end
	
	for k, v in pairs(result) do
		local override = args[k]
		if override ~= nil then
			result[k] = override
		end
	end
	
	return frame:expandTemplate{ title = 'MoveDataCargoTest/Display', args = result }
end

return p