• We have updated our Community Code of Conduct. Please read through the new rules for the forum that are an integral part of Paradox Interactive’s User Agreement.
They look interesting. Does anybody know if templates like these exist in the other wikis? At least eu4 uses lua defines and I think some of the newer games use .txt files which have syntax which could possibly be converted to lua.

Is there a reason why read_define doesn't add a footnote with a reference to the define?
I had that as an idea when creating it, but had issues while implementing, regarding it appearing as regular text instead of a reference and ignoring the conditional. I could replicate them just now, but just testing more somehow made the problem disappear and I can't get it to break again. Could add that in as an extra argument, but I need auto-patrol on this account to be able to edit the template space since I created the template before moving accounts.
 
I had that as an idea when creating it, but had issues while implementing, regarding it appearing as regular text instead of a reference and ignoring the conditional. I could replicate them just now, but just testing more somehow made the problem disappear and I can't get it to break again. Could add that in as an extra argument, but I need auto-patrol on this account to be able to edit the template space since I created the template before moving accounts.
Great work on the module :)
I want to dedicate some time to learning LUA myself (hoping to automate stuff on the wikis). Any suggestion on good learning sources?
 
  • 2Like
Reactions:
Great work on the module :)
I want to dedicate some time to learning LUA myself (hoping to automate stuff on the wikis). Any suggestion on good learning sources?
I mostly used existing modules on the English Wikipedia as examples, as well as Wikipedia's https://en.wikipedia.org/wiki/Help:Lua, and also just googled some questions (Thanks to Stack Overflow, as always). I don't know that much Lua myself.
I wanted to automate the entire Defines page's tables, but the tables with non-numeric keys seem to be ordered unpredictably rather than the order in which they're defined, so that fell through after finishing the entire code.
 
  • 2
Reactions:
I've tried to copy over English Wikipedia's Template:Template shortcut to use for the documentations of the templates, but it seems like the HoI4 Wiki's content handlers aren't set up to recognise pages ending with .css as sanitized CSS as it does by default, preventing creating Module:Shortcut/styles.css due to Lua errors. Seems like Template: Plainlist/styles.css (space to avoid conversion to emoji) is used as well. Would it be possible to port them over from the English Wikipedia (with attribution in the edit summary as per CC-BY-SA 4.0) and have their content model set to sanitized-css?
 
Finally got round to writing this up, here is a sudo code explanation of how we do the damage calculation for air combat. the wiki was pretty close just a few things where missing. I hope this will clear up any gaps. feel free to ask more questions if something isn't clear.

Code:
if ( AttackerAgility < OurAgility ){

DifferenceFactor = Min( Our Agility / Attacker Agility, BIGGEST_AGILITY_FACTOR_DIFF )

AgilityMitigation =( ( DifferenceFactor - 1 ) * ( AirAttack * COMBAT_BETTER_AGILITY_DAMAGE_REDUCTION ) ).Rounded
}



if ( AttackerSpeed > OurSpeed){

DifferenceFactor =Min( AttackerSpeed / OurSpeed, BIGGEST_SPEED_FACTOR_DIFF );

SpeedBonus =( ( DifferenceFactor - 1 ) * (AirAttack*COMBAT_BETTER_SPEED_DAMAGE_INCREASE ) ).Rounded
 
SpeedBonus +=( AttackerSpeed * TOP_SPEED_DAMAGE_BONUS_FACTOR / 100* AirAttack).Rounded
}

FinalAirAttack += SpeedBonus - AgilityMitigation

MaxKillCount =Min( TargetablePlaneCount, AirWingSize  - DelayedLosses )

RemainingTargetablePlaneCount -=
        AttackingPlanes / COMBAT_MULTIPLANE_CAP ).Rounded

ClampMin(RemainingTargetablePlaneCount, 0 )

DamageScale = IsCarrierFight ? COMBAT_DAMAGE_SCALE_CARRIER : COMBAT_DAMAGE_SCALE

CalcKillCount= Max( 0.01, ( FinalAirAttack * DamageScale * 0.1 ) / OurDefense )
 
if ( CalcKillCount< MaxKillCount ){
    KillCount = CalcKillCount.Truncated
    if ( RANDOM < ( UnlimitedKillCountWithDecimals - KillCount ) ){
         ++KillCount
    }
}
else{
KillCount = MaxKillCount
}

DelayedLosses += KillCount #this lets us run combat losses over multiple calcs without issue.
 
  • 5
  • 2Love
Reactions:
Can't upload svg file. https://commons.wikimedia.org/wiki/File:Lua-Logo.svg

edit.
Plus, someone know why module/template Lua do not create infobox? In other wiki it create, but here it's just normal text.
From the module:

Code:
    local html = mw.html.create('div')
        :addClass('c-sidebar')
    if #modules < 1 then
        html
            :tag('strong')
                :addClass('error')
                :wikitext('Error: no modules specified')
Specifically, the module adds "c-sidebar" and, if applicable, "error" CSS classes to the output, which decide a bulk of the properties including the border that makes it a visible infobox. However, neither of these seem to be defined on the HoI4 Wiki (meaning that adding the classes changes essentially nothing), and adding them can only be done by an administrator: the content handlers aren't set up to recognise pages ending with .css as sanitised CSS pages by default, and the only existing ones are in the MediaWiki namespace that aren't editable by non-administrators.

On another note, could you credit the exact Wiki that it was taken from in the edit summary by making a cosmetic edit to the pages that links to the page that was copied, (using an interwiki link if possible, with a list in Special:Interwiki)? Attribution is a requirement under CC BY-SA 4.0, and even if unlikely to turn into an issue, it's better to be on the safe side.
 
Last edited:
Have someone idea how to fix Template:Focus?? HTTP ERROR 500

My suggestion is to do like in my Sandbox page, or split existing one into each country/national focus = subpage.
Where in the second one, focus template would just call correct subpage based on tag parameter.

Code:
FRA, USA, UK, SOV, GER, ITA, JAP = 7
Generic, Chinese warlords, Horn of africa countries = 3
YUG, ROM, CZE, HUN = 4
GRE, TUR, BUL = 3
POL, LIT, LAT, EST = 4
MEX, HOL = 2
POR, SPR = 2
SWI, ETH = 2
CAN, SAF, RAJ, AST, NZL = 5
CHI, PRC, MAN = 3
total = 35
SWE, FIN, NOR, DEN = 4
total = 39

Additionally second one also is better for page translation in future.

Also there is option to do it with modules, but I have no clue how.

edit.
Ok, created module for testing.
Any feedback will be helpful. Including how to handle "Magazine for focuses", each country to seperate sub-module, then just require each of them? Or each dlc?


edit.
Created Module:Focus and updated Template:Focus
 
Last edited:
Currently, mw-collapsed tables start out as open before instantly being closed. This sometimes results in a link to a section heading (e.g. to a specific focus in a national focus page) that are below a collapsed table to break, as the browser closes the table after directing the reader to the linked section, moving the contents of the page up while the view remains static. This results in the link practically scrolling down further than intended when the reader clicks on it, unless they're already on the target page.
{{Collapse}} is a notable example of resulting in giant offsets whenever used, but somehow {{VisibleCollapse}} doesn't cause it (from what I've tested, if a table with a |! header is collapsed, the table's contents don't get loaded when the page is first opened. However, I didn't see a way to implement this into {{Collapse}} and have the button not float right).

From what I've found, https://phabricator.wikimedia.org/T42812 should have prevented this, and I can't replicate it on the English Wikipedia. Is it possible that the fix is somehow not implemented on PDX wikis?
 
@Randi Moth Do you have an example link to replicate this in the hoi4 wiki? If I try e.g. https://hoi4.paradoxwikis.com/Artillery_technology#Anti-Air it seems to be working fine for me in Chrome.
Compare https://hoi4.paradoxwikis.com/French_national_focus_tree#Reconnect_To_the_Balkans (working fine as intended) and https://hoi4.paradoxwikis.com/French_national_focus_tree#Loyalty_To_Moscow (with an offset, right after the {{Collapse}} used on a list of nations in the previous focus)

It only seems to only be broken in certain mw-collapsed usages, but not all. Every single {{Collapse}} usage triggers it, however. https://hoi4.paradoxwikis.com/Special:WhatLinksHere/Template:Collapse for a list of pages that use it right now for a minimum amount of affected pages.
 
Compare https://hoi4.paradoxwikis.com/French_national_focus_tree#Reconnect_To_the_Balkans (working fine as intended) and https://hoi4.paradoxwikis.com/French_national_focus_tree#Loyalty_To_Moscow (with an offset, right after the {{Collapse}} used on a list of nations in the previous focus)

It only seems to only be broken in certain mw-collapsed usages, but not all. Every single {{Collapse}} usage triggers it, however. https://hoi4.paradoxwikis.com/Special:WhatLinksHere/Template:Collapse for a list of pages that use it right now for a minimum amount of affected pages.
I can't seem to repro it there either... Maybe others can chime in to see how widespread this is. From how I understand it, timing divides between how quickly the JS runs versus the page rendering. The mediawiki version should easily be new enough to contain the referenced commit.
 
Last edited:
I can't seem to repro it there either... Maybe others can chime in to see how widespread this is. From what I understand it, timing devides between how quickly the JS runs versus the page rendering. The mediawiki version should easily be new enough to contain the referenced commit.
Maybe https://hoi4.paradoxwikis.com/French_national_focus_tree#Bomber_Focus is a better test, because there are more collapsed things before it. When I open that link(it does not work if you copy&paste the link into a tab in which that page is already open), it shows me the last focus (Naval Bomber Focus) instead of the Bomber Focus which is four lines above it. The eu4 wiki also has the same problem on a few pages. For example https://eu4.paradoxwikis.com/Achievements#Eat_your_Greens goes to the end of the page instead of the table line for the achievement "Eat your Greens".
 
  • 1Like
Reactions:
Maybe https://hoi4.paradoxwikis.com/French_national_focus_tree#Bomber_Focus is a better test, because there are more collapsed things before it. When I open that link(it does not work if you copy&paste the link into a tab in which that page is already open), it shows me the last focus (Naval Bomber Focus) instead of the Bomber Focus which is four lines above it. The eu4 wiki also has the same problem on a few pages. For example https://eu4.paradoxwikis.com/Achievements#Eat_your_Greens goes to the end of the page instead of the table line for the achievement "Eat your Greens".
Good example is also Italian Independace RSI, which move me to Gappisti focus.