- Jul 20, 2018
- 724
- 1,184
So I guess this is a pretty novel question on this forum. I just wanted to know about documenting code. I'm trying to be a good boy and document my code properly (or good enough at any rate.) I'm still pretty new and wanted an outsider perspective if what I'm doing is good enough; am I going overboard or should I document more?
Below I provide some code and would like some feedback from the more experienced programmers The code provided is part of the event handler that will run the game and make the game easily updateable (or make it possible to mod in events).
Example 1:
Example 2:
Example 3:
Below I provide some code and would like some feedback from the more experienced programmers The code provided is part of the event handler that will run the game and make the game easily updateable (or make it possible to mod in events).
Example 1:
Python:
def addcalendar(txtfilenumber):
"""addcalendar(textfilenumber) takes a textfile chops it's contents into tuples and then triggers the addtuple fuction to add the individual tuples to the calendar variable.
textfilenumber is the numer of the textfile that needs to be read.
textfiles for mods should be odd numbers. even numbers are reserved for the game.
"""
x = [ i.strip() for i in renpy.file("txt/" + str(txtfilenumber) + ".txt") ]
for j in range(len(x)):
x[j] = tuple(x[j].split(","))
addtuple(x[j])
Python:
def calendarsort():
"""calendarsort() does what it says on the thin it sorts the calendar after start or after load to make sure the events play in the right order."""
global calendar
for i in calendar:
for j in range (1,8):
calendar[i][j].sort()
Python:
def firststart():
"""firststart() is called upon when a new game is started. it will read the files in the txt folder in the game folder.
the game can read files up to 25000. but will stop at the highest 1000 found. e.g. if you wish the game to read file 1001.txt another file called 2000.txt should be present in the folder (keep txt files that are multiples of 1000 empty). (I hope this will increase gamespeed on first start and after load.)
for modding txt files should always be odd numbers. Even numbers are used for game files
One event per line
eventlines should be built as follows:
week,weekday,time,whentrigger,label
week 90 - 99 before start academic year
Week 80 - 89 after end academic year
Week 01 - 52 Academic year (academic year is not 52 weeks long but space is reserved anyway_
weekday mon (1) - sun (7)
time 0000 - 2400 (time between HH00 - HH04 is reserved to resolve schedule conflicts)
whentrigger a quick selection for the eventhandler (if pc is not part of Scholastica those events can be ignored.) If it should trigger for multiple memberships just use the 'all' ID.
label is the label needed to start the event.
correct eventline example:
91,1,1205,all,startprologue
"""
global txtcheck
global txtloaded
global txtnotloaded
number = maxcheck()
for i in range(0,number):
if renpy.exists("txt/" + str(i) + ".txt") == True:
txtloaded.append(i)
addcalendar(i)
else:
txtnotloaded.append(i)
calendarsort()