diff options
| author | s-ol <s-ol@users.noreply.github.com> | 2020-04-19 15:02:54 +0000 |
|---|---|---|
| committer | s-ol <s-ol@users.noreply.github.com> | 2020-04-19 15:02:54 +0000 |
| commit | 8b9d1ac65083c201d4ce86d1c6950ea02d7b95f3 (patch) | |
| tree | d550ea40181899ea3aa601728f7afdd04ea4cb7b /alv/copilot.moon | |
| parent | also pack source rocks (diff) | |
| download | alive-8b9d1ac65083c201d4ce86d1c6950ea02d7b95f3.tar.gz alive-8b9d1ac65083c201d4ce86d1c6950ea02d7b95f3.zip | |
add wxLua alv-wx
Diffstat (limited to 'alv/copilot.moon')
| -rw-r--r-- | alv/copilot.moon | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/alv/copilot.moon b/alv/copilot.moon index a1dc811..3d1523e 100644 --- a/alv/copilot.moon +++ b/alv/copilot.moon @@ -26,20 +26,26 @@ class Copilot --- create a new Copilot. -- @classmethod -- @tparam string file name/path of the alive file to watch and execute - new: (@file) => + new: (file) => @registry = Registry! + @eval_stream, @run_stream = io.stderr, io.stdout + @open file if file - @last_modification = 0 - - mode = lfs.attributes @file, 'mode' + open: (file) => + mode = lfs.attributes file, 'mode' if mode != 'file' - error "not a file: #{@file}" + error "not a file: #{file}" + + @last_modification = 0 + @file = file --- members -- @section members --- poll for changes and tick. tick: => + return unless @file + @poll! if @root @@ -76,10 +82,10 @@ class Copilot return if @last_modification < modification - L.stream = io.stderr + L.stream = @eval_stream L\log "#{@file} changed at #{modification}" @eval! - L.stream = io.stdout + L.stream = @run_stream @last_modification = os.time! { |
