SWC LISP/Modules

From Star Wars Combine :: Game Guide
Jump to: navigation, search

See the Rules Page on SWC for additional explanations.

Two new language constructs are load to use a module and module-export called from within a module (only useful here!) to declare a symbol to be made available outside the module. Modules have private internal state allowing for personal variables, etc.

swclib

(load "swclib")

Contact: Selatos; Kay Dallben

funlib

(load "funlib")

Contact: Selatos, Kay Dallben

mathematics

(load "mathematics")

Contact: Kay Dallben

timelib

(load "timelib")

Contact: Kay Dallben, mackaybre at gmail dot com

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

Keyboard-Al Sayif

This Script Module (and paired NPC-Script requirements) enables a character-by-character input of a string into a script.

NPC Script Requirements

;;;; ---------------------------------------------
;; Corresponding Content for NPC/Entity
(load "Keyboard-Al Sayif" "")
(load "swclib")
(bind-keyboard-mself (get-id self) 'npc)
(bind-keyboard-convo say say-c describe describe-c ooc ooc-c)
(bind-keyboard-responses add-action add-response add-text)
(bind-keyboard-utils clear-window)
(defun oncancel
; Called when you hit the Cancel Button. Edit as needed.
(ooc "Cancelled Keyboard Input."))
(defun onfinish
; called when user clicks the Enter button. Edit as needed.
(clear-window)
(say (myconcat "Well it's very nice to meet you, Mr. " (get-keyboard-response))))
(bind-keyboard-callbacks onfinish oncancel)
(defun start ;; Example to go straight into it. Edit as needed, or just use start-keyboard.
(describe "Enter your input on the keypad. As you click the screen will update.")
(start-keyboard))
;;;; ---------------------------------------------

start-keyboard

  • clears the window and starts the Keyboard Input script: Asks for input character by character. CAPS toggles between UPPERCASE and lowercase for letter, BACK removes the last-entered character, CLEAR clears the input entirely, ENTER saves the input and calls `onfinish`, CANCEL saves the input and calls `oncancel`

get-keyboard-response

  • returns a string of the saved input from the keyboard.

COMING SOONTM

start-keypad

  • clears the window and starts the Keypad Input script: Asks for input character by character (numbers 0 - 9 only). BACK removes the last-entered character, CLEAR clears the input entirely, ENTER saves the input and calls `onfinish`, CANCEL saves the input and calls `oncancel`

Contact: Kay Dallben

input-general

Very similar to Keyboard, but this one allows you to send an arbitrary keyset (in the form of a list of strings) to be the options. This can be numbers only, letters, or even whole words. The Keyset must be a list of strings. Using return functions during the same session, you can obtain the results in either hyphen-separated String format or a list of entries.

NPC Script Requirements

;;;; ---------------------------------------------
;; Corresponding Content for NPC/Entity
(load "input-general")
(load "swclib")
(bind-ninp-mself (get-id self) 'npc)
(bind-ninp-convo say say-c describe describe-c ooc ooc-c)
(bind-ninp-responses add-action add-response add-text)
(bind-ninp-utils clear-window)
(defun oncancel
; Called when you hit the Cancel Button. Edit as needed.
(ooc "Cancelled Input."))
(defun onfinish
; called when user clicks the Enter button. Edit as needed.
(clear-window)
(say (myconcat "The code you provided was: " (get-input-str))))
(bind-ninp-callbacks onfinish oncancel)
(defun start
;; Example to go straight into it.
(start-n-input `("Red" "Blue" "Yellow") "Provide a code sequence made up of the following colours:" ))
;;;; ---------------------------------------------

start-n-input

  • keyset (list) optional:::display-instructions(string) optional:::default-input(list)
  • clears the window and starts the input script with the list of available options.
  • allows user to input an unlimited amount of each key.
  • auto-adds the usual controlling options: BACK removes the last-entered key, CLEAR clears the input entirely, ENTER saves the input and calls `onfinish`, CANCEL saves the input and calls `oncancel`
  • displays the provided instructions or "Input:" if nothing is provided.
  • starts with the provided default-input or `empty` if none provided.

Example: (start-n-input `("Red" "Yellow" "Blue") "Create the desired code from the following possible choices:")

start-nex-input

  • keyset (list) optional:::display-instructions(string) optional:::default-input(list)
  • clears the window and starts the input script with the list of available options.
  • the user may select each key in keyset only once. (IE: Use for non-repeating options, manual re-ordering of lists, etc.)
  • auto-adds the usual controlling options: BACK removes the last-entered key, CLEAR clears the input entirely, ENTER saves the input and calls `onfinish`, CANCEL saves the input and calls `oncancel`
  • displays the provided instructions or "Input:" if nothing is provided.
  • starts with the provided default-input or `empty` if none provided.

Example: (start-nex-input `("Red" "Yellow" "Blue") "Rank these colours in order from your most favourite to your least favourite:")

get-input-str

  • returns a string of the saved input from the active session (IE: as it it shown during input)

Example: Keyset: `("Red" "Yellow" "Blue") Input shows Blue-Blue-Yellow, will return: "Blue-Blue-Yellow")

get-input-list

  • returns a list of the input (letter by letter or entry-by-entry) from the active session.

Example: Keyset: `("Red" "Yellow" "Blue") Input shows Blue-Blue-Yellow, will return: `("Blue" "Blue" "Yellow")


Contact: Kay Dallben

display-funs

A small module for the purposes of passing lists of say, ooc, describe, or lists of add-response, add-action, add-text statements to be evaluated. Should help in situations where you want to dynamically create options or speeches, for example multi-level option lists, etc.

NB: Right now the batch say/etc. seems to break at about 90 elements, and that's really laggy so careful with your spam.

---------------------------------------------

Functions available for use:

display-element disp-list

  • disp-list is a list in the form of:
(list stringCode (list say say-c describe describe-c ooc ooc-c))
  • I recommend setting up in your script module or NPC/Item script
(defvar dfuns (list say say-c describe describe-c ooc ooc-c)) and/or a wrapper function
(defun (disp string-code) (display-element (list string-code dfuns))
  • NB: not particularly useful except in conjunction with script-generated strings that might be of any of the forms.

disp-factory disp-strings funclist

  • disp-strings is a list in the form (list "$s Say This" "$d Describe That" "$o OOC The other Thing" )
  • funclist is the dfuns mentioned above (list say say-c describe describe-c ooc ooc-c)

NOTE: for both display-element and disp-factory, the strings use prefixes: "$s " is say, "$sc " is say-c, "$d " is describe, "$dc " is describe-c "$o " is ooc, "$oc " is ooc-c.


show-option optns

  • displays the option.
  • options is a list of an option-list and the list of option funs (list add-response add-action add-text)
  • option-list example (list "^r I like cheese." likes-cheese), where `likes-cheese` is a no-parameter function defined in your script.
  • again, prefixes used are ^r ^a ^t for response, action, text respectively. Make sure you put a space between the prefix and the Label text.

option-factory list-of-option-lists optn-funs

  • takes this list of option-lists and prints out all the options from same.
  • list-of-option-lists is a list of lists of option-lists.
Example: (list `("^r I like cheese." ,likes-cheese) `("^a leave." ,leave))
  • again optn-funs is the (list add-response add-action add-text). defvar it for repetition or wrap the function in your script/SM.

@TODO: create filtering/searching functions to parse incoming lists (especially of says, oocs, describes) and combine those that can be combined (ie if the list has a say followed by a say-c, they should be combined into a single 'say').
@TODO: further functions to assist in speedy creation of the requisite lists.

Contact: Kay Dallben