Attribute-related tests.

git-svn-id: svn://svn.code.sf.net/p/crossfire/code/maps/trunk@19789 282e977c-c81d-0410-88c4-b93c2d0d6712
master
ryo_saeba 2015-02-22 15:09:18 +00:00
parent 9aae9aad24
commit 5ff3ac1d4b
1 changed files with 20 additions and 0 deletions

View File

@ -43,6 +43,7 @@ def do_help():
help += ' - checkinventory\n'
help += ' - nosave\n'
help += ' - move_to\n'
help += ' - attr: object-attribute tests'
whoami.Say(help)
@ -432,6 +433,23 @@ def do_move_to():
whoami.WriteKey('dest_x', '2', 1)
whoami.WriteKey('dest_y', '2', 1)
def do_attr():
if len(topic) < 2:
whoami.Say('Usage: attr name [value], if value is omitted display the value')
return
if len(topic) == 2:
whoami.Say('my %s is %d'%(topic[1], getattr(whoami, topic[1])))
return
try:
setattr(whoami, topic[1], topic[2])
except:
try:
setattr(whoami, topic[1], int(topic[2]))
except:
whoami.Say("sorry, I don't know how to set this attribute...")
def handle_say():
if whoami.ReadKey('dest_x') != '' or whoami.ReadKey('dest_y') != '':
return
@ -511,6 +529,8 @@ def handle_say():
do_no_save()
elif topic[0] == 'move_to':
do_move_to()
elif topic[0] == 'attr':
do_attr()
else:
do_help()