Advertisement
Shadowolf3400

Layered Garments (v11) for Inform7

Feb 14th, 2013
733
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 22.83 KB | None | 0 0
  1. Version 11/130805 of Layered Garments by Shadow Wolf begins here.
  2.  
  3. "Based on What Not To Wear in the Documentation, made generic for any actor."
  4.  
  5. Include Plurality by Emily Short.
  6.  
  7. Volume 1 - Equipped items and the bearing relation
  8.  
  9. ["Equipped" means that the item isn't carried - it's either part of the person or worn by them.]
  10. Definition: A thing is equipped rather than unequipped:
  11. let the item be it;
  12. while the item is part of something, let the item be the holder of the item;
  13. if the item is a person or the item is worn by a person, yes;
  14. no.
  15.  
  16. To decide which person is the bearer of (the item - a thing):
  17. let B be the holder of the item;
  18. while B is not a person, let B be the holder of B;
  19. decide on B.
  20.  
  21. Bearing relates a person (called the bearer) to a thing (called the item) when the item is equipped and the item is enclosed by the bearer. The verb to bear (he bears, they bear, he bore, it is borne, he is bearing) implies the bearing relation.
  22.  
  23. Volume 2 - Overlying and Underlying
  24.  
  25. A garment-element is a kind of thing.
  26.  
  27. A garment is a kind of garment-element. A garment can be transparent. A garment is usually wearable.
  28.  
  29. A garment-piece is a kind of garment-element. The printed name of a garment-piece is usually "[holder of the item described]". A garment-piece is usually privately-named. A garment-piece is usually not wearable.
  30. Before an actor taking off a garment-piece: try the actor taking off the holder of the noun instead.
  31. Before an actor wearing a garment-piece: try the actor wearing the holder of the noun instead.
  32.  
  33. Definition: A garment is complex if it incorporates a garment-element.
  34.  
  35. Composition relates a garment-element (called B) to a garment (called A) when A is B or B is part of A. The verb to compose (it composes, they compose, it composed, it is composed, it is composing) implies the composition relation. The verb to be a portion of implies the composition relation.
  36.  
  37. Definition: A garment-element is worn if it is borne by someone. [The "worn" definition normally only applies to the player - this overrides that.]
  38.  
  39. Underlying relates various garment-elements to various garment-elements with fast route-finding. The verb to underlie (it underlies, they underlie, it is underlying, it is underlaid) implies the underlying relation. The verb to be under implies the underlying relation.
  40.  
  41. To decide whether (X - a garment-element) prevents/prevent wearing (Y - a garment): if X covers something which is a portion of Y, yes; otherwise no.
  42.  
  43. Impeding relates a garment-element (called G) to a garment (called M) when G prevents wearing M. The verb to impede (it impedes, they impede, it is impeding, it is impeded) implies the impeding relation.
  44.  
  45. Check an actor taking off a garment (this is the cant take something off if its covered rule):
  46. if an uppermost garment-element (called the impediment) borne by the actor impedes the noun, say "[The impediment] [is-are] in the way." instead;
  47. if a garment-element (called the impediment) borne by the actor impedes the noun, say "Something seems to be in the way." instead. [This last should only take place if the author defines invisible clothes...]
  48.  
  49. Carry out an actor taking off a garment (this is the taking off garments rule): doff the noun.
  50.  
  51. Report an actor taking off something (this is the report remaining clothes after taking off garments rule):
  52. say "[It-they of the actor] [is-are] now wearing [a list of unconcealed things worn by the actor]." instead.
  53.  
  54. Definition: a garment-element is uppermost if it is not under something opaque.
  55. Definition: A garment (called g) is unconcealed if a garment-element which is a portion of G is uppermost.
  56.  
  57. Before an actor taking off a garment which is impeded by something which is borne by the actor (This is the take off intervening clothing before removing rule):
  58. while the noun is impeded by an uppermost garment-element (called the impediment) which is borne by the actor:
  59. report implicitly removing the impediment;
  60. silently try the actor taking off the impediment;
  61. if actor bears the impediment, stop the action;
  62.  
  63. Overlying relates various garment-elements to various garment-elements with fast route-finding. The verb to overlie (it overlies, they overlie, it is overlying, it is overlaid) implies the overlying relation.
  64.  
  65. Covering relates a garment-element (called A) to a garment-element (called B) when the number of steps via the overlying relation from A to B is greater than 0. The verb to cover (it covers, they cover, it is covering, it is covered) implies the covering relation.
  66.  
  67. Layering rules is a rulebook.
  68.  
  69. Before an actor wearing a not worn garment which is impeded by something which is borne by the actor (this is the take off intervening clothing before wearing rule):
  70. while the noun is impeded by an uppermost garment-element (called the impediment) which is borne by the actor:
  71. report implicitly removing the impediment;
  72. silently try the actor taking off the impediment;
  73. if actor bears the impediment, stop the action.
  74.  
  75. Check an actor wearing a not worn garment which is impeded by something which is borne by the actor (this is the cant wear if theres impeding clothing rule):
  76. if the noun is impeded by an uppermost garment-element (called the impediment) which is borne by the actor, say "[The impediment] [is-are] in the way." instead;
  77. if the noun is impeded by a garment-element (called the impediment) which is borne by the actor, say "Something seems to be in the way." instead.
  78.  
  79. Carry out an actor wearing a garment (this is the standard wearing garments rule): don the noun.
  80.  
  81. Instead of looking under a garment which is worn by the player (this is the peeking at underwear rule):
  82. if a worn garment-element (called the underwear) underlies a garment-element which is a portion of the noun, say "You peek at [the underwear]. Yup, still there.";
  83. otherwise say "Just you in there."
  84.  
  85. Instead of taking inventory (this is the visible garments inventory rule):
  86. say "You're carrying [a list of things carried by the player][if the player wears something]. You are wearing [a list of unconcealed garment-elements worn by the player][end if]."
  87.  
  88. Volume 3 - Activities - Donning, doffing, reporting implicit removal of
  89.  
  90. Doffing something is an activity on garments. The doffing activity has a person called the doffer.
  91.  
  92. The first before doffing a garment (called the clothing): now the doffer is the holder of the clothing.
  93.  
  94. Rule for doffing a garment (called the clothing):
  95. repeat with piece running through garment-elements composing the clothing:
  96. now the piece is not underlaid by anything.
  97.  
  98. Donning something is an activity on garments. The donning activity has a person called the donner.
  99.  
  100. The first before donning a garment (called the clothing): now the donner is the holder of the clothing.
  101.  
  102. Rule for donning a garment (called the clothing):
  103. repeat with piece running through garment-elements composing the clothing:
  104. repeat with hidden item running through garment-elements borne by the donner:
  105. if the piece covers the hidden item, now the hidden item underlies the piece;
  106. repeat with hidden item running through garment-elements incorporated by the donner:
  107. if the piece covers the hidden item, now the hidden item underlies the piece.
  108.  
  109. Reporting implicit removal of something is an activity on garments. The reporting implicit removal activity has a garment called the impediment.
  110. Before reporting implicit removal of a garment-element (called the item) (this is the set activity variables for reporting implicit removal rule): Now the impediment is the item.
  111.  
  112. Rule for reporting implicit removal of a garment (this is the standard reporting implicit removal rule): say "(first removing [the impediment])[command clarification break]".
  113.  
  114. To doff (the item - a garment): carry out the doffing activity with the item.
  115. To don (the item - a garment): carry out the donning activity with the item.
  116. To report implicitly removing (the item - a garment): Carry out the reporting implicit removal activity with the item.
  117. To report implicitly removing (the item - a garment-element): Carry out the reporting implicit removal activity with the holder of the item.
  118.  
  119. Volume 4 - Regional Coverage
  120.  
  121. Overlapping relates a garment-element (called X) to a garment-element (called Y) when
  122. X does not cover Y and
  123. Y does not cover X and
  124. X covers a body-part which is covered by Y.
  125. The verb to overlap (it overlaps, they overlap, it is overlapped, it is overlapping, it is overlapped) implies the overlapping relation.
  126.  
  127. Before an actor wearing a not worn garment (this is the remove garments on the same area rule):
  128. while an uppermost garment-element (called the impediment) borne by the actor overlaps something composing the noun:
  129. report implicitly removing the impediment;
  130. silently try the actor taking off the impediment;
  131. if the actor bears the impediment, stop the action.
  132.  
  133. Check an actor wearing a not worn garment (this is the cant wear if another garment is on the same area rule):
  134. if something borne by the actor covers a body-part which is covered by something composing the noun: [Fast but incomplete check, for performance.]
  135. if an uppermost garment-element (called the impediment) borne by the actor overlaps something composing the noun, say "[The impediment] [is-are] in the way." instead;
  136. if a garment-element (called the impediment) borne by the actor overlaps something composing the noun, say "Something seems to be in the way." instead.
  137.  
  138. Check an actor wearing a garment when the actor is wearing the noun (this is the cant wear worn garments rule): instead say "[It-they of the actor] [is-are] already wearing [that-those of the noun]."
  139.  
  140. A body-part is a kind of garment-element. A torso, a seat, and pair of feet are kinds of body-part.
  141.  
  142. One torso is part of every person. One pair of feet is part of every person. One seat is part of every person.
  143.  
  144. A pair of pants, a pair of underpants, a foundation garment, a pair of socks, a pair of shoes, a jacket, and a shirt are kinds of garment.
  145.  
  146. The plural of pair of pants is pairs of pants. The plural of pair of underpants is pairs of underpants. The plural of socks is pairs of socks. The plural of pair of shoes is pairs of shoes.
  147.  
  148. A layering rule (this is the simple garments layering rule):
  149. now every pair of socks overlies every pair of feet;
  150. now every pair of shoes overlies every pair of socks;
  151. now every pair of underpants overlies every seat;
  152. now every pair of pants overlies every pair of underpants;
  153. now every shirt overlies every foundation garment;
  154. now every foundation garment overlies every torso;
  155. now every jacket overlies every shirt;
  156.  
  157. Volume 5 - Some complex garments
  158.  
  159. A dress is a kind of garment. A dress-skirt is a kind of garment-piece. A dress-skirt is part of every dress.
  160.  
  161. A layering rule (this is the layering dresses rule):
  162. now every jacket overlies every dress;
  163. now every dress overlies every foundation garment;
  164. now every dress-skirt overlies every pair of underpants.
  165.  
  166. A bodysuit is a kind of garment. A bodysuit-bottom is a kind of garment-piece. A bodysuit-bottom is part of every bodysuit.
  167.  
  168. A layering rule (this is the layering bodysuits rule):
  169. now every shirt overlies every bodysuit;
  170. now every pair of pants overlies every bodysuit-bottom;
  171. now every dress overlies every bodysuit;
  172. now every dress-skirt overlies every bodysuit-bottom;
  173. now every bodysuit overlies every torso;
  174. now every bodysuit-bottom overlies every seat.
  175.  
  176. Volume 6 - Starting Play wearing Garments
  177.  
  178. To decide if (X - a garment) layers over (Y - a garment):
  179. if X covers Y, yes;
  180. if a garment-element which is a portion of X covers a garment-element which is a portion of Y, yes;
  181. no.
  182.  
  183. To decide which list of garments is the coverage-sorted (L - a list of garments):
  184. let L2 be a list of garments;
  185. while the number of entries of L is not 0:
  186. let the innermost be entry 1 of L;
  187. repeat with item running through L:
  188. if the innermost layers over the item, now the innermost is the item;
  189. add the innermost to L2;
  190. remove the innermost from L;
  191. decide on L2.
  192.  
  193. The dressing-person is a person that varies. [Workaround for the restriction on descriptions involving temporaries]
  194. When play begins (this is the set up clothing rule):
  195. follow the layering rulebook;
  196. Repeat with P running through persons wearing a garment:
  197. Now the dressing-person is P;
  198. let L be the coverage-sorted list of garments worn by the dressing-person;
  199. now all garments worn by P are carried by P;
  200. repeat with G running through L:
  201. silently try P wearing G.
  202.  
  203. Volume 7 - Outermost Garments
  204.  
  205. A garment can be outermost. [Outermost means that even if it's an undergarment, you still can't wear anything over it.]
  206.  
  207. Before an actor wearing a garment when the noun covers an outermost garment worn by the actor (this is the remove outermost garments before wearing others rule):
  208. while the actor bears an outermost garment (called the impediment) covered by the noun:
  209. report implicitly removing the impediment;
  210. silently try the actor taking off the impediment;
  211. if the actor wears the impediment, stop the action.
  212.  
  213. Layered Garments ends here.
  214.  
  215. ---- DOCUMENTATION ----
  216.  
  217. Layered Garments is an extension based upon the "What Not to Wear" example in the Inform Recipe Book.
  218.  
  219. The original example has some problems. The wearing and removing rules only work for the player, and the author forgot to make shirts overlie foundation garments. The overlying relation needs fast route-finding to be usable (even with only the sample clothing!). All characters need to begin nude. And the big problem is that jackets (which only cover the torso) interfere with removing or wearing underpants (covering only the seat). This happens because jackets overlie dresses which overlie underpants - using a transitive rule for regional coverage doesn't work well.
  220.  
  221. To fix the last problems, I have ended up creating a slightly more complex system, in which any garment that covers multiple body-parts is composed of multiple pieces. Fortunately, as long the game author is willing to work with the existing kinds of garments and body-parts, there should be no need to deal with the complexity directly.
  222.  
  223. The extension defines torsos, seats, and pairs of feet as the standard body-parts. This is vastly simplified from the original extension. Additional body-parts may be added as necessary, at the cost of having to define some additional pieces of garments to cover them.
  224.  
  225. Simple garments overlie only a single body-part. Several kinds of simple garments are predefined: Foundation garments (bras, camisoles, undershirts), shirts, underpants, pants, jackets, socks, and shoes.
  226.  
  227. Complex garments are composed of a main garment (covering a single body-part), and several garment-pieces which cover additional body-parts. The extension defines dresses (covering torsos and seats, on the same layer as shirts and pants) and bodysuits (covering the same, on the same layer as underwear).
  228.  
  229. In order to ensure a complete path for the overlying relation, the author must create at least one actual item for each of the simple garment kinds. If the author adds additional body-parts, ensure that a garment is created for each layer.
  230.  
  231. The extension, as the original example, contains an "Instead of taking inventory" rule. If you are writing your own inventory display, you will need to delist this rule and probably incorporate its logic into your own rule.
  232.  
  233. If the actor begins play wearing garments, a "When play begins" rule will strip them and re-wear all of the garments from innermost to outermost. This is necessary to set up the "underlying" relation. The author is responsible for ensuring that all initially-worn garments are compatible, otherwise there will be odd messages displayed at the beginning of the game.
  234.  
  235. Anything the player can wear needs to be created as a garment. It is possible to create a garment that doesn't overlie anything, which can then be worn regardless of other clothing. (e.g. just say "The necklace is a garment.")
  236.  
  237. Section: Defining new Complex Garments
  238.  
  239. Define the main garment. For each additional body-part it covers, define a garment-piece, and create an assembly.
  240.  
  241. A catsuit is a kind of garment. A pair of catsuit-pants is a kind of garment-piece. A pair of catsuit-feet is a kind of garment-piece. A pair of catsuit-pants and a pair of catsuit-feet are part of every catsuit.
  242.  
  243. Create "layering rules" to set up the proper overlying relations. For each piece (including the main garment), define which items it goes immediately over, and which go immediately over it. If two items cover the same body-part, but neither covers each other, they are considered the same layer. For this example, we will say that the torso portion of the catsuit (the main garment) goes directly over the skin, in the same layer as a foundation garment, the bottom portion of the catsuit can be worn over underpants and beneath pants, and the feet go underneath socks.
  244.  
  245. A layering rule:
  246. now every catsuit overlies every torso;
  247. now every pair of catsuit-pants overlies every pair of underpants;
  248. now every pair of pants overlies every pair of catsuit-pants;
  249. now every pair of catsuit-feet overlies every pair of feet;
  250. now every pair of socks overlies every pair of catsuit-feet.
  251.  
  252. Section: The donning and doffing activities
  253.  
  254. The actual mechanics of wearing and removing clothing are now covered by the "donning" and "doffing" activities. These activities are only carried out if the wearing/removal will go forward (i.e. during the "carry out" phase.) Any additional special behavior (but not text!) that needs to happen when wearing or removing clothes should take place in "after donning" and "after doffing" rules. The "donner" and the "doffer" are the persons who are wearing or will wear the item.
  255.  
  256. The reason for these activities is to allow other actions to cause clothing to be worn or removed without rewriting all the rules for each action. (In particular, "Adult Layered Garments" will define a "stripping it from" action allowing a person to remove *another* person's clothing.) If calling these activities in another action, ensure that the person who will wear the item is holding it before carrying out the activity.
  257.  
  258. "Don (a garment)" and "Doff (a garment)" phrases are defined to call the donning and doffing activities.
  259.  
  260. Section: Reporting implicit removal of something
  261.  
  262. Several of the Before rules automatically remove clothing that is in the way of whatever you are trying to wear or take off. These rules call the "reporting implicit removal" activity with the garment to be removed. The default is to say "(first removing [the impediment])". You can change this by adding rules for specific impediments or entirely replacing the standard reporting implicit removal rule.
  263.  
  264. The phrase "report implicitly removing (a garment)" will call the reporting activity.
  265.  
  266. Section: Defining new Body-parts
  267.  
  268. When defining a body-part, you also need to define garment-pieces for any garments which will cover that part. The necessary assembly rules and overlying rules have to be created to match. This example creates arms and sleeves to cover them - shirts and jackets have sleeves, but foundation garments and dresses do not.
  269.  
  270. A pair of arms is a kind of body-part. Shirt-sleeves are a kind of garment-piece. Shirt-sleeves are part of every shirt. Jacket-sleeves are a kind of garment-piece. Jacket-sleeves are part of every jacket.
  271. A layering rule: now every shirt-sleeves overlies every pair of arms; now every jacket-sleeves overlies every shirt-sleeves.
  272.  
  273. Don't forget to define appropriate garment-pieces for any new garments you've defined, too!
  274.  
  275. Catsuit-sleeves are a kind of garment-piece. Catsuit-sleeves are part of every catsuit. A layering rule: now every catsuit-sleeves overlies every pair of arms; now every shirt-sleeves overlies every pair of catsuit-sleeves.
  276.  
  277. Many variations are of course possible:
  278.  
  279. A long-sleeved dress is a kind of dress. Shirt-sleeves are part of every long-sleeved dress.
  280.  
  281.  
  282. Section: Considerations for further features
  283.  
  284. A reciprocal "incompatibility" relation to declare that some garments simply cannot be worn with other garments, even if their layering/coverage does not conflict. Example - you can't (or wouldn't) wear thick woolen socks with high-heeled pumps.
  285.  
  286. Supplying proper specifications for all the kinds
  287.  
  288. Section: Change Log
  289.  
  290. 1/130214
  291. - Original published version.
  292.  
  293. 2/130609
  294. - Realized the extension requires Plurality - added appropriate Include statement.
  295. - Removed unnecessary "head" body-part, which is not used by any currently-defined garment type.
  296. - Add clause to wearing rules so that the underlying relation is set up for body-parts when garments are worn over them.
  297.  
  298. 3/130609
  299. - Added a rule so garments worn at the start of the game are removed and re-worn in the proper order to set up the underlying relationships.
  300.  
  301. 4/130627
  302. - Complex garments added for the dress and bodysuit types.
  303.  
  304. 5/130701
  305. - Reworked the complex garments code completely, to allow reasonably easy extension of existing garment types. The layering rulebook was added. The "skirt" type was removed. Renamed from "Simplified Garments" to Layered Garments
  306.  
  307. 6/130705
  308. - Added "worn" definition for garment-elements.
  309. - Modified impedance relation with "prevents wearing" phrase so you can add specific rules which override the normal definition. Example "To decide whether (X - a skirted garment-element) prevents wearing (Y - a skirt-compatible garment): no."
  310.  
  311. 7/130717
  312. - Added "donning" and "doffing" activities so that other actions can safely wear and remove clothing.
  313.  
  314. 8/130718
  315. - Fixes minor bug with wearing and removing garment-pieces rules. (Wouldn't have effected most games, as garment-pieces are normally privately-named).
  316.  
  317. 9/130720
  318. - When reporting an impediment in before/check rules, ensures that only unconcealed garments are reported. If there's an invisible garment (would need to be defined by the author somehow, then the check rule will fail with "Something seems to be in the way..."
  319. - Added "Check wearing" rules for impediments, rather than assumming that the before rules would remove any.
  320. - Added "Reporting implicit removal" activity, so the author can either suppress the "(first removing the impediment)" message, or change it.
  321. - Added "To doff", "to don", "to report implicitly removing" phrases.
  322.  
  323. 10/130722
  324. - Changed the initial dressing code, and in particular "coverage-sorted" phrase, to be garments only, rather than garment-elements. (Due to bug discovered - "coverage-sorted" fails on non-garments).
  325. - Added "not worn" to various wearing rules - no point removing garments over something you're already wearing.
  326.  
  327. 11/130805
  328. - Fixed "every every" in catsuit example.
  329. - Slightly modified the definition of "unconcealed" to improve performance.
  330. - Added "equipped" definition and "bearing" relation - the latter replacing "sporting". These are generic and not specific to garment-elements.
  331. - renamed "Sections" to "Volumes"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement