Skip to content

Instantly share code, notes, and snippets.

@jemmons
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jemmons/2297e1d4688817a40e6b to your computer and use it in GitHub Desktop.
Save jemmons/2297e1d4688817a40e6b to your computer and use it in GitHub Desktop.
Getting Started Programming Light Table
(ns reverb.lighttable
(:require lt.object)
(:require-macros lt.macros))
(lt.object/object* ::my-template-name :tags [:my-tag-name] :some-nebulous-state [], :other-state-like-thing {})
(lt.object/->def ::my-template-name)
(lt.object/create ::my-template-name)
(lt.object/instances-by-type ::my-template-name)
(lt.macros/behavior ::my-behavior-name
:triggers #{:my-trigger-name}
:reaction (fn [self & rest]
(prn (str "self:" self " and: " rest))))
(lt.object/->behavior ::my-behavior-name)
;; For illustrative purposes only. You should normally do this via `user.behaviors`.
(lt.object/add-behavior! (first (lt.object/by-tag :my-tag-name)) [::my-behavior-name])
(lt.object/raise (first (lt.object/by-tag :my-tag-name)) :my-trigger-name "foo")
;; Note that in the above, we find our objects `by-tag`, but we can use anything that returns (an) object(s). For example `intances-by-type`, or even `by-id`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment