aboutsummaryrefslogtreecommitdiffstats
path: root/init.moon
blob: d4f7e85cb8927c6fc1d92b793f1b466a65eef951 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
-- run from CLI
import monotime, sleep from require 'system'
import Logger from require 'logger'
import Copilot from require 'copilot'

arguments, key = {}
for a in *arg
  if match = a\match '^%-%-(.*)'
    key = match
    arguments[key] = true
  elseif key
    arguments[key] = a
    key = nil
  else
    table.insert arguments, a

Logger.init arguments.log

delta = do
  period = 1 / 60
  
  local last
  ->
    if last
      target, current = (last + period), monotime!
      if current > target
        L\warn 'Frame Skipped!'
      else
        sleep target - current

    time = monotime!
    with time - (last or time)
      last = time

copilot = Copilot arguments[1]

while true
  dt = delta!

  copilot\update dt