1
Programming / libtcod + python sys check for event error, make no sense!!
« on: February 11, 2013, 06:49:03 AM »
So I am working on a command menu for this RL I am developing, and I am running into an error that makes no sense at all to me. I am a beginner btw.
So in the menu function I test the key to see which command to call after which a function is called in which the player clickson a tile to set a destination. I am literally doing the exact same thing for each key, typed below...
if key == 'a':
libtcod.console_flush()
person = choose_ally() <--------------------- WORKS FINE!!
person.ai.get_destination()
elif key == 'b':
libtcod.console_flush()
person = choose_ally() <------------------ ERROR?!?!
person.ai.get_destination
person.hold = True
elif key == 'c':
libtcod.console_flush()
person = choose_ally <--------------- ERROR?!!
person.hold = None
If I press a than everything works fine. But if I press b or c and than choose any player than I get:
return _lib.TCOD_sys_check_for_event(c_int(mask),byref(k),byref(m))
TypeError: byref() argument must be a ctypes instance, not 'str'
The choose ally function is written below, all it does it either return ally or ally2, both of which are Objects with the same BasicAlly ai.
def choose_ally():
options = [ally.name, ally2.name]
header = ''
key = menu(header, options, 20)
char = chr(key + ord('a'))
if char == 'a':
return ally
elif char == 'b':
return ally2
Please someone help me out,I have been really getting into developing and I think I have a pretty good idea for a RL. I will attach the full code to this in the case that someone has some time to figure out whats going on. I followed the libtcod python tutorial and than taught myself how to add allys that the player will semi-command so don;t tear my coding apart or steal my ideas (or at least the first small part of the idea I am trying to implement)
purpherb
UPDATE: file is too big to upload but i can send it to someone somehow if anyone is willing to give me some help!
So in the menu function I test the key to see which command to call after which a function is called in which the player clickson a tile to set a destination. I am literally doing the exact same thing for each key, typed below...
if key == 'a':
libtcod.console_flush()
person = choose_ally() <--------------------- WORKS FINE!!
person.ai.get_destination()
elif key == 'b':
libtcod.console_flush()
person = choose_ally() <------------------ ERROR?!?!
person.ai.get_destination
person.hold = True
elif key == 'c':
libtcod.console_flush()
person = choose_ally <--------------- ERROR?!!
person.hold = None
If I press a than everything works fine. But if I press b or c and than choose any player than I get:
return _lib.TCOD_sys_check_for_event(c_int(mask),byref(k),byref(m))
TypeError: byref() argument must be a ctypes instance, not 'str'
The choose ally function is written below, all it does it either return ally or ally2, both of which are Objects with the same BasicAlly ai.
def choose_ally():
options = [ally.name, ally2.name]
header = ''
key = menu(header, options, 20)
char = chr(key + ord('a'))
if char == 'a':
return ally
elif char == 'b':
return ally2
Please someone help me out,I have been really getting into developing and I think I have a pretty good idea for a RL. I will attach the full code to this in the case that someone has some time to figure out whats going on. I followed the libtcod python tutorial and than taught myself how to add allys that the player will semi-command so don;t tear my coding apart or steal my ideas (or at least the first small part of the idea I am trying to implement)
purpherb
UPDATE: file is too big to upload but i can send it to someone somehow if anyone is willing to give me some help!