Modding:Mod compatibility/barchart: Difference between revisions
Appearance
imported>Pathoschild m update script for 'optional' status |
imported>Peaw mNo edit summary |
||
| (10 intermediate revisions by 3 users not shown) | |||
| Line 10: | Line 10: | ||
| {{#expr:({{{broken|0}}} / {{{total|<noinclude>1</noinclude>0}}}) * 100 round 0}}% are broken and not open-source.¹ | | {{#expr:({{{broken|0}}} / {{{total|<noinclude>1</noinclude>0}}}) * 100 round 0}}% are broken and not open-source.¹ | ||
|} | |} | ||
<small>¹ Many of these broke | <small>¹ Many of these broke due to a Stardew Valley update. Some may be updated by their authors later.</small><noinclude> | ||
==Usage== | ==Usage== | ||
| Line 25: | Line 25: | ||
==Script== | ==Script== | ||
This | This script generates the template call when run from the parent page. | ||
< | <syntaxhighlight lang="javascript"> | ||
(function() { | |||
// group mods by status | |||
let counts = { ok: 0, workaround: 0, soon: 0, broken: 0, total: 0 }; | |||
let invalidMods = []; | |||
$("#mod-list .mod").each(function(i, entry) { | |||
entry = $(entry); | |||
let status = entry.attr("data-beta-status") || entry.attr("data-status"); | |||
let hasSource = entry.is("[data-github], [data-custom-source]"); | |||
switch(status) { | |||
// ignore obsolete mods | |||
case "abandoned": | |||
case "obsolete": | |||
break; | |||
// compatible | |||
case "ok": | |||
case "optional": | |||
counts.ok++; | |||
counts.total++; | |||
break; | |||
` | // workaround | ||
{{/barchart | case "workaround": | ||
case "unofficial": | |||
counts.workaround++; | |||
counts.total++; | |||
break; | |||
}} | // soon/broken | ||
` | case "broken": | ||
</ | if (hasSource) | ||
counts.soon++; | |||
else | |||
counts.broken++; | |||
counts.total++; | |||
break; | |||
default: | |||
invalidMods.push(mods); | |||
break; | |||
} | |||
}); | |||
// show results | |||
if (invalidMods.length) { | |||
console.log("found entries with unknown status:", invalidMods); | |||
throw 'script failed'; | |||
} | |||
console.log(` | |||
{{/barchart | |||
|ok = ${counts.ok} | |||
|workaround = ${counts.workaround} | |||
|soon = ${counts.soon} | |||
|broken = ${counts.broken} | |||
|total = ${counts.total} | |||
}} | |||
`.replace(/^ /mg, '')); | |||
})(); | |||
</syntaxhighlight> | |||
[[Category:Modding]]</noinclude> | [[Category:Modding]] | ||
[[de:Modding:SMAPI Kompatibilität/barchart]] | |||
[[tr:Modlama:Mod Uyumluluğu/barchart]] | |||
</noinclude> | |||
Latest revision as of 12:29, 12 July 2024
| 0% are compatible or have a working alternative. | |
| 0% have an update coming soon. | |
| 0% are broken and not open-source.¹ |
¹ Many of these broke due to a Stardew Valley update. Some may be updated by their authors later.
Usage
List the counts for each group:
{{/barchart
|ok = 135
|workaround = 33
|soon = 56
|broken = 33
|total = 257
}}
Script
This script generates the template call when run from the parent page.
(function() {
// group mods by status
let counts = { ok: 0, workaround: 0, soon: 0, broken: 0, total: 0 };
let invalidMods = [];
$("#mod-list .mod").each(function(i, entry) {
entry = $(entry);
let status = entry.attr("data-beta-status") || entry.attr("data-status");
let hasSource = entry.is("[data-github], [data-custom-source]");
switch(status) {
// ignore obsolete mods
case "abandoned":
case "obsolete":
break;
// compatible
case "ok":
case "optional":
counts.ok++;
counts.total++;
break;
// workaround
case "workaround":
case "unofficial":
counts.workaround++;
counts.total++;
break;
// soon/broken
case "broken":
if (hasSource)
counts.soon++;
else
counts.broken++;
counts.total++;
break;
default:
invalidMods.push(mods);
break;
}
});
// show results
if (invalidMods.length) {
console.log("found entries with unknown status:", invalidMods);
throw 'script failed';
}
console.log(`
{{/barchart
|ok = ${counts.ok}
|workaround = ${counts.workaround}
|soon = ${counts.soon}
|broken = ${counts.broken}
|total = ${counts.total}
}}
`.replace(/^ /mg, ''));
})();