Difference between revisions of "Monster stats/Script"

From Wildermyth Wiki
m
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>monsterStats.py</nowiki>''' (or whatever you want) inside the '''<nowiki>Wildermyth</nowiki>''' directory. Then run it by calling '''<nowiki>python monsterStats.py</nowiki>''' from the command line. It will create a text file for each difficulty named '''<nowiki>monsterStats_<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"
Line 7: Line 7:
  <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('monsterStats_%s.txt'%diff, 'w') as f:
     f.write(string)</nowiki>
     f.write(string)</nowiki>
|}
|}

Revision as of 05:05, 20 February 2022

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