Difference between revisions of "Monster stats/Script"

From Wildermyth Wiki
m
m
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
This is a [https://www.python.org/downloads/ Python] script to generate the [[monster stat]] tables. Copy the code in the box below into a text file named '''<nowiki>tables.py</nowiki>''' (or whatever you want) inside the '''<nowiki>Wildermyth</nowiki>''' directory. Then run it by calling '''<nowiki>python tables.py</nowiki>''' from the command line. It will create a text file for each difficulty named '''<nowiki>tables_<difficulty>.txt</nowiki>''', full of wiki-formatted tables that can be pasted into the appropriate wiki pages.
This is a [https://www.python.org/downloads/ Python] script to generate the [[monster stat]] tables. Copy the code in the box below into a text file named '''<nowiki>wikiMonsterStats.py</nowiki>''' (or whatever you want) inside the '''<nowiki>Wildermyth</nowiki>''' directory. Then run it by calling '''<nowiki>python wikiMonsterStats.py</nowiki>''' from the command line. It will create a text file for each difficulty named '''<nowiki>wikiMonsterStats_<difficulty>.txt</nowiki>''', full of wiki-formatted tables that can be pasted into the appropriate wiki pages.


{| role="presentation" class="wikitable mw-collapsible mw-collapsed"
{| role="presentation" class="wikitable mw-collapsible mw-collapsed"
| '''<nowiki>tables.py</nowiki>'''
| '''<nowiki>wikiMonsterStats.py</nowiki>'''
|-
|-
|
|
  <nowiki>import json
  <nowiki>import json
from glob import glob
from glob import glob
with open('version.txt','r',encoding='utf8') as f:
  lines = f.readlines()
  version = lines[0]


name_path_base = ''
name_path_base = ''
Line 95: Line 99:
     string += '|}\n\n'
     string += '|}\n\n'
     string += '|}\n\n'
     string += '|}\n\n'
   
  string += '==Notes==\nLast updated [[%s]] using [[Monster stats/Script|this script]].\n'%version[:-1]
    
    
   with open('tables_%s.txt'%diff, 'w') as f:
   with open('wikiMonsterStats_%s.txt'%diff, 'w') as f:
     f.write(string)</nowiki>
     f.write(string)</nowiki>
|}
|}

Latest revision as of 13:38, 5 March 2022

This is a Python script to generate the monster stat tables. Copy the code in the box below into a text file named wikiMonsterStats.py (or whatever you want) inside the Wildermyth directory. Then run it by calling python wikiMonsterStats.py from the command line. It will create a text file for each difficulty named wikiMonsterStats_<difficulty>.txt, full of wiki-formatted tables that can be pasted into the appropriate wiki pages.