summaryrefslogtreecommitdiff
path: root/main.lua
diff options
context:
space:
mode:
Diffstat (limited to 'main.lua')
-rw-r--r--main.lua52
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 @@
1local funsaac = RegisterMod("funsaac", 1)
2local json = require("json")
3
4requestServerInfo = {
5 Id = 1,
6 ClientName = "Funsaac",
7 MessageVersion = 1
8}
9
10--
11-- local client = require("websocket").new("192.168.178.28", 12345)
12local 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
30local 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()
38end
39
40local 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)
49end
50
51funsaac:AddCallback(ModCallbacks.MC_ENTITY_TAKE_DMG, onEnemyDamage)
52funsaac:AddCallback(ModCallbacks.MC_POST_GAME_STARTED, onStart)