1 import os
, utility
, packets
, nil
.file, keyboard_configuration
, craw
, player_killer
, random
4 return current_handler
.command_handler
.town_portal_handler
7 packets
.send_chat(message
)
10 get_tp_handler().cast_town_portal()
13 get_tp_handler().town_tp()
16 get_tp_handler().tppk()
22 print 'Failed to reveal the current act!'
25 current_handler
.player_killer_handler
.attack()
28 current_handler
.player_killer_handler
.ground_attack()
31 print 'Inviting all players'
32 my_player
= utility
.get_my_player()
33 players
= craw
.get_players()
34 for player
in players
:
35 if my_player
.id == player
.id:
37 packets
.invite_player(player
.id)
40 lines
= nil
.file.read_lines(file)
42 print 'Unable to read %s'
43 elif len(lines
) >= 25:
44 print '%s has too many lies' % file
46 print 'Reading %s and sending it to the chat' % file
48 packets
.send_chat(line
)
50 def random_quote(directory
):
51 files
= os
.listdir(directory
)
52 source
= files
[random
.randint(0, len(files
) - 1)]
53 say_file(os
.path
.join(directory
, source
))
55 current_handler
= None
57 class bind_handler_class
:
59 self
.bindings
= keyboard_configuration
.bindings
60 self
.player_killer_handler
= None
61 craw
.set_keyboard_handler(self
.process_key
)
63 def bind(self
, key
, action
):
64 self
.bindings
[key
] = action
65 self
.serialise_bindings()
67 def unbind(self
, key
):
68 self
.bindings
.pop(key
)
69 self
.serialise_bindings()
71 def print_bindings(self
):
72 for key
in self
.bindings
:
73 print '"%s": %s' % (key
, self
.bindings
[key
])
75 def escape(self
, input):
76 return input.replace("'", "\\'")
78 def serialise_bindings(self
):
79 data
= '#This file was generated automatically, do not edit it at runtime\n\n'
80 data
+= 'bindings = {\n'
81 for key
in self
.bindings
:
82 key
= self
.escape(key
)
83 command
= self
.escape(self
.bindings
[key
])
84 data
+= "\t'%s': '%s',\n" % (key
, command
)
87 data
= data
.replace(',\n}', '\n}')
89 path
= os
.path
.join(utility
.get_configuration_directory(), 'keyboard_configuration.py')
91 nil
.file.write_file(path
, data
)
93 def process_key(self
, key
):
97 global current_handler
98 current_handler
= self
99 code
= self
.bindings
[key_char
]