Code: Show/Hide # callbacks
from asss import * chat = get_interface(I_CHAT) def goal(arena, p, bid, x, y): chat.SendArenaMessage(arena, "goal.") cb1 = reg_callback(CB_GOAL, goal) ... # commands from asss import * chat = get_interface(I_CHAT) def c_mycmd(cmd, params, p, targ): """\ some help text """ chat.SendMessage(p, "moo.") cmd1 = add_command("t1", c_mycmd) |
Code: Show/Hide def mm_attach(arena):
# do stuff with arena def mm_detach(arena): # undo stuff |
Code: Show/Hide def blah(p):
# do stuff to p asss.for_each_player(blah) |
Code: Show/Hide typedef struct Imoney
{ ... void (*addMoney)(Player *player, int amount); /* pyint: player, int -> void */ ... } |
Code: Show/Hide # method 1
def count_players(condition): count = [0] def blah(p): if condition(p): count[0] += 1 asss.for_each_player(blah) return count[0] # method 2 class ConditionCounter: def __init__(me, condition): me.count = 0 me.condition = me.condition def __call__(me, p): if me.condition(p): me.count += 1 c = ConditionCounter(condition) asss.for_each_player(c) # do stuff with c.count |