You shouldn't have to use a try/except block in mm_attach.
There's a lot of things wrong in your module. I'll start from the top:
- bd = balldata() - There is no balldata function defined any where.
- db_timer = set_timer(timer, 200); - the variable db_timer should most likely be in the arena data. You don't need a semicolon on the end of the line.
- if bd.state == CB_BALLFIRE:You've already got
arena.db_gameoverref = reg_callback(CB_BALLFIRE, gameover, arena) so you know this function only gets called on the ball fired event. Also the variable bd didn't exist before this line.
- db_timer.start() - thats not how you start timers, see the wiki.
- if a.playerover <= db_timer:a.playerover never existed until this point. You can't compare it with a timer either, since timer variables in py are references and don't have any useful value.
- chat.SendArenaMessage(arena, "p could not dodge a wrench or a ball and is OUT!") - Read some py tutorials and learn about string formatting. Heres how it should be done chat.SendArenaMessage(arena, "%s could not dodge a wrench or a ball and is OUT!" % p.name)
- if count_playing(arena) == 1: - where is function count_playing defined? Also what happens if there are 0 people playing? (Unexpected maybe, but possible).
- for_each_player(count_playing) - again no function count_playing defined. Maybe you want something like:
def count_playing(arena):
# use a 1 element list since apparently everything else is immutable inside nested functions.
playing = [ 0 ]
def cb_count(p):
if p.arena == arena and p.ship != SHIP_SPEC:
playing[0] += 1
for_each_player(cb_count)
return playing[0]
|
- chat.SendArenaMessage(arena, for_each_player, " is the winner!") - string format again