*Finally* allow “using” an item @w@
This commit is contained in:
parent
63515434d0
commit
4baaa8d04a
|
@ -39,7 +39,7 @@ overheat, or something ¯\_(ツ)_/¯"
|
||||||
(let ((state-result
|
(let ((state-result
|
||||||
(apply (car states) (cons matrix state-params)))) ;; Run the last-added state-loop.
|
(apply (car states) (cons matrix state-params)))) ;; Run the last-added state-loop.
|
||||||
(✎:print-screen-matrix (✎:matrix-delta last-matrix matrix)) ;; Print its results.
|
(✎:print-screen-matrix (✎:matrix-delta last-matrix matrix)) ;; Print its results.
|
||||||
(format *error-output* "~S~%" state-result)
|
;; (format *error-output* "~S~%" state-result)
|
||||||
(force-output)
|
(force-output)
|
||||||
(state-loop
|
(state-loop
|
||||||
(cond ((listp state-result)
|
(cond ((listp state-result)
|
||||||
|
|
|
@ -631,6 +631,13 @@ avoid triggering this."
|
||||||
(flashback-casino-dialogue map)))
|
(flashback-casino-dialogue map)))
|
||||||
|
|
||||||
|
|
||||||
|
(defun cry (&optional map ring)
|
||||||
|
(nconc (list :drop 1)
|
||||||
|
(make-dialogue-state
|
||||||
|
map
|
||||||
|
(start-dialogue (mumble 'player :en "FUCK")))))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
;;; ———————————————————————————————————
|
;;; ———————————————————————————————————
|
||||||
;;; Main-menu data
|
;;; Main-menu data
|
||||||
|
|
|
@ -36,7 +36,6 @@ exceeds the size of SEQUENCE, the returned subsequence is equivalent to SEQUENCE
|
||||||
"Convert a list of items’ plists (that one might get from OVERWORLD’s map
|
"Convert a list of items’ plists (that one might get from OVERWORLD’s map
|
||||||
:ITEMS) into a pretty and presentable menu-grid of items, for use with
|
:ITEMS) into a pretty and presentable menu-grid of items, for use with
|
||||||
📋:MENU-STATE(-*)."
|
📋:MENU-STATE(-*)."
|
||||||
(format *error-output* "ITEMS ~S~%" item-plists)
|
|
||||||
(let* ((label-width 7)
|
(let* ((label-width 7)
|
||||||
(border-width 2)
|
(border-width 2)
|
||||||
;; Weird bounding, whoops! I’m so clumsy, it’s endearing instead of just annoying! … Right? =w=”
|
;; Weird bounding, whoops! I’m so clumsy, it’s endearing instead of just annoying! … Right? =w=”
|
||||||
|
@ -54,7 +53,7 @@ exceeds the size of SEQUENCE, the returned subsequence is equivalent to SEQUENCE
|
||||||
(getf (cdr item) :name-eo)))
|
(getf (cdr item) :name-eo)))
|
||||||
:selected (and (eq row 0) (eq column 0))
|
:selected (and (eq row 0) (eq column 0))
|
||||||
:selection (if (and (eq row 0) (eq column 0)) 100 0)
|
:selection (if (and (eq row 0) (eq column 0)) 100 0)
|
||||||
:return nil
|
:submenu 't
|
||||||
:row row)
|
:row row)
|
||||||
(cdr item)))
|
(cdr item)))
|
||||||
item-plists)))
|
item-plists)))
|
||||||
|
@ -64,13 +63,42 @@ exceeds the size of SEQUENCE, the returned subsequence is equivalent to SEQUENCE
|
||||||
;;; ———————————————————————————————————
|
;;; ———————————————————————————————————
|
||||||
;;; Inventory loop logic
|
;;; Inventory loop logic
|
||||||
;;; ———————————————————————————————————
|
;;; ———————————————————————————————————
|
||||||
(defun inventory-state-update (map inventory-menu)
|
(defun submenu (item)
|
||||||
|
"Create a ITEM’s submenu, from its plist."
|
||||||
|
(nconc (when (getf item :use)
|
||||||
|
(list
|
||||||
|
(list :en "Use it!"
|
||||||
|
:eo "Uzi ĝin!"
|
||||||
|
:selected 't :selection 100
|
||||||
|
:use 't)))
|
||||||
|
(list
|
||||||
|
(list :en "Lose it!"
|
||||||
|
:eo "Ne!"
|
||||||
|
:use nil))))
|
||||||
|
|
||||||
|
|
||||||
|
(defun inventory-state-update (map inventory-menu submenu)
|
||||||
"The input-taking/logic-handling component of the inventory state-function.
|
"The input-taking/logic-handling component of the inventory state-function.
|
||||||
Part of INVENTORY-STATE."
|
Part of INVENTORY-STATE."
|
||||||
(if (📋:menu-state-update inventory-menu)
|
(let ((menu-return (📋:menu-state-update (if submenu submenu inventory-menu)))
|
||||||
(list :map map :inventory inventory-menu)
|
(selected-item (📋:selected-menu-item inventory-menu)))
|
||||||
(values nil
|
(cond
|
||||||
(list :map map))))
|
;; Display the pop-up menu when an item is selected.
|
||||||
|
((and (listp menu-return) (getf menu-return :submenu))
|
||||||
|
(list :parameters (list :map map :inventory inventory-menu
|
||||||
|
:submenu (submenu selected-item))))
|
||||||
|
;; User decided to use the item, let’s go!
|
||||||
|
((and (listp menu-return) (getf menu-return :use) (getf selected-item :use))
|
||||||
|
(funcall (…:string->symbol (getf selected-item :use)) map selected-item))
|
||||||
|
;; User decided not to use the item.
|
||||||
|
((and (listp menu-return) (member :use menu-return))
|
||||||
|
(list :parameters (list :map map :inventory inventory-menu)))
|
||||||
|
;; Return the menu itself, if non-nil.
|
||||||
|
(menu-return
|
||||||
|
menu-return)
|
||||||
|
;; If menu-return was non-nil, the user left the menu. Let’s leave inventory!
|
||||||
|
('t
|
||||||
|
(list :drop 1 :parameters (list :map map))))))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -92,27 +120,28 @@ the bottom of the screen."
|
||||||
'(:x 1 :y 18) :width 70)))
|
'(:x 1 :y 18) :width 70)))
|
||||||
|
|
||||||
|
|
||||||
(defun inventory-state-draw (matrix items)
|
(defun inventory-state-draw (matrix items submenu)
|
||||||
"The drawing component of the inventory state-function.
|
"The drawing component of the inventory state-function.
|
||||||
Part of INVENTORY-STATE."
|
Part of INVENTORY-STATE."
|
||||||
(📋:menu-state-draw matrix items)
|
(📋:menu-state-draw matrix items)
|
||||||
(render-selected-item matrix items))
|
(render-selected-item matrix items)
|
||||||
|
(when submenu
|
||||||
|
(📋:menu-state-draw matrix submenu)))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
;;; ———————————————————————————————————
|
;;; ———————————————————————————————————
|
||||||
;;; Inventory loop
|
;;; Inventory loop
|
||||||
;;; ———————————————————————————————————
|
;;; ———————————————————————————————————
|
||||||
(defun inventory-state (matrix &key map inventory)
|
(defun inventory-state (matrix &key map inventory (submenu nil))
|
||||||
"A state-function for use with STATE-LOOP."
|
"A state-function for use with STATE-LOOP."
|
||||||
(sleep .02)
|
(sleep .02)
|
||||||
(inventory-state-draw matrix inventory)
|
(inventory-state-draw matrix inventory submenu)
|
||||||
(inventory-state-update map inventory))
|
(inventory-state-update map inventory submenu))
|
||||||
|
|
||||||
|
|
||||||
(defun make-inventory-state (map)
|
(defun make-inventory-state (map)
|
||||||
"Return a state-function for inventory-listing, for use with STATE-LOOP."
|
"Return a state-function for inventory-listing, for use with STATE-LOOP."
|
||||||
(lambda (matrix &key (map map) (inventory (items->menu-plist (gethash :items map))))
|
(lambda (matrix &key (map map) (submenu nil) (inventory (items->menu-plist (gethash :items map))))
|
||||||
(apply #'🎒:inventory-state
|
(apply #'🎒:inventory-state
|
||||||
(list matrix :map map :inventory inventory))))
|
(list matrix :map map :inventory inventory :submenu submenu))))
|
||||||
|
|
||||||
|
|
|
@ -145,9 +145,7 @@ That is, 0 for non-selected items and 100 for selected items."
|
||||||
(selected-item (nth (selected-menu-item-position menu-plist)
|
(selected-item (nth (selected-menu-item-position menu-plist)
|
||||||
menu-plist))
|
menu-plist))
|
||||||
(func (getf selected-item :function))
|
(func (getf selected-item :function))
|
||||||
(exec (getf selected-item :exec))
|
(exec (getf selected-item :exec)))
|
||||||
(return-val-p (member :return selected-item))
|
|
||||||
(return-val (getf selected-item :return)))
|
|
||||||
(case (getf input :semantic)
|
(case (getf input :semantic)
|
||||||
('⌨:→ (progn (select-right-menu-item menu-plist)
|
('⌨:→ (progn (select-right-menu-item menu-plist)
|
||||||
't))
|
't))
|
||||||
|
|
|
@ -209,7 +209,7 @@ Returns parameters to be used in the next invocation of OVERWORLD-STATE."
|
||||||
(interactee-id (car interactee))
|
(interactee-id (car interactee))
|
||||||
(interaction (getf (cdr interactee) :interact)))
|
(interaction (getf (cdr interactee) :interact)))
|
||||||
(if interaction
|
(if interaction
|
||||||
(apply (string->symbol interaction) (list map interactee-id))
|
(apply (…:string->symbol interaction) (list map interactee-id))
|
||||||
(list :parameters (list :map map)))))
|
(list :parameters (list :map map)))))
|
||||||
('⌨:❎
|
('⌨:❎
|
||||||
(list :function (🎒:make-inventory-state map)))
|
(list :function (🎒:make-inventory-state map)))
|
||||||
|
@ -242,7 +242,7 @@ Very kindly removes a list of parameters to be returned by the overworld state-f
|
||||||
(let* ((coords (getf-entity-data map '✿:player :coords))
|
(let* ((coords (getf-entity-data map '✿:player :coords))
|
||||||
(trigger (trigger-at-coords map (list :x (getf coords :x) :y (getf coords :y)))))
|
(trigger (trigger-at-coords map (list :x (getf coords :x) :y (getf coords :y)))))
|
||||||
(if (and trigger (getf trigger :function))
|
(if (and trigger (getf trigger :function))
|
||||||
(apply (string->symbol (getf trigger :function))
|
(apply (…:string->symbol (getf trigger :function))
|
||||||
(list map trigger))
|
(list map trigger))
|
||||||
(list :parameters (list :map map)))))
|
(list :parameters (list :map map)))))
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ character-scale world coordinates in plist form."
|
||||||
(when (not (tiled-rectangle-p tiled-obj))
|
(when (not (tiled-rectangle-p tiled-obj))
|
||||||
(let ((properties (cl-tiled:properties tiled-obj)))
|
(let ((properties (cl-tiled:properties tiled-obj)))
|
||||||
(append
|
(append
|
||||||
(list (string->symbol (gethash "id" properties)))
|
(list (…:string->symbol (gethash "id" properties)))
|
||||||
(loop for key being the hash-keys in properties
|
(loop for key being the hash-keys in properties
|
||||||
for val being the hash-values in properties
|
for val being the hash-values in properties
|
||||||
collect (intern (string-upcase key) "KEYWORD")
|
collect (intern (string-upcase key) "KEYWORD")
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#:plist=
|
#:plist=
|
||||||
#:incf-0
|
#:incf-0
|
||||||
#:at-least #:at-most
|
#:at-least #:at-most
|
||||||
|
#:string->symbol
|
||||||
#:system-language #:langcode->keysym #:getf-lang))
|
#:system-language #:langcode->keysym #:getf-lang))
|
||||||
|
|
||||||
(defpackage :flora-search-aurora.input
|
(defpackage :flora-search-aurora.input
|
||||||
|
@ -74,7 +75,6 @@
|
||||||
#:world-coords->screen-coords
|
#:world-coords->screen-coords
|
||||||
#:world-coords-chunk
|
#:world-coords-chunk
|
||||||
#:map->plist #:plist->map
|
#:map->plist #:plist->map
|
||||||
#:string->symbol
|
|
||||||
#:save-map-to-file))
|
#:save-map-to-file))
|
||||||
|
|
||||||
(defpackage :flora-search-aurora.overworld
|
(defpackage :flora-search-aurora.overworld
|
||||||
|
|
|
@ -403,6 +403,7 @@ Fojfoje mi ja ŝatas mian fakon, mdr.</property>
|
||||||
<property name="name-en" value="ring"/>
|
<property name="name-en" value="ring"/>
|
||||||
<property name="name-eo" value="ringo"/>
|
<property name="name-eo" value="ringo"/>
|
||||||
<property name="reaction-face" value=">_<"/>
|
<property name="reaction-face" value=">_<"/>
|
||||||
|
<property name="use" value="✿:cry"/>
|
||||||
</properties>
|
</properties>
|
||||||
<point/>
|
<point/>
|
||||||
</object>
|
</object>
|
||||||
|
|
14
util.lisp
14
util.lisp
|
@ -123,8 +123,20 @@ minimum returns your more pitiful of moments."
|
||||||
|
|
||||||
|
|
||||||
;;; ———————————————————————————————————
|
;;; ———————————————————————————————————
|
||||||
;;; Linguistic affirs
|
;;; Linguistic & symbolic affirs
|
||||||
;;; ———————————————————————————————————
|
;;; ———————————————————————————————————
|
||||||
|
(defun string->symbol (string)
|
||||||
|
"Given a STRING with an optionally defined package (e.g., “package:symbol”),
|
||||||
|
return it as an appopriate symbol."
|
||||||
|
(let* ((split (str:split ":" (string-upcase string)))
|
||||||
|
(package (when (eq (length split) 2)
|
||||||
|
(car split)))
|
||||||
|
(symbol (or (cadr split) (car split))))
|
||||||
|
(if package
|
||||||
|
(intern symbol package)
|
||||||
|
(intern symbol))))
|
||||||
|
|
||||||
|
|
||||||
(defun langcode->keysym (str)
|
(defun langcode->keysym (str)
|
||||||
"Given a language’s code (es/cz/it/etc.), return a corresponding key symbol,
|
"Given a language’s code (es/cz/it/etc.), return a corresponding key symbol,
|
||||||
if the language is among the supported. Otherwise, nil."
|
if the language is among the supported. Otherwise, nil."
|
||||||
|
|
Ŝarĝante…
Reference in New Issue