// Ctrl+S to save & compile // Select a method from the pull-down above, and then click Run. // The return value is printed as a string in the Log (dockable). // All static methods with no parameters are placed in the pull-down. class CreateFrankenDoll { static fun create( dollName : String, donorNames : String... ) { val resources = Editor.resources val frankenDoll = Costume( resources ) val events = frankenDoll.events events["editor"] = CostumeEvent(frankenDoll).apply { poses.add( resources.poses.find( "${donorNames[0]}-torso" ) ) } for (partName in listOf( "head", "torso", "arm-left", "arm-right", "abdomen", "leg-left", "leg-right" ) ) { val partEvent = CostumeEvent(frankenDoll) events[partName] = partEvent for ( donorName in donorNames ) { val donor = resources.costumes.find( donorName ) val donorPart = donor.chooseCostume( partName ) partEvent.costumes.add( donorPart ) // Ensure that each of the donor's parts has an event "doll" which is the Doll costume to which they belong. if (donorPart.chooseCostume("doll") == null) { donorPart.events["doll"] = CostumeEvent( donorPart ).apply { costumes.add( donor ) } } } } resources.costumes.add( dollName, frankenDoll ) ResourcesReaderWriter.save(resources) println( "Now click reload - because tabs may have stale data!" ) } static fun createFike() { create( "fike", "mike", "fiona" ) } static fun createMonster() { create( "monster", "asul", "eesha", "emma", "fiona", "foxie", "jishna", "lilian", "mike" ) } static fun createBanta() { create( "banta", "santa", "bony" ) } static fun createShah() { create( "shah", "asul", "eesha", "jishna" ) } static fun createBoxie() { create( "boxie", "bony", "foxie" ) } static fun createSemma() { create( "semma", "santa", "emma" ) } }