From d95f49be9dde63de3694a56316fe7e07ad4062e7 Mon Sep 17 00:00:00 2001 From: FxQnLr Date: Tue, 30 Apr 2024 20:47:13 +0200 Subject: working connection and basic request --- main.lua | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) (limited to 'main.lua') diff --git a/main.lua b/main.lua index 31555ee..c19ae3c 100644 --- a/main.lua +++ b/main.lua @@ -1,29 +1,10 @@ ----@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() + WsClient:update() render_tick = render_tick + 1 if render_tick >= 60 then @@ -32,4 +13,9 @@ local function onRender() end end -funsaac:AddCallback(ModCallbacks.MC_POST_RENDER, onRender) \ No newline at end of file +local function onEnemyDamage(_, entity, amount, damage_flags, source, countdown_frames) + ScalarCmd(1) +end + +funsaac:AddCallback(ModCallbacks.MC_POST_RENDER, onRender) +funsaac:AddCallback(ModCallbacks.MC_ENTITY_TAKE_DMG, onEnemyDamage) \ No newline at end of file -- cgit v1.2.3