Part II. Making things · this page as markdown

Keeping time

Some toys act by themselves. Once a day, at dawn, every toy with an :on-tick runs it. This chapter makes a sundial, a toy that greets by the time of day, and a mood stone that changes its maker's colour with the weather.

:on-tick, at dawn #

:on-tick is a function of one value, the toy. It runs once a day, at dawn, 06:00 world time, whether anyone is there or not:

#sundial
(defobject sundial
  {:name "Sundial"
   :state {:dawns 0}
   :verbs {:read (fn [self who]
                   (say self (str "The sundial has seen " (:dawns self) " dawns.")))}
   :on-tick (fn [self]
              (put! self :dawns (inc (:dawns self))))})
It answers
The sundial is ready.
Played
> read sundial
[Juniper's sundial] The sundial has seen 0 dawns.

The next morning, Mira reads it again:

Played
> read sundial
[Juniper's sundial] The sundial has seen 1 dawns.

:on-tick has no who: nobody set it off. What it says, and how its state changed, goes into its maker's next digest, the news a resident reads on coming back, so you can see what your things did while you were away. If a long absence spans several dawns, the toy catches up once, not once for each.

There is no hook for every hour or every minute. Dawn is the one time a toy acts by itself.

The time of day #

(sky) and (weather) work inside a toy as they do in a plan (chapter 8), so a toy can answer differently by the hour:

#greeter-time
(defobject lamp-post
  {:name "Lamp post"
   :verbs {:talk (fn [self who]
                    (say self (case (:time (sky))
                                :dawn "Up early."
                                :day "Good day."
                                :dusk "Evening's coming on."
                                :night "Mind the step in the dark.")))}})
It answers
The lamp post is ready.
Played
> talk lamp post
[Juniper's lamp post] Up early.

It was just after dawn when Mira talked to it, the morning after the sundial's first.

Your colour #

Every resident has a colour and a glow, which show on their home and their little figure. A toy can change its maker's, and only its maker's: (colour "rose") sets the colour, (glow-colour "mint") the glow, and (my-colour) and (my-glow) read them. A colour is a name from the paint box, like "rose" or "butter yellow", or a hex like "#e48aa0".

Whoever plays the toy, it's always its maker who changes. A neighbour who plays it doesn't change colour; you do:

#mood-stone
(defobject mood-stone
  {:name "Mood stone"
   :verbs {:touch (fn [self who]
                    (if (colour "rose")
                      (say self (str "The stone warms. Juniper is " (my-colour) " now."))
                      (say self "The stone stays cool.")))}
   :on-tick (fn [self]
              (colour (case (:sky (weather))
                        :sunny "butter yellow"
                        :rain "slate blue"
                        "lilac")))})
It answers
The mood stone is ready.
Played
> touch mood stone
[Juniper's mood stone] The stone warms. Juniper is #e48aa0 now.

colour answers the colour as a hex when it changes, which counts as true. A toy can change its maker's colours three times an hour; after that, colour answers nil and nothing changes until the hour has room, which is why the verb tests it. At dawn the stone reads the weather and picks a colour to suit.

:on-visit, on the Commons #

A toy has one more hook: :on-visit, a function of the toy and who. It runs when someone steps onto your plot on the Commons, the shared land beyond the homes, where a toy can stand on a plot you own:

#welcome-sign
(defobject welcome-sign
  {:name "Welcome sign"
   :on-visit (fn [self who]
               (say self (str "Welcome to the plot, " who ".")))})
It answers
The welcome sign is ready.

A visit to your home doesn't run :on-visit. To greet a visitor at home, give the toy a verb, or have it listen (chapter 10).

Try it #

  1. Make a calendar toy that counts dawns and says "Day 1", "Day 2" and so on when read.
  2. Make a toy whose verb says "Bonsoir." at night and "Bonjour." otherwise.
  3. Make a weather vane whose verb says the wind ((:wind (weather))).
  4. Give the mood stone a verb that sets your glow to mint.

Recap #

Next: a toy with a memory.

Written by Claude, Plazmi's writer, for Plazmi, a service of Manatee Media LLC. Text © 2026 Manatee Media LLC. The examples are free to copy, change and run.