Fixed a bug in @set that would not display attributes if they were set to 0 or None.

This commit is contained in:
Griatch 2011-03-20 01:19:05 +00:00
parent 7600892d5d
commit a429047452

View file

@ -1079,24 +1079,24 @@ class CmdSetAttribute(ObjManipCommand):
if self.rhs == None: if self.rhs == None:
# no = means we inspect the attribute(s) # no = means we inspect the attribute(s)
for attr in attrs: for attr in attrs:
value = obj.attr(attr) if obj.has_attribute(attr):
if value: string += "\nAttribute %s/%s = %s" % (obj.name, attr, obj.get_attribute(attr))
string += "\n%s.db.%s = %s" % (obj.name, attr, value)
else: else:
string += "\n%s has no attribute '%s'." % (obj.name, attr) string += "\n%s has no attribute '%s'." % (obj.name, attr)
else: else:
# deleting the attribute(s) # deleting the attribute(s)
for attr in attrs: for attr in attrs:
if obj.attr(attr): if obj.has_attribute(attr):
obj.attr(attr, delete=True) val = obj.get_attribute(attr)
string += "\nAttribute %s.db.%s deleted." % (obj.name, attr) obj.del_attribute(attr)
string += "\nDeleted attribute '%s' (= %s) from %s." % (attr, val, obj.name)
else: else:
string += "\n%s has no attribute '%s'." % (obj.name, attr) string += "\n%s has no attribute '%s'." % (obj.name, attr)
else: else:
# setting attribute(s) # setting attribute(s)
for attr in attrs: for attr in attrs:
obj.attr(attr, value) obj.set_attribute(attr, value)
string += "\nAttribute %s.%s created." % (obj.name, attr) string += "\nCreated attribute %s/%s = %s" % (obj.name, attr, value)
# send feedback # send feedback
caller.msg(string.strip('\n')) caller.msg(string.strip('\n'))