local funsaac = RegisterMod("funsaac", 1) local json = require("json") requestServerInfo = { Id = 1, ClientName = "Funsaac", MessageVersion = 1 } -- -- local client = require("websocket").new("192.168.178.28", 12345) local client = require("websocket").new("127.0.0.1", 12345) -- local msg = '"{ RequestServerInfo": ' .. json.encode(requestServerInfo) .. "}" -- client:send(msg) -- print(client:read()) -- function client:onopen() -- client:update() -- res = client:read() -- print(res) -- local msg = '[{"RequestServerInfo": ' .. json.encode(requestServerInfo) .. "}]" -- print(msg) -- client:send(msg) -- -- local msg = '"[{ RequestServerInfo": ' .. json.encode(requestServerInfo) .. "}]" -- -- client:send(msg) -- -- print(client:read()) -- -- client:send("") -- end --client:update() local function onEnemyDamage(_, entity, amount, damage_flags, source, countdown_frames) print(reqestServerInfo) client:update() local msg = '[{"RequestServerInfo": ' .. json.encode(requestServerInfo) .. "}]" print(msg) client:send(msg) print(client:read()) client:update() end local function onStart() client:update() res = client:read() -- print(res) local msg = '[{"RequestServerInfo": ' .. json.encode(requestServerInfo) .. "}]" print(msg) client:send(msg) local t = client:read() print(t) end funsaac:AddCallback(ModCallbacks.MC_ENTITY_TAKE_DMG, onEnemyDamage) funsaac:AddCallback(ModCallbacks.MC_POST_GAME_STARTED, onStart)