|
|
(220 intermediate revisions by 2 users not shown) |
Line 1: |
Line 1: |
| local p = {}; | | local p = require("Module:Move") |
| local cargo = mw.ext.cargo
| | p.game = require("Module:Game").Tekken7 |
| 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 then
| |
| return frame:expandTemplate{ title = 'MoveData', args = frame:getParent().args }
| |
| else
| |
| local args = mw.clone(frame:getParent().args)
| |
|
| |
| local parent = cargo.query(tables, 'input,target,damage,parent', { where = "id='" .. parent .. "'" })[1]
| |
| if parent == nil then
| |
| return 'Error: parent = "' .. parentId .. '" not found'
| |
| end
| |
|
| |
| for k, v in pairs(parent) 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 | | return p |