When customizing Info Pages content for a side project of mine I have encountered a minor problem: Warband module system compiler does not understand references to entries of module_info_pages.py.
To fix the problem process_operations.py file must be modified as follows:
Add one more import directive in the beginning of the file:
Then, modify the get_id_value function as follows (changes are closer to the end):
Finally, modify the get_identifier_value function:
As the result of these modifications you will be able to use "ip_whatever" references in the module system text to refer to entries of module_info_pages.py file. I have used this to convert "Game Concepts" page to "Game Reports" page, which will contain analogs of menus from "Reports" menu - slightly customized and with actually working hyperlinks.
Screenshot (click to open full version):
To fix the problem process_operations.py file must be modified as follows:
Add one more import directive in the beginning of the file:
Code:
from module_info_pages import *
Then, modify the get_id_value function as follows (changes are closer to the end):
Code:
def get_id_value(tag, identifier, tag_uses):
tag_type = -1
id_no = -1
if (tag == "str"):
id_no = find_object(strings,identifier)
tag_type = tag_string
elif (tag == "itm"):
id_no = find_object(items,identifier)
tag_type = tag_item
elif (tag == "trp"):
id_no = find_object(troops,identifier)
tag_type = tag_troop
elif (tag == "fac"):
id_no = find_object(factions,identifier)
tag_type = tag_faction
elif (tag == "qst"):
id_no = find_object(quests,identifier)
tag_type = tag_quest
elif (tag == "pt"):
id_no = find_object(party_templates,identifier)
tag_type = tag_party_tpl
elif (tag == "p"):
id_no = find_object(parties,identifier)
tag_type = tag_party
elif (tag == "scn"):
id_no = find_object(scenes,identifier)
tag_type = tag_scene
elif (tag == "mt"):
id_no = find_object(mission_templates,identifier)
tag_type = tag_mission_tpl
elif (tag == "mnu"):
id_no = find_object(game_menus,identifier)
tag_type = tag_menu
elif (tag == "script"):
id_no = find_object(scripts,identifier)
tag_type = tag_script
elif (tag == "psys"):
id_no = find_object(particle_systems,identifier)
tag_type = tag_particle_sys
elif (tag == "spr"):
id_no = find_object(scene_props,identifier)
tag_type = tag_scene_prop
elif (tag == "prsnt"):
id_no = find_object(presentations,identifier)
tag_type = tag_presentation
elif (tag == "snd"):
id_no = find_object(sounds,identifier)
tag_type = tag_sound
elif (tag == "icon"):
id_no = find_object(map_icons,identifier)
tag_type = tag_map_icon
elif (tag == "skl"):
id_no = find_object(skills,identifier)
tag_type = tag_skill
elif (tag == "track"):
id_no = find_object(tracks,identifier)
tag_type = tag_track
elif (tag == "mesh"):
id_no = find_object(meshes,identifier)
tag_type = tag_mesh
elif (tag == "anim"):
id_no = find_object(animations,identifier)
tag_type = tag_animation
elif (tag == "tableau"):
id_no = find_object(tableaus,identifier)
tag_type = tag_tableau
# INSERT NEW LINES:
elif (tag == "ip"):
id_no = find_object(info_pages,identifier)
tag_type = 0
# NO MORE NEW LINES.
if (tag_type > -1 and id_no > -1):
add_tag_use(tag_uses,tag_type,id_no)
return (tag_type, id_no)
Finally, modify the get_identifier_value function:
Code:
def get_identifier_value(str, tag_uses):
underscore_pos = string.find(str, "_")
result = -1
if (underscore_pos > 0):
tag_str = str[0:underscore_pos]
id_str = str[underscore_pos + 1:len(str)]
(tag_type, id_no) = get_id_value(tag_str,id_str,tag_uses)
#if (tag_type > 0): # THIS LINE IS DISABLED
if (tag_type >= 0): # AND THIS LINE IS USED INSTEAD
if (id_no < 0):
print "Error: Unable to find object:" + str
else:
result = id_no | (tag_type << op_num_value_bits)
else:
print "Error: Unrecognized tag:" +tag_str + "in object:" + str
else:
print "Error: Invalid object:" +str + ".Variables should start with $ sign and references should start with a tag"
return result
As the result of these modifications you will be able to use "ip_whatever" references in the module system text to refer to entries of module_info_pages.py file. I have used this to convert "Game Concepts" page to "Game Reports" page, which will contain analogs of menus from "Reports" menu - slightly customized and with actually working hyperlinks.
Screenshot (click to open full version):