Difference between revisions of "SWC LISP/Modules"

From Star Wars Combine :: Game Guide
Jump to: navigation, search
(Created page with "==Public Script Modules== See the Rules Page on SWC for additional explanation. ===swclib=== (load "swclib") <b>is-unharmed?</b> <i>player-NPC-object</i> - returns #t if <i...")
 
(KayD-StringShortcuts)
Line 67: Line 67:
  
 
===KayD-StringShortcuts===
 
===KayD-StringShortcuts===
(load "KayD-StringShortcuts")<br />
+
This library was removed as module and cannot be loaded. However, it is possible to use the functions by copying/pasting them.
NOTE: This lib was removed and cannot be loaded. It is possible to use the functions by copying/pasting them.
+
These functions insert appropriate pronoun string based on gender.
  
General Descrip: For inserting appropriate pronoun string based on gender.
+
  (defun (female? (who self))
 +
    (cond
 +
      [(eq? (get-gender who) "female") #t]
 +
      [#t #f]))
  
<b>heshe</b> <i>player-NPC-object</i>
+
(defun (male? (who self))
EG: (say (concat "Yes, " (heshe (get-npc 54486)) " is pretty silly.")) -> "Yes, he is pretty silly."
+
    (cond
EG: (describe (concat (HerHis self) " gun points directly at you.")) -> Her gun points directly at you.
+
      [(eq? (get-gender who) "male") #t]
 +
      [#t #f]))
  
<b>HeShe</b> <i>player-NPC-object</i>
+
(defun (HeShe? (who self))
 +
    (cond
 +
      [(female? who) "She"]
 +
      [#t "He"]))
  
<b>herhis</b> <i>player-NPC-object</i>
+
(defun (heshe? (who self))
 +
    (cond
 +
      [(female? who) "she"]
 +
      [#t "he"]))
  
<b>HerHis</b> <i>player-NPC-object</i>
+
(defun (HerHis? (who self))
 +
    (cond
 +
      [(female? who) "Her"]
 +
      [#t "His"]))
  
<b>herhim</b> <i>player-NPC-object</i>
+
(defun (herhis? (who self))
 +
    (cond
 +
      [(female? who) "her"]
 +
      [#t "his"]))
  
<b>HerHim</b> <i>player-NPC-object</i>
+
(defun (HerHim? (who self))
 +
    (cond
 +
      [(female? who) "Her"]
 +
      [#t "Him"]))
  
Contact: Kay Dallben
+
(defun (herhim? (who self))
 +
    (cond
 +
      [(female? who) "her"]
 +
      [#t "him"]))
 +
 
 +
Examples:
 +
* (say (concat "Yes, " (heshe (get-npc 54486)) " is pretty silly.")) -> "Yes, he is pretty silly."
 +
* (describe (concat (HerHis self) " gun points directly at you.")) -> Her gun points directly at you.
 +
* <b>heshe</b> <i>player-NPC-object</i>
 +
* <b>HeShe</b> <i>player-NPC-object</i>
 +
* <b>herhis</b> <i>player-NPC-object</i>
 +
* <b>HerHis</b> <i>player-NPC-object</i>
 +
* <b>herhim</b> <i>player-NPC-object</i>
 +
* <b>HerHim</b> <i>player-NPC-object</i>
  
  
 
[[Category:SWC LISP]]
 
[[Category:SWC LISP]]

Revision as of 11:32, 14 September 2018

Public Script Modules

See the Rules Page on SWC for additional explanation.


swclib

(load "swclib")

is-unharmed? player-NPC-object - returns #t if player-NPC-object's HP-Status-Text is "unharmed" EG: (is-unharmed? character) -> #t

is-slightly-wounded? player-NPC-object - returns #t if player-NPC-object's HP-Status-Text is "slightly wounded"

is-wounded? player-NPC-object - returns #t if player-NPC-object's HP-Status-Text is "wounded"

is-badly-wounded? player-NPC-object - returns #t if player-NPC-object's HP-Status-Text is "badly wounded"

Contact: Selatos; Kay Dallben

funlib

(load "funlib")

join separatorCharacter list - Combine the elements of list with the separatorCharacter to form a string EG: (join ", " (list "Green" "Blue" "Yellow")) -> "Green, Blue, Yellow,"

map function list - Call function for each member of list and return the list of results. E.g. (map (lambda (x) (+ x 2)) (list 1 0 4) ) -> (3 2 7)

apply-foreach function list - Call function for each member of list but do not return results. e.g. (apply-foreach (lamda (x) (say x)) (list "I like" "cheesy poofs." "Do you?")) -> I like cheesy poofs. Do you?

append list element - adds element to the end of list e.g. (append (list 1 2) 3) -> (1 2 3)

reduce function init list - reduce a list to a single value, using the combiner function provided, which function takes two inputs init and (car list) e.g. (reduce (lamda (x y) (+ x (* 2 y))) 0 (list 1 2 3)) -> (((0 + 2*1) + (2*2)) + (2*3)) -> 12

repeat-fn function NumTimes object - repeat function Numtimes on object e.g. (repeat (lamda (x) (+ x 1)) 4 0) -> 4

eq-lists? listA listB - preposition: is listA equal to listB -> are all elements of A = all elements of B. - Does NOT currently take into account lists of lists, so just 1D lists atm. e.g. (eq-lists? `(a b c) `(d e f)) -> #f (eq-lists? `(a b c) `(a b c)) -> #t (eq-lists? `(a b c) `( `(a) b c)) -> Error.

neq? atomA atomB - preposition: is atomA NOT equal to atomB e.g. (neq? 1 2) -> #t

KayD-StringShortcuts

This library was removed as module and cannot be loaded. However, it is possible to use the functions by copying/pasting them. These functions insert appropriate pronoun string based on gender.

(defun (female? (who self))
   (cond
      [(eq? (get-gender who) "female") #t]
      [#t #f]))
(defun (male? (who self))
   (cond
      [(eq? (get-gender who) "male") #t]
      [#t #f]))
(defun (HeShe? (who self))
   (cond
      [(female? who) "She"]
      [#t "He"]))
(defun (heshe? (who self))
   (cond
      [(female? who) "she"]
      [#t "he"]))
(defun (HerHis? (who self))
   (cond
      [(female? who) "Her"]
      [#t "His"]))
(defun (herhis? (who self))
   (cond
      [(female? who) "her"]
      [#t "his"]))
(defun (HerHim? (who self))
   (cond
      [(female? who) "Her"]
      [#t "Him"]))
(defun (herhim? (who self))
   (cond
      [(female? who) "her"]
      [#t "him"]))

Examples:

  • (say (concat "Yes, " (heshe (get-npc 54486)) " is pretty silly.")) -> "Yes, he is pretty silly."
  • (describe (concat (HerHis self) " gun points directly at you.")) -> Her gun points directly at you.
  • heshe player-NPC-object
  • HeShe player-NPC-object
  • herhis player-NPC-object
  • HerHis player-NPC-object
  • herhim player-NPC-object
  • HerHim player-NPC-object