Skip to main content

Conditions API

Namespace: hexis.conditions

Boolean conditions for game state checks.


Player Detection

hexis.conditions.player_nearby(distance)        -- Any player nearby
hexis.conditions.no_players_nearby(distance) -- No players nearby
hexis.conditions.player_within(distance, ms) -- Player lingering
hexis.conditions.player_visible(distance, ms) -- Player in line of sight
hexis.conditions.player_sneaking(distance) -- Sneaking player nearby

Examples

-- Check if any player is within 30 blocks
if hexis.conditions.player_nearby(30) then
hexis.log.warn("Player detected nearby!")
end

-- Check if a player has been within 10 blocks for 5 seconds
if hexis.conditions.player_within(10, 5000) then
hexis.log.warn("Player lingering close by!")
end

Entity Detection

hexis.conditions.mob_within(distance, ms)       -- Mob nearby
hexis.conditions.entity_within(distance, ms) -- Any entity nearby

Examples

-- Check for mobs within 20 blocks
if hexis.conditions.mob_within(20) then
hexis.combat.start({...})
end

State Checks

hexis.conditions.inventory_full()               -- Inventory is full
hexis.conditions.gui_open(title_pattern) -- GUI open (optional title)
hexis.conditions.gui_closed(title_pattern) -- GUI closed
hexis.conditions.player_health("lt", 10) -- Health comparison
hexis.conditions.player_y("gt", 64) -- Y coordinate comparison
hexis.conditions.tablist_contains(pattern) -- Tablist has entry
hexis.conditions.distance_from_marked("lt", 5) -- Distance from marked pos

Health Comparison

-- Check if health is less than 10
if hexis.conditions.player_health("lt", 10) then
hexis.log.warn("Low health!")
hexis.actions.use_item() -- Use healing item
end

-- Comparison operators: "lt", "gt", "eq", "lte", "gte"

Y Position Check

-- Check if player is above Y=64
if hexis.conditions.player_y("gt", 64) then
hexis.log.info("Above sea level")
end

Tablist Check

-- Check area via tablist
if hexis.conditions.tablist_contains("Area: The Park") then
hexis.log.info("In The Park")
end

Utility Conditions

hexis.conditions.random(0.5)     -- 50% chance
hexis.conditions.always() -- Always true

Examples

-- Random break (50% chance)
if hexis.conditions.random(0.5) then
hexis.log.info("Taking a break...")
hexis.sleep(5000)
end

-- 10% chance
if hexis.conditions.random(0.1) then
hexis.actions.jump()
end

Example: Safety Check

-- Combined safety check
local function is_safe()
return hexis.conditions.no_players_nearby(30)
and not hexis.conditions.inventory_full()
and hexis.conditions.player_health("gt", 5)
end

while hexis.running() do
if is_safe() then
-- Continue farming
else
hexis.log.warn("Safety check failed, pausing...")
hexis.sleep(5000)
end
end