Object MethodCore FlowComing soonv1.0.51

PhaseGate.status(gate)

Reads the gate without changing it: phase (nil before the first visit), visits, total, cycles, mode, limit and elapsedMs. It never changes the phase, even when the time is up.

Documented for app version 1.0.51 (not on Google Play yet)Updated:

Detailed Explanation

This section explains when to use the API, how to call it, and which structures it works best with in production flow.

How To Call It

PhaseGate is a global table: call its functions with a dot (PhaseGate.<method>(...)), not a colon. Requires Macro Handler 1.0.51 or later.

When To Use It

Core flow APIs are usually the backbone of larger scenarios; keep them anchored to clear checkpoints and readable variables.

Parameters and Return

Required: gate. Returns a Lua table.

Options and Limits

Options: trueMode and falseMode = "count" (visits, the default), "ms" or "seconds"; trueLimit and falseLimit are positive whole numbers (default 1; at most 1,000,000,000 visits, 604,800,000 ms or 604,800 seconds); repeatCycle (default true) decides whether the false phase returns to the true phase, and startWithTrue (default true) picks the first phase. A new table given to next or reset is a complete configuration: omitted fields return to their defaults. An invalid handle, an unknown unit, a zero, negative, fractional or oversized limit and a non-boolean flag raise an error.

Best Combined With

Using this API with logging, error handling, and next-step control produces much more professional results than calling it in isolation.

Example Usage

The snippet below is a starter pattern that can be applied directly in runtime flow.

local gate = PhaseGate.create({ trueMode = "count", trueLimit = 3, falseMode = "count", falseLimit = 1 })
PhaseGate.next(gate)
local result = PhaseGate.status(gate)

Copyable Progressive Examples

From foundation to combined usage, each level is provided as a separate code block so you can copy the level you need and adapt it directly.

Foundation

Shows the shortest direct way to call the API.

Foundation
local gate = PhaseGate.create({ trueMode = "count", trueLimit = 3, falseMode = "count", falseLimit = 1 })
PhaseGate.next(gate)
local result = PhaseGate.status(gate)

Simple

Wraps the base call with minimal flow control.

Simple
local stepOk = true
local gate = PhaseGate.create({ trueMode = "count", trueLimit = 3, falseMode = "count", falseLimit = 1 })
PhaseGate.next(gate)
local result = PhaseGate.status(gate)
if stepOk then
  wait(200)
end

Practical Flow

A practical pattern for real macros with pcall, logging, and guards.

Practical Flow
local ok, err = pcall(function()
  local gate = PhaseGate.create({ trueMode = "count", trueLimit = 3, falseMode = "count", falseLimit = 1 })
  PhaseGate.next(gate)
  local result = PhaseGate.status(gate)
end)

if not ok then
  print("API step failed: PhaseGate.status: " .. tostring(err))
  requestStop()
end

Detailed

This level packages the API into a reusable helper with error reporting.

Detailed
-- Core flow APIs are usually the backbone of larger scenarios; keep them anchored to clear checkpoints and readable variables.
local function run_status_step()
  local gate = PhaseGate.create({ trueMode = "count", trueLimit = 3, falseMode = "count", falseLimit = 1 })
  PhaseGate.next(gate)
  local result = PhaseGate.status(gate)
end

local ok, err = pcall(run_status_step)
if not ok then
  toast("Step failed")
  print(err)
end

Combined

Combines the API with related structures to form a more realistic workflow.

Combined
-- Three working visits, then one skipped visit, repeated (Macro Handler 1.0.51 or later)
local gate = PhaseGate.create({ trueMode = "count", trueLimit = 3, falseMode = "count", falseLimit = 1 })
for visit = 1, 8 do
  if PhaseGate.next(gate) then
    print("work", visit)
  else
    print("skip", visit)
  end
end
local state = PhaseGate.status(gate)
print(state.phase, state.visits, state.total, state.cycles, state.elapsedMs)
PhaseGate.reset(gate)