summaryrefslogtreecommitdiff
path: root/main.lua
blob: 31555eea0a315bd2405dbd233020bd3a84b6fe4b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
---@diagnostic disable: duplicate-set-field

local funsaac = RegisterMod("funsaac", 1)
require("messages")

local client = require("websocket").new("127.0.0.1", 12345, "/")

CONNECTED = false

function client:onmessage(message)
  HandleResponse(ResponseContent(message))
  if CONNECTED == true then
    self:send(GetMessage(Messages.StartScanning))
    CONNECTED = false
  end
end

function client:onopen()
  self:send(GetMessage(Messages.RequestServerInfo))
end


local render_tick = 0
local s = 0;
local function onRender()
  client:update()

  render_tick = render_tick + 1
  if render_tick >= 60 then
    render_tick = 0
    s = s + 1
  end
end

funsaac:AddCallback(ModCallbacks.MC_POST_RENDER, onRender)