summaryrefslogblamecommitdiff
path: root/main.lua
blob: 31555eea0a315bd2405dbd233020bd3a84b6fe4b (plain) (tree)
1
2
3
4
5
6
7
8
9

                                           
                                         


                                                                
 
                 
 
                                  




                                                 
   
 
                        
                                                   

   



                         
                 





                               

   
                                                         
---@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)