17 - Goblin racing toy.
[email protected]
I borrowed Pete's truck yesterday. I had to shoo
away a couple of gnomes sleeping in the front
seat, and then I go for a grocery run down to the
Save-Mor. When I get back, I swing by Leanne and
her mom's unit to drop off some food and naloxone
and stuff. Leanne is a super smart kid, and I wish
she were in real school. She actually has a
working computer in their place, a real one with a
keyboard, and she's really good with it from what
I can tell. She knows I go on the inter net some
times to post things like this, and so she gives
me this program she made to share with you all out
there. We didn't have the right cable to connect
my phone, so she had to write it out onto a couple
of sheets of notebook paper, and later I tapped it
all back into my phone.
And so here is her toy she made. I hope I typed it
all in right; some of the pencil got smudged when
page 2 soaked up some gnome piss from the seat of
Pete's truck on the way home. Oh yeah, and she
told me to tell you that it runs in "e-max". I
think that's what she said.
-
(defun lg-goblin-racing ()
"racing"
(interactive)
(defun lg-goblin-racing-redraw ()
(interactive)
(let ((buffer-read-only nil))
(erase-buffer)
(dotimes (i (length racers))
(if (= winner i)
(insert " winner ")
(insert " "))
(insert "|")
(let ((place (plist-get (nth i racers) :place)))
(dotimes (j (- length place)) (insert "."))
(insert (plist-get (nth i racers) :symbol))
(dotimes (j (- place 1)) (insert "."))
(newline)))
(insert "keys: r ... q")))
(defun lg-goblin-run-race ()
(interactive)
(let ((out nil))
(while (not out)
(dotimes (i (length racers))
(let ((racer (nth i racers)))
(when (>= (random 10) 6)
(plist-put racer :speed (+ 1 (random 4))))
(when (= 0 (mod counter (plist-get racer :speed)))
(plist-put racer :place (+ 1 (plist-get racer :place))))
(when (= (plist-get racer :place) length)
(setq winner i)
(setq out t))))
(setq counter (+ counter 1))
(lg-goblin-racing-redraw)
(when (not (sit-for 0.1)) (setq out t)))))
(defun lg-goblin-racing-reset ()
(set (make-local-variable 'winner) -1)
(set (make-local-variable 'length) 40)
(set (make-local-variable 'racers)
(list
(list :symbol 128127 :speed 2
:place 1)
(list :symbol 128127 :speed 2
:place 1)
(list :symbol 128127 :speed 2
:place 1)
(list :symbol 128127 :speed 2
:place 1)))
(set (make-local-variable 'counter ) 1)
(lg-goblin-racing-redraw))
(define-derived-mode lg-goblin-racing-mode
special-mode "lg-goblin-racing"
"Special mode for racing toy."
(setq cursor-type nil)
(lg-goblin-racing-reset))
(setq lg-goblin-racing-mode-map
(let ((map (make-sparse-keymap)))
(define-key map "r"
(lambda() (interactive)
(lg-goblin-racing-reset)
(lg-goblin-run-race)))
map))
(switch-to-buffer "*lg-goblin-racing*")
(lg-goblin-racing-mode))
-