Server
Last updated on
The progress contract on the server — start a bar on one player's screen and get the server's verdict on how it ended.
local progress = OPX.Api.Get('progress')From server code inside opx_infinity (modules/progress/server/main.lua). The client draws the bar; the server judges it by its own clock. A finished that arrives sooner than the duration (less 150 ms of tick slack) is rejected and written to the security journal as progress.early; no report by the duration plus 5 s is no_answer; the player leaving is left. Separate resources use the StartProgress export.
Start
Puts a numbered bar on one player's screen. One bar per player.
progress.Start(source, owner, spec, on)Parameters
- source:
number— a connected player - owner:
string— your module name; carried back asowner - spec:
table—{ label, durationMs, cancelable?, animation? = { name, variant? } }, as the clientStart - on?:
function—on(source, outcome), called once with the verdict
Returns
Result—{ id, durationMs }; errorsinvalid_player,invalid_caller,invalid_spec,progress_busy,invalid_duration,invalid_label
The verdict is { id, owner, ending, completed, elapsedMs }, also raised as opx:on:progress:finished.
progress.Start(source, 'mymodule', { label = 'Searching', durationMs = 5000 }, function(src, outcome)
if outcome.completed then --[[ the server timed it: give the loot ]] end
end)Stop
Takes down a bar this owner put up; ends it stopped.
progress.Stop(source, owner, id)Parameters
- source:
number - owner:
string - id?:
integer— only that bar
Returns
Result—true; errorsprogress_not_active,not_owner
State
The bar the server has up on one player.
progress.State(source)Returns
Result—{ id, owner, remainingMs }, ornil