feat: add event listeners

This commit is contained in:
2025-02-20 21:07:41 -05:00
parent c2da997b71
commit bd6698c4b4
5 changed files with 126 additions and 25 deletions

View File

@@ -1,7 +1,7 @@
local center = { x = 0, z = 0 }
local radius = 100
function on_tick()
function log_player_positions()
local entities = client:find_entities(function(e)
return e.kind == "minecraft:player"
and e.position.x > center.x - radius + 1
@@ -17,8 +17,14 @@ end
function on_init()
info("client initialized, setting information...")
client:set_client_information({ view_distance = 16 })
end
function on_login()
info("player successfully logged in!")
add_listener("login", function()
info("player successfully logged in!")
end)
add_listener("death", function()
warn("player died!")
end, "warn_player_died")
add_listener("tick", log_player_positions)
end