baseAdd now uses the location class

doc_update
Joey Hines 2018-05-21 11:38:04 -05:00
parent 0a26e22dbe
commit e14a7ddb70
1 changed files with 12 additions and 11 deletions

View File

@ -15,14 +15,14 @@ class Location:
y = 0; y = 0;
z = 0; z = 0;
def __init__(self,str) : def __init__(self,args) :
try: self.name = args[0]
name = args[0] self.x = int(args[1])
x = int(args[1]) self.y = int(args[2])
y = int(args[2]) self.z = int(args[3])
z = int(args[3])
except ValueError: def posToStr(self) :
raise parseError return '(x=' + str(self.x) + ', y=' + str(self.y) + ', z=' + str(self.z) + ')'
@ -40,10 +40,11 @@ async def test():
@bot.command(pass_context=True) @bot.command(pass_context=True)
async def addBase(ctx, * args): async def addBase(ctx, * args):
if (len(args) > 0) : if (len(args) == 4) :
try: try:
base = location(args) base = Location(args)
except parseError: await bot.say('{}, your base named {} located at {} has been added to the database.'.format(ctx.message.author.mention, base.name, base.posToStr()))
except ValueError:
await bot.say('Invalid syntax, try again (?addbase [name] [x coord] [z coord])') await bot.say('Invalid syntax, try again (?addbase [name] [x coord] [z coord])')
else : else :