-
Notifications
You must be signed in to change notification settings - Fork 0
Coroutine yield helper module #15
Copy link
Copy link
Closed
Labels
Description
Should be able to use SLua coroutines to flatten callback APIs into sequential code, including the following.
Runtime
spawn(fn)run a function inside a coroutine so it can yieldwaitFor(event, filter?)yield until an LLEvents event fires (with optional predicate)sleep(seconds)yield for N seconds viaLLTimers.once
Dataserver Wrappers
requestAgentData(id, type)yields, returnsstringrequestDisplayName(id)yields, returnsstringrequestSimulatorData(region, type)yields, returnsstringrequestInventoryData(item)yields, returnsstringreadNotecardLine(name, line)yields, returnsstringreadNotecard(name)yields, returnsstring[](loops until EOF)findNotecardTextCount(name, pattern, opts)yields, returnsstring
Key-Value Store Wrappers (dataserver-based)
kvRead(key)->{ ok: boolean, value: string }kvCreate(key, value)->booleankvUpdate(key, value)->booleankvDelete(key)->booleankvSize()->{ used: number, total: number }
Dialog & TextBox
dialog(avatarId, text, buttons)yields, returns button text (manages listen channel internally)textBox(avatarId, text)yields, returns typed text
HTTP
httpRequest(url, params, body)yields, returns{ status, metadata, body }
Permissions
requestPermissions(avatarId, mask)yields, returns granted flagstransferMoney(avatarId, amount)yields, returns{ success, message }
Sensor
sensor(name, id, type, range, arc)yields, returnsDetectedEvent[] | null
Note, I'm not sure but there's probably also plans for official callback style APIs at some point, but this may still be good as a stand in.
Reactions are currently unavailable