summaryrefslogtreecommitdiff
path: root/main.lua
diff options
context:
space:
mode:
authorFxQnLr <[email protected]>2024-04-30 20:47:13 +0200
committerFxQnLr <[email protected]>2024-04-30 20:47:13 +0200
commitd95f49be9dde63de3694a56316fe7e07ad4062e7 (patch)
treee07af9156af08a15dbb33b6718359a3fc7c004d2 /main.lua
parentab76e442ab4fb4d41ccbc211f9ac05e19aaefd4b (diff)
downloadfunsaac-main.tar
funsaac-main.tar.gz
funsaac-main.zip
working connection and basic requestHEADmain
Diffstat (limited to 'main.lua')
-rw-r--r--main.lua28
1 files changed, 7 insertions, 21 deletions
diff --git a/main.lua b/main.lua
index 31555ee..c19ae3c 100644
--- a/main.lua
+++ b/main.lua
@@ -1,29 +1,10 @@
1---@diagnostic disable: duplicate-set-field
2
3local funsaac = RegisterMod("funsaac", 1) 1local funsaac = RegisterMod("funsaac", 1)
4require("messages") 2require("messages")
5 3
6local client = require("websocket").new("127.0.0.1", 12345, "/")
7
8CONNECTED = false
9
10function client:onmessage(message)
11 HandleResponse(ResponseContent(message))
12 if CONNECTED == true then
13 self:send(GetMessage(Messages.StartScanning))
14 CONNECTED = false
15 end
16end
17
18function client:onopen()
19 self:send(GetMessage(Messages.RequestServerInfo))
20end
21
22
23local render_tick = 0 4local render_tick = 0
24local s = 0; 5local s = 0;
25local function onRender() 6local function onRender()
26 client:update() 7 WsClient:update()
27 8
28 render_tick = render_tick + 1 9 render_tick = render_tick + 1
29 if render_tick >= 60 then 10 if render_tick >= 60 then
@@ -32,4 +13,9 @@ local function onRender()
32 end 13 end
33end 14end
34 15
35funsaac:AddCallback(ModCallbacks.MC_POST_RENDER, onRender) \ No newline at end of file 16local function onEnemyDamage(_, entity, amount, damage_flags, source, countdown_frames)
17 ScalarCmd(1)
18end
19
20funsaac:AddCallback(ModCallbacks.MC_POST_RENDER, onRender)
21funsaac:AddCallback(ModCallbacks.MC_ENTITY_TAKE_DMG, onEnemyDamage) \ No newline at end of file