luv

Workshop wiki

play.lisp

luvcraft/play.lisp

system luvcraft/core · 10 definitions · on GitHub

in-package#:luvcraft
defvar*session*nil"The live game session in this Lisp, or NIL."
defvar*checkpoint-writer*nil"The checkpoint writer for the world PLAY opened, or NIL."
defundefault-luvcraft-world-pathname

Return the pathname of the ordinary persistent luvcraft world.

merge-pathnames#P"luvcraft/worlds/default.sexp"
let
data-home
uiop:getenv"XDG_DATA_HOME"
ifdata-home
uiop:ensure-directory-pathname
pathnamedata-home
merge-pathnames#P".local/share/"
user-homedir-pathname
defunload-or-make-luvcraft-world
pathname

Read the persistent world at pathname, or make a new little world.

if
probe-filepathname
progn
formatt"Loading luvcraft world from ~A~%"pathname
progn
formatt"Creating luvcraft world at ~A~%"pathname
defvar*video-pathname*nil

A video file to play on a screen hanging in front of the player, or NIL.

play reads this so a live image can hang a film in the world without changing any call site: set it, stop-playing, and play again.

defunplay
&keytracy-pfullscreen-p
video-pathname*video-pathname*

Open the ordinary persistent game in this Lisp and return the session.

Load or create world-pathname, restore its saved camera and player, start checkpointing, and open the visible game window, on the whole display when fullscreen-p. *SESSION* names the live game for later SLY evaluations. stop-playing checkpoints and closes it.

when*session*
error"A game is already playing; call STOP-PLAYING first."
multiple-value-bind
worldresume-description
multiple-value-bind
cameraplayerselected-blockcarried
let
writer
sessionnil
unwind-protect
setfsession
start-luvcraft:providerprovider:title"luvcraft — walk, jump, mine, and build":worldworld:cameracamera:playerplayer:selected-blockselected-block:fullscreen-pfullscreen-p:video-pathnamevideo-pathname:quit-function
lambda
playing-session

request-luvcraft-quit already granted this worker sole ownership; do not recursively enter stop-luvcraft.

let
playing-writerwriter
unwind-protect-releasing
releasing:playing-session-publication
when
eqplaying-session*session*
releasing:checkpoint-writer
whenplaying-writer
:checkpoint-writerwriter
unlesssession

The films the player was carrying come back into the bag, and the ones standing beside walls light them again.

dolist
blockcarried
add-block-to-inventory
luvcraft-session-inventorysession
block1
defunstop-playing

Checkpoint and close the game play opened, releasing its resources.

*SESSION* is cleared whether or not the release succeeds, so a failed teardown cannot leave the image believing a game is still playing. The failure itself is not swallowed: stop-luvcraft closes the window first and then signals what went wrong, and that condition comes out of here.

defunshader-knob-p

Whether knob has been folded into a live pipeline's source, so that turning it rebuilds one. Answered for the live session.

and
boundp'*session*
*session*
some
lambda
pipeline
assoc
knob-nameknob
live-shader-pipeline-attempted-source-valuespipeline

--------------------------------------------------------------------- The verbs the metabar offers.

define-actionfocus-target
:label"focus what the crosshair is on"

Whatever gadget offered this button is itself the focus at the moment it is pressed; it must stand down before the world can be looked at.

define-actionquit
:label"quit the game"
unless
close-canvas
luvcraft-session-canvassession