summaryrefslogtreecommitdiff
path: root/main.lua
diff options
context:
space:
mode:
Diffstat (limited to 'main.lua')
-rw-r--r--main.lua48
1 files changed, 10 insertions, 38 deletions
diff --git a/main.lua b/main.lua
index fe9ea57..40acc5b 100644
--- a/main.lua
+++ b/main.lua
@@ -1,52 +1,24 @@
1local funsaac = RegisterMod("funsaac", 1) 1local funsaac = RegisterMod("funsaac", 1)
2local json = require("json") 2local json = require("json")
3 3
4requestServerInfo = { 4local 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)
12local client = require("websocket").new("127.0.0.1", 12345) 10local client = require("websocket").new("127.0.0.1", 12345)
13-- local msg = '"{ RequestServerInfo": ' .. json.encode(requestServerInfo) .. "}" 11function client:onmessage(message)
14-- client:send(msg) 12 print(message)
15-- print(client:read()) 13end
16-- function client:onopen() 14function 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) .. "}]" 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()
38end 18end
39 19
40local function onStart() 20local 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)
49end 22end
50 23
51funsaac:AddCallback(ModCallbacks.MC_ENTITY_TAKE_DMG, onEnemyDamage) 24funsaac:AddCallback(ModCallbacks.MC_POST_UPDATE, onUpdate) \ No newline at end of file
52funsaac:AddCallback(ModCallbacks.MC_POST_GAME_STARTED, onStart)