Advertisement
Kovitikus

fstring version

Mar 24th, 2021
633
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.         character_attributes = ["languages", "speaking", "personal_scent", "reputation", "personality", "peoplecolor",
  2.                                 "speechcolor", "pose_default", "pose", "travelstring_default", "travelstring",
  3.                                 "voicetype", "voicedesc", "birthday", "armor", "covered", "bodyparts", "clothes",
  4.                                 "origin", "handedness", "age", "gender", "heritage", "background", "privatepast",
  5.                                 "desc", "height", "weight", "eyecolor", "skincolor", "haircolor", "hairstyle",
  6.                                 "handwriting", "skills", "stats", "currency"]
  7.         string = ""
  8.         string = "|R# CHARACTERS|n|/"
  9.         string = f"{string}|/limbo = caller.search('#2', global_search=True)|/|/"
  10.         char_id = 1
  11.         for char in Character.objects.all():
  12.             # collect the account it belongs to, in order to search out and attach to in the build
  13.             if char.account:
  14.                 char_account_name = char.account.name
  15.             else:
  16.                 char_account_name = "Aleph"
  17.             # Set up string to create new character object
  18.             string = f"{string}|/character_{char_id}s = create_object(Character, key='{char.key}s', location=limbo)|/"
  19.             # Attach the object to the right account
  20.             string = f"{string}|/for player in Account.objects.all():|/" \
  21.                       f"|-if player.key == '{char_account_name}':|/" \
  22.                       f"|-|-player.db._playable_characters.append(character_{char_id}s)|/"
  23.             # Fix the attributes of the new object
  24.             for attribute in character_attributes:
  25.                 string = f"{string}character_{str(char_id)}.db.{attribute} = {char.attributes.get(attribute)}|/"
  26.             char_id = char_id + 1
  27.  
  28.         self.caller.msg(string)
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement