refactor: rename a few things

This commit is contained in:
2025-02-17 11:53:24 -05:00
parent 93348835ac
commit 2373d6500e
21 changed files with 7 additions and 7 deletions

15
lib/enum.lua Normal file
View File

@@ -0,0 +1,15 @@
NONE = 0
FORWARD = 1
BACKWARD = 2
LEFT = 3
RIGHT = 4
FORWARD_LEFT = 5
FORWARD_RIGHT = 6
BACKWARD_LEFT = 7
BACKWARD_RIGHT = 8
BLOCK_POS_GOAL = 0
RADIUS_GOAL = 1
REACH_BLOCK_POS_GOAL = 2
XZ_GOAL = 3
Y_GOAL = 4

20
lib/events.lua Normal file
View File

@@ -0,0 +1,20 @@
local center = { x = 0, z = 0 }
local radius = 50
function on_tick()
local entities = client:find_entities(function(e)
return e.kind == "minecraft:player"
and e.position.x > center.x - radius + 1
and e.position.x < center.x + radius
and e.position.z > center.z - radius
and e.position.z < center.z + radius
end)
for _, e in entities do
client:chat(string.format("%s (%s) at %.1f %.1f %.1f", e.kind, e.id, e.position.x, e.position.y, e.position.z))
end
end
function on_init()
info("client initialized, setting client information")
client:set_client_information({ view_distance = 16 })
end

30
lib/utils.lua Normal file
View File

@@ -0,0 +1,30 @@
function dump(object)
if type(object) == "table" then
local string = "{ "
local parts = {}
for key, value in pairs(object) do
table.insert(parts, key .. " = " .. dump(value))
end
string = string .. table.concat(parts, ", ")
return string .. " " .. "}"
else
return tostring(object)
end
end
function dump_pretty(object, level)
if not level then
level = 0
end
if type(object) == "table" then
local string = "{\n" .. string.rep(" ", level + 1)
local parts = {}
for key, value in pairs(object) do
table.insert(parts, key .. " = " .. dump_pretty(value, level + 1))
end
string = string .. table.concat(parts, ",\n" .. string.rep(" ", level + 1))
return string .. "\n" .. string.rep(" ", level) .. "}"
else
return tostring(object)
end
end