Issues with python/libtcod

Graham Fielding frednotbob at hotmail.ca
Thu Nov 8 01:07:27 CET 2012





Hey, all. 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. Here's a code snippet, including the affected line. #def menu(header, options, width):
    #if len(options) > 26: raise ValueError('Cannot have a menu with more than 26 options.')
 
    #calculate total height for the header (after auto-wrap) and one line per option
    #header_height = libtcod.console_height_left_rect(con, 0, 0, width, SCREEN_HEIGHT, header)
    #height = len(options) + header_height
In a nutshell: def menu() 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. 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:
File "C:/Python Project/Roguelike.py", line 602, in <module>
    player_action = handle_keys()
  File "C:/Python Project/Roguelike.py", line 531, in handle_keys
    chosen_item = inventory_menu('Press the key next to an item to use it, or any other to cancel.\n')
  File "C:/Python Project/Roguelike.py", line 487, in inventory_menu
    index = menu(header, options, INVENTORY_WIDTH)
  File "C:/Python Project/Roguelike.py", line 447, in menu
    header_height = libtcod.console_height_left_rect(con, 0, 0, width, SCREEN_HEIGHT, header)
AttributeError: 'module' object has no attribute 'console_height_left_rect' I've tried moving the entire def menu() function to various sections of the stack, I've changed its arguments manually, and I've even removed the affected line entirely to see if that would help; nothing seems to work, and it's only when def menu() is called that this happens. Anyone got any ideas what could be going flooey? 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20121107/95e96e1e/attachment.html>


More information about the Python-list mailing list