diff options
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | main.lua | 48 |
2 files changed, 12 insertions, 38 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..21c8fbc --- /dev/null +++ b/.gitignore | |||
@@ -0,0 +1,2 @@ | |||
1 | .vscode | ||
2 | .luarc.json \ No newline at end of file | ||
@@ -1,52 +1,24 @@ | |||
1 | local funsaac = RegisterMod("funsaac", 1) | 1 | local funsaac = RegisterMod("funsaac", 1) |
2 | local json = require("json") | 2 | local json = require("json") |
3 | 3 | ||
4 | requestServerInfo = { | 4 | local requestServerInfo = { |
5 | Id = 1, | 5 | Id = 1, |
6 | ClientName = "Funsaac", | 6 | ClientName = "Funsaac v.0.0.1", |
7 | MessageVersion = 1 | 7 | MessageVersion = 3 |
8 | } | 8 | } |
9 | 9 | ||
10 | -- | ||
11 | -- local client = require("websocket").new("192.168.178.28", 12345) | ||
12 | local client = require("websocket").new("127.0.0.1", 12345) | 10 | local client = require("websocket").new("127.0.0.1", 12345) |
13 | -- local msg = '"{ RequestServerInfo": ' .. json.encode(requestServerInfo) .. "}" | 11 | function client:onmessage(message) |
14 | -- client:send(msg) | 12 | print(message) |
15 | -- print(client:read()) | 13 | end |
16 | -- function client:onopen() | 14 | function client:onopen() |
17 | -- client:update() | ||
18 | -- res = client:read() | ||
19 | -- print(res) | ||
20 | -- local msg = '[{"RequestServerInfo": ' .. json.encode(requestServerInfo) .. "}]" | ||
21 | -- print(msg) | ||
22 | -- client:send(msg) | ||
23 | -- -- local msg = '"[{ RequestServerInfo": ' .. json.encode(requestServerInfo) .. "}]" | ||
24 | -- -- client:send(msg) | ||
25 | -- -- print(client:read()) | ||
26 | -- -- client:send("") | ||
27 | -- end | ||
28 | --client:update() | ||
29 | |||
30 | local function onEnemyDamage(_, entity, amount, damage_flags, source, countdown_frames) | ||
31 | print(reqestServerInfo) | ||
32 | client:update() | ||
33 | local msg = '[{"RequestServerInfo": ' .. json.encode(requestServerInfo) .. "}]" | 15 | local msg = '[{"RequestServerInfo": ' .. json.encode(requestServerInfo) .. "}]" |
34 | print(msg) | 16 | print(msg) |
35 | client:send(msg) | 17 | self:send(msg) |
36 | print(client:read()) | ||
37 | client:update() | ||
38 | end | 18 | end |
39 | 19 | ||
40 | local function onStart() | 20 | local function onUpdate() |
41 | client:update() | 21 | client:update() |
42 | res = client:read() | ||
43 | -- print(res) | ||
44 | local msg = '[{"RequestServerInfo": ' .. json.encode(requestServerInfo) .. "}]" | ||
45 | print(msg) | ||
46 | client:send(msg) | ||
47 | local t = client:read() | ||
48 | print(t) | ||
49 | end | 22 | end |
50 | 23 | ||
51 | funsaac:AddCallback(ModCallbacks.MC_ENTITY_TAKE_DMG, onEnemyDamage) | 24 | funsaac:AddCallback(ModCallbacks.MC_POST_UPDATE, onUpdate) \ No newline at end of file |
52 | funsaac:AddCallback(ModCallbacks.MC_POST_GAME_STARTED, onStart) | ||