Difference between revisions of "Module:UnitData"
(First draft) |
m (Handle nil properties) |
||
Line 9: | Line 9: | ||
local property = frame.args[2] | local property = frame.args[2] | ||
local result = unitData[unitDefName][property] | local result = unitData[unitDefName][property] | ||
+ | if not result then result = '' end | ||
return frame:preprocess(result) or '' | return frame:preprocess(result) or '' | ||
end | end | ||
return unit | return unit |
Revision as of 21:37, 10 May 2024
This module is used to autogenerate unit infoboxes by drawing data from Module:UnitData/data. The intent is to ease updating of unit infoboxes on the wiki; ideally, only the one data page needing to be changed every release. The concept is taken from e.g. the Combat Card Data module on the Library of Ruina Wiki.
This module is currently used with Template:Autoinfobox zkunit as follows:
{{Autoinfobox zkunit |defname=striderdetriment |name=Name override }}
The module can also be invoked directly to generate an infobox (note that output may not be identical in some cases; observed with automatic detection of buildpic on Reef):
{{#invoke:UnitData|printInfobox|defname=striderdetriment|name=Name override}}
When invoking from module, defname
may be passed as an anonymous parameter instead.
See also Module:WeaponData, which is used to generate the weapon infoboxes within the unit infoboxes.
Data page
Module:UnitData/data is a central store of data used by Module:UnitData to automatically populate unit infoboxes.
The page is a Lua table written to the local file temp/unitStats.lua
by the Wiki Data Export (dbg_wiki_export.lua
) widget in Zero-K. This widget should be run once each update and the data page on the wiki replaced accordingly. It should not be necessary to edit the data manually.
local getArgs = require('Module:Arguments').getArgs local unit = {} local unitData = mw.loadData('Module:UnitData/data') function unit.getData(frame) if not frame then return '' end local unitDefName = frame.args[1] if not (unitData[unitDefName]) then return 'unitdef ' .. unitDefName .. ' not found' end local property = frame.args[2] local result = unitData[unitDefName][property] if not result then result = '' end return frame:preprocess(result) or '' end return unit
Debug data:
[SQLBagOStuff] MainObjectStash using store ReplicatedBagOStuff
[objectcache] MainWANObjectCache using store EmptyBagOStuff
IP: 216.73.216.43
Start request GET /mediawiki/index.php?diff=next&oldid=9247&title=Module%3AUnitData
HTTP HEADERS:
CONTENT-TYPE:
CONTENT-LENGTH: 0
X-FORWARDED-FOR: 10.3.190.125
USER-AGENT: Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
HOST: zero-k.info
ACCEPT-ENCODING: gzip, br, zstd, deflate
ACCEPT: */*
VIA: 1.1 squid-proxy-5b5d847c96-qkq5m (squid/6.10)
CONNECTION: keep-alive
CACHE-CONTROL: max-age=0[localisation] LocalisationCache: using store LCStoreDB
[session] SessionManager using store SqlBagOStuff
[DBReplication] Cannot use ChronologyProtector with EmptyBagOStuff
[DBReplication] Wikimedia\Rdbms\LBFactory::getChronologyProtector: request info {
"IPAddress": "216.73.216.43",
"UserAgent": "Mozilla\/5.0 AppleWebKit\/537.36 (KHTML, like Gecko; compatible; ClaudeBot\/1.0; +claudebot@anthropic.com)",
"ChronologyProtection": false,
"ChronologyPositionIndex": 0,
"ChronologyClientId": false
}[DBConnection] Wikimedia\Rdbms\LoadBalancer::lazyLoadReplicationPositions: executed chronology callback.
[DBConnection] Wikimedia\Rdbms\LoadBalancer::getLocalConnection: connected to database 0 at 'localhost'.
[SQLBagOStuff] Connection mysql object #125 (handle id #119) will be used for SqlBagOStuff
[session] SessionBackend "i27ut7a9c2b960a64tufm8edu6upuugj" is unsaved, marking dirty in constructor
[session] SessionBackend "i27ut7a9c2b960a64tufm8edu6upuugj" save: dataDirty=1 metaDirty=1 forcePersist=0
[cookie] already deleted setcookie: "wikidb229_mw__session", "", "1724089066", "/", "", "", "1"
[cookie] already deleted setcookie: "wikidb229_mw_UserID", "", "1724089066", "/", "", "", "1"
[cookie] already deleted setcookie: "wikidb229_mw_Token", "", "1724089066", "/", "", "", "1"
[cookie] already deleted setcookie: "forceHTTPS", "", "1724089066", "/", "", "", "1"
[DBConnection] Wikimedia\Rdbms\LoadBalancer::getLocalConnection: connected to database 0 at 'localhost'.
[localisation] LocalisationCache::isExpired(en): cache for en expired due to GlobalDependency
[localisation] LocalisationCache::recache: got localisation for en from source
[DBQuery] startAtomic: entering level 0 (LCStoreDB::finishWrite)
[DBQuery] endAtomic: leaving level 0 (LCStoreDB::finishWrite)
Title::getRestrictionTypes: applicable restrictions to [[Module:UnitData]] are {edit,move}
[objectcache] Rejected set() for global:revision-row-1.29:wikidb229-mw_:1683:9855 due to pending writes.
[objectcache] Rejected set() for global:NameTableSqlStore:slot_roles:wikidb229-mw_ due to pending writes.
[objectcache] Rejected set() for global:NameTableSqlStore:content_models:wikidb229-mw_ due to pending writes.
[ContentHandler] Created handler for Scribunto: ScribuntoContentHandler
Article::view: showing diff page
DifferenceEngine old '9247' new 'next' rcid ''
[MessageCache] MessageCache using store SqlBagOStuff
[SQLBagOStuff] Connection mysql object #125 (handle id #119) will be used for SqlBagOStuff
[SQLBagOStuff] Connection mysql object #125 (handle id #119) will be used for SqlBagOStuff
[SQLBagOStuff] Connection mysql object #125 (handle id #119) will be used for SqlBagOStuff
[SQLBagOStuff] Connection mysql object #125 (handle id #119) will be used for SqlBagOStuff
[SQLBagOStuff] SqlBagOStuff::lock failed due to timeout for wikidb229-mw_:messages:en.
[ContentHandler] Created handler for wikitext: WikitextContentHandler
[SQLBagOStuff] Connection mysql object #125 (handle id #119) will be used for SqlBagOStuff
[SQLBagOStuff] Connection mysql object #125 (handle id #119) will be used for SqlBagOStuff
[MessageCache] MessageCache::load: Loading en... local cache is empty, global cache is expired/volatile, loading from database
ParserFactory: using preprocessor: Preprocessor_Hash
Unstubbing $wgLang on call of $wgLang::_unstub from ParserOptions->__construct
DifferenceEngine old '0' new '0' rcid '0'
WikiPage::getParserOutput: using parser cache: no
[caches] parser: SqlBagOStuff
[SQLBagOStuff] Connection mysql object #125 (handle id #119) will be used for SqlBagOStuff
[objectcache] Rejected set() for wikidb229-mw_:page:828:2f56c68abf1fb98eafd761d5b74f6e4d1e29aefb due to pending writes.
Unstubbing $wgParser on call of $wgParser::parse from AbstractContent->getParserOutput
[objectcache] Rejected set() for global:revision-row-1.29:wikidb229-mw_:1690:9336 due to pending writes.
[Preprocessor] Cached preprocessor output (key: wikidb229-mw_:preprocess-hash:e517d01e2ae643bc2d167084f290cd4b:1)
[objectcache] Rejected set() for wikidb229-mw_:page:828:9baf32adde9c6d5d0b09562819322a26c9336249 due to pending writes.
[objectcache] Rejected set() for global:revision-row-1.29:wikidb229-mw_:1689:9304 due to pending writes.
[Scribunto] Scribunto_LuaStandaloneInterpreter::__construct: creating interpreter: ""C:\Projekty\zero-k.info\www\mediawiki\extensions\Scribunto\includes\engines\LuaStandalone/binaries/lua5_1_5_Win64_bin/lua5.1.exe" "C:\Projekty\zero-k.info\www\mediawiki\extensions\Scribunto\includes\engines\LuaStandalone/mw_main.lua" "C:\Projekty\zero-k.info\www\mediawiki\extensions\Scribunto\includes" "0" "8""
[gitinfo] Candidate cacheFile=C:\Projekty\zero-k.info\www\mediawiki/gitinfo.json for C:\Projekty\zero-k.info\www\mediawiki
[gitinfo] Cache incomplete for C:\Projekty\zero-k.info\www\mediawiki
SiteStats::loadAndLazyInit: reading site_stats from replica DB
[objectcache] Rejected set() for wikidb229-mw_:SiteStats:groupcounts:sysop due to pending writes.
[DBPerformance] Sub-optimal transaction on DB(s) [localhost (wikidb229-mw_) (TRX#856551)]:
0 3.418240 query-m: DELETE FROM `mw_l10n_cache` WHERE lc_lang = 'X' [TRX#856551]
1 0.004604 query-m: INSERT INTO `mw_l10n_cache` (lc_lang,lc_key,lc_value) VALUES ('X') [TRX#856551]
2 0.003292 query-m: INSERT INTO `mw_l10n_cache` (lc_lang,lc_key,lc_value) VALUES ('X') [TRX#856551]
3 0.002866 query-m: INSERT INTO `mw_l10n_cache` (lc_lang,lc_key,lc_value) VALUES ('X') [TRX#856551]
4 0.002767 query-m: INSERT INTO `mw_l10n_cache` (lc_lang,lc_key,lc_value) VALUES ('X') [TRX#856551]
5 0.003149 query-m: INSERT INTO `mw_l10n_cache` (lc_lang,lc_key,lc_value) VALUES ('X') [TRX#856551]
6 0.002993 query-m: INSERT INTO `mw_l10n_cache` (lc_lang,lc_key,lc_value) VALUES ('X') [TRX#856551]
7 0.002714 query-m: INSERT INTO `mw_l10n_cache` (lc_lang,lc_key,lc_value) VALUES ('X') [TRX#856551]
8 0.003563 query-m: INSERT INTO `mw_l10n_cache` (lc_lang,lc_key,lc_value) VALUES ('X') [TRX#856551]
9 0.002678 query-m: INSERT INTO `mw_l10n_cache` (lc_lang,lc_key,lc_value) VALUES ('X') [TRX#856551]
10 0.002943 query-m: INSERT INTO `mw_l10n_cache` (lc_lang,lc_key,lc_value) VALUES ('X') [TRX#856551]
11 0.002929 query-m: INSERT INTO `mw_l10n_cache` (lc_lang,lc_key,lc_value) VALUES ('X') [TRX#856551]
12 0.002912 query-m: INSERT INTO `mw_l10n_cache` (lc_lang,lc_key,lc_value) VALUES ('X') [TRX#856551]
13 0.002846 query-m: INSERT INTO `mw_l10n_cache` (lc_lang,lc_key,lc_value) VALUES ('X') [TRX#856551]
14 0.003080 query-m: INSERT INTO `mw_l10n_cache` (lc_lang,lc_key,lc_value) VALUES ('X') [TRX#856551]
15 0.002874 query-m: INSERT INTO `mw_l10n_cache` (lc_lang,lc_key,lc_value) VALUES ('X') [TRX#856551]
16 0.004353 query-m: INSERT INTO `mw_l10n_cache` (lc_lang,lc_key,lc_value) VALUES ('X') [TRX#856551]
17 0.001559 query-m: REPLACE INTO `mw_objectcache` (keyname,value,exptime) VALUES ('X')MediaWiki::preOutputCommit: primary transaction round committed
MediaWiki::preOutputCommit: pre-send deferred updates completed
MediaWiki::preOutputCommit: session changes committed
MediaWiki::preOutputCommit: LBFactory shutdown completed
Title::getRestrictionTypes: applicable restrictions to [[Module:UnitData]] are {edit,move}