Introduced sample-macros.fnl to demonstrate how import-macros works.
This commit is contained in:
parent
11087a53df
commit
ea38605427
|
@ -1,3 +1,5 @@
|
|||
(import-macros {: incf} :sample-macros)
|
||||
|
||||
(var counter 0)
|
||||
(var time 0)
|
||||
|
||||
|
@ -8,7 +10,8 @@
|
|||
(if (< counter 65535)
|
||||
(set counter (+ counter 1))
|
||||
(set counter 0))
|
||||
(set time (+ time dt))
|
||||
(incf time dt)
|
||||
;;(set time (+ time dt))
|
||||
(when (> time 3)
|
||||
(love.event.quit)))
|
||||
:keypressed (fn keypressed [key set-mode]
|
||||
|
|
13
sample-macros.fnl
Normal file
13
sample-macros.fnl
Normal file
|
@ -0,0 +1,13 @@
|
|||
(fn incf [value ?by]
|
||||
`(set ,value (+ ,value (or ,?by 1))))
|
||||
|
||||
(fn decf [value ?by]
|
||||
`(set ,value (+ ,value (or ,?by 1))))
|
||||
|
||||
(fn with [t keys ?body]
|
||||
`(let [,keys ,t]
|
||||
(if ,?body
|
||||
,?body
|
||||
,keys)))
|
||||
|
||||
{: incf : decf : with}
|
Loading…
Reference in a new issue