|
192.168.1.169 ~/dust/code/arcologies $ git diff --cached |
|
diff --git a/lib/counters.lua b/lib/counters.lua |
|
index 0f3bf45..4898b37 100644 |
|
--- a/lib/counters.lua |
|
+++ b/lib/counters.lua |
|
@@ -1,3 +1,5 @@ |
|
+include("arcologies/lib/filesystem") |
|
+ |
|
counters = {} |
|
|
|
function counters.init() |
|
@@ -36,6 +38,9 @@ function counters.conductor() |
|
keeper:collide_signals_and_cells() |
|
keeper:delete_signals() |
|
keeper:teardown() |
|
+ if math.fmod(counters.music_generation, 4) then |
|
+ filesystem.save_map("running", "/tmp/arcologies/") |
|
+ end |
|
redraw() |
|
end |
|
end |
|
diff --git a/lib/filesystem.lua b/lib/filesystem.lua |
|
index 9b5fa81..ce5b032 100644 |
|
--- a/lib/filesystem.lua |
|
+++ b/lib/filesystem.lua |
|
@@ -80,10 +80,11 @@ function filesystem:get_crypt() |
|
return self.current |
|
end |
|
|
|
-function filesystem.save_map(text) |
|
+function filesystem.save_map(text, maps_path) |
|
+ maps_path = maps_path or filesystem.paths["maps_path"] |
|
if text then |
|
print("saving map...") |
|
- local save_path = filesystem.paths.maps_path .. text ..".txt" |
|
+ local save_path = maps_path .. text ..".txt" |
|
local data = saveload:collect_data_for_map_save(text) |
|
local file = io.open(save_path, "w") |
|
io.output(file) |
|
diff --git a/serve.js b/serve.js |
|
new file mode 100644 |
|
index 0000000..4db1ece |
|
--- /dev/null |
|
+++ b/serve.js |
|
@@ -0,0 +1,18 @@ |
|
+const fs = require('fs') |
|
+const WS = require('ws') |
|
+ |
|
+const wss = new WS.Server({ |
|
+ port: 8080 |
|
+}) |
|
+ |
|
+// yeah this should be streams and fully async but i'm just hackin here to test |
|
+ |
|
+fs.watch('/tmp/arcologies/running.txt', {encoding: 'buffer'}, function (eventType, filename) { |
|
+ console.log("change") |
|
+ wss.clients.forEach(function each(client) { |
|
+ if (client !== wss && client.readyState === WS.OPEN) { |
|
+ console.log('sending') |
|
+ client.send(fs.readFileSync('/tmp/arcologies/running.txt', {encoding: 'ascii'})); |
|
+ } |
|
+ }) |
|
+}) |