Advertisement
Guest User

attempt to auto define image and side_image LiveComposite

a guest
Mar 8th, 2015
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.66 KB | None | 0 0
  1.     def define_composites(folder_name, image_size, side_image=False):
  2.         base = {}
  3.         mouth = {}
  4.         eyes = {}
  5.         brows = {}
  6.         arms = {}
  7.         hair = {}
  8.         effect = {}
  9.         blank = ""
  10.        
  11.         for path in renpy.list_files():
  12.             if path.startswith("sprites/" + folder_name):
  13.                 filename = path.split("/")[-1]
  14.                 filename = os.path.splitext(filename)[0]
  15.                
  16.                 if filename.endswith("base"):
  17.                     base[folder_name + filename[:-4]] = path
  18.                 elif filename.startswith("ku"):
  19.                     mouth[filename[2:]] = path
  20.                 elif filename.startswith("me"):
  21.                     eyes[filename[2:]] = path
  22.                 elif filename.startswith("ma"):
  23.                     brows[filename[2:]] = path
  24.                 elif filename.startswith("fx"):
  25.                     effect[filename[2:]] = path
  26.                 elif filename.startswith("pose"):
  27.                     arms[filename[4:]] = path
  28.                 elif filename.startswith("ka"):
  29.                     hair[filename[2:]] = path
  30.                 ### function requires a "none" file
  31.                 elif filename == "none":
  32.                     blank = path
  33.                      
  34.         effect["x"] = blank
  35.         for x in [mouth, eyes, brows, arms, hair, effect]:
  36.             if len(x) == 0:
  37.                 x["x"] = blank
  38.                
  39.         position = (0, 0)
  40.         for type in base:
  41.             layer0 = (position, base[type])
  42.           #  if side_image:
  43.           #      t = Character(type.capitalize(), color="#E7B0DC", image=type.lower())
  44.           #      def f(what, k=t, outfit=None, pose=None, expression=None, **kwargs):
  45.           #          k(what, **kwargs)
  46.           #      setattr(sys.modules[__name__], type, f)
  47.             for teeth in mouth:
  48.                 layer1 = layer0 + (position, mouth[teeth])
  49.                 for ball in eyes:
  50.                     layer2 = layer1 + (position, eyes[ball])
  51.                     for brow in brows:
  52.                         layer3 = layer2 + (position, brows[brow])
  53.                         for arm in arms:
  54.                             layer4 = layer3 + (position, arms[arm])
  55.                             for cut in hair:
  56.                                 layer5 = layer4 + (position, hair[cut])
  57.                                 for shoot in effect:
  58.                                     layers = layer5 + (position, effect[shoot])
  59.                                     shortname = (type, teeth, ball, brow, arm, cut, shoot)
  60.                                     renpy.image(shortname, LiveComposite(image_size, *layers))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement