<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>
Hey, all.<BR> <BR>I'm trying to program a roguelike, using the wonderful tutorials written by Joćo F. Henriques (a.k.a. Jotaf), but I've stumbled onto a bit of a problem setting up the game's inventory system, and I was hoping someone could help me out.<BR> <BR>Here's a code snippet, including the affected line.<BR> <BR><span class="kw1"><strong><font color="#ff7700">#def</font></strong></span> menu<span class="br0">(</span>header, options, width<span class="br0">)</span>:<br> #<span class="kw1"><strong><font color="#ff7700">if</font></strong></span> <span class="kw2"><font color="#008000">len</font></span><span class="br0">(</span>options<span class="br0">)</span> <span class="sy0"><font color="#66cc66">></font></span> <span class="nu0"><font color="#ff4500">26</font></span>: <span class="kw1"><strong><font color="#ff7700">raise</font></strong></span> <span class="kw2"><font color="#008000">ValueError</font></span><span class="br0">(</span><span class="st0"><font color="#483d8b">'Cannot have a menu with more than 26 options.'</font></span><span class="br0">)</span><br> <br> <span class="co1"><em><font color="#808080">#calculate total height for the header (after auto-wrap) and one line per option</font></em></span><br> #header_height = libtcod.<span class="me1">console_height_left_rect</span><span class="br0">(</span>con, <span class="nu0"><font color="#ff4500">0</font></span>, <span class="nu0"><font color="#ff4500">0</font></span>, width, SCREEN_HEIGHT, header<span class="br0">)</span><br> #height = <span class="kw2"><font color="#008000">len</font></span><span class="br0">(</span>options<span class="br0">)</span> + header_height<br><BR>In a nutshell:<BR> <BR><em>def menu()</em> is an all-encompassing 'menu processor' function -- it contains a standardized menu layout that can be called, from anywhere in the stack, to create a generic menu.<BR> <BR>When I launch the game to check things out, everything runs smoothly until I try to open the inventory window -- at which point, IDLE tosses up an AttributeError:<BR><br>File "C:/Python Project/Roguelike.py", line 602, in <module><br> player_action = handle_keys()<br> File "C:/Python Project/Roguelike.py", line 531, in handle_keys<br> chosen_item = inventory_menu('Press the key next to an item to use it, or any other to cancel.\n')<br> File "C:/Python Project/Roguelike.py", line 487, in inventory_menu<br> index = menu(header, options, INVENTORY_WIDTH)<br> File "C:/Python Project/Roguelike.py", line 447, in menu<br> header_height = libtcod.console_height_left_rect(con, 0, 0, width, SCREEN_HEIGHT, header)<br>AttributeError: 'module' object has no attribute 'console_height_left_rect'<BR> <BR>I've tried moving the entire <em>def menu()</em> function to various sections of the stack, I've changed its arguments manually, and I've even removed the affected line <em>entirely</em> to see if that would help; nothing seems to work, and it's only when def menu() is called that this happens.<BR> <BR>Anyone got any ideas what could be going flooey?<BR> </div></body>
</html>