Guide
Example, Mobile Legends
The mlbb namespace exposes the entity snapshot and the room. This script reads mlbb.entities() and logs each visible enemy with its health and distance from the local hero, once a second.
Mobile Legends has no per-game events, so the work runs in paint and throttles itself with client.timestamp (milliseconds).
local next_log = 0
client.set_event_callback("paint", function()
local now = client.timestamp()
if now < next_log then return end
next_log = now + 1000
local snapshot = mlbb.entities()
if not snapshot.ready or not snapshot.local_player then return end
local me = snapshot.local_player.position
for index, enemy in ipairs(snapshot.enemies) do
if enemy.visible and not enemy.dead and enemy.position then
local hp = enemy.health or 0
local max = enemy.maximum_health or 0
client.log(string.format(
"enemy %d: %d/%d hp, %.1f away",
index, hp, max, vector.distance(me, enemy.position)
))
end
end
end)
Notes
snapshot.readyis false outside a match.local_playeris absent until the local hero spawns.- A field on an entity is absent when the game did not expose it that frame, so read
healthandmaximum_healthwith a default. enemy.positionis avec3;vector.distanceaccepts twovec3tables and is always available.mlbb.room()returns the lobby or match room with every player’s hero, rank and score. Outside a room it returnsniland a reason string.
See the mlbb reference for the field lists.