diff options
author | FxQnLr <[email protected]> | 2024-04-28 15:34:26 +0200 |
---|---|---|
committer | FxQnLr <[email protected]> | 2024-04-28 15:34:26 +0200 |
commit | bf52c4de83022baa626c56e81f1c7b4a6e958774 (patch) | |
tree | 87b1270b462ca5fac523a17ca29d481d55e935cd /main.lua | |
download | funsaac-bf52c4de83022baa626c56e81f1c7b4a6e958774.tar funsaac-bf52c4de83022baa626c56e81f1c7b4a6e958774.tar.gz funsaac-bf52c4de83022baa626c56e81f1c7b4a6e958774.zip |
working handshake plus response
Diffstat (limited to 'main.lua')
-rw-r--r-- | main.lua | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/main.lua b/main.lua new file mode 100644 index 0000000..fe9ea57 --- /dev/null +++ b/main.lua | |||
@@ -0,0 +1,52 @@ | |||
1 | local funsaac = RegisterMod("funsaac", 1) | ||
2 | local json = require("json") | ||
3 | |||
4 | requestServerInfo = { | ||
5 | Id = 1, | ||
6 | ClientName = "Funsaac", | ||
7 | MessageVersion = 1 | ||
8 | } | ||
9 | |||
10 | -- | ||
11 | -- local client = require("websocket").new("192.168.178.28", 12345) | ||
12 | local client = require("websocket").new("127.0.0.1", 12345) | ||
13 | -- local msg = '"{ RequestServerInfo": ' .. json.encode(requestServerInfo) .. "}" | ||
14 | -- client:send(msg) | ||
15 | -- print(client:read()) | ||
16 | -- 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) .. "}]" | ||
34 | print(msg) | ||
35 | client:send(msg) | ||
36 | print(client:read()) | ||
37 | client:update() | ||
38 | end | ||
39 | |||
40 | local function onStart() | ||
41 | 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 | ||
50 | |||
51 | funsaac:AddCallback(ModCallbacks.MC_ENTITY_TAKE_DMG, onEnemyDamage) | ||
52 | funsaac:AddCallback(ModCallbacks.MC_POST_GAME_STARTED, onStart) | ||