Functions
Anchor |
---|
| installedRulesets |
---|
| installedRulesets |
---|
|
installedRulesetsReturns an array of all of the rulesets installed on the pico ReturnsAn array of strings, with each string being an RID (ruleset identifier) Code Block |
---|
language | js |
---|
theme | Confluence |
---|
title | Example |
---|
| installed_rulesets = wrangler:installedRulesets()
/*
["io.picolabs.pico", ...]
*/ |
registeredRulesetsReturns an array of all the registered rulesets on the pico engine that the pico is running on. ReturnsAn array of strings, with each string being an RID (ruleset identifier) Code Block |
---|
language | js |
---|
theme | Confluence |
---|
title | Example |
---|
| registered_rulesets = wrangler:registeredRulesets()
/*
["io.picolabs.pico", "io.picolabs.logging"]
*/ |
rulesetsInfoReturns an array that contains full ruleset descriptions for the requested ruleset(s) ParametersParameter | Datatype | Description |
---|
rids | Array String | The RIDs of the rulesets to be described. Each RID can be an entry in an array, or in a semicolon denoted list (e.g. "io.picolabs.ruleset_one;io.picolabs.ruleset_two"). |
ReturnsA an array where each entry is a requested ruleset's description. See the example for an idea of what each description (represented as a map) looks like
Code Block |
---|
language | js |
---|
theme | Confluence |
---|
title | Example |
---|
| wrangler_info = wrangler:rulesetsInfo("io.picolabs.wrangler")
/*
[
{
"rid": "io.picolabs.wrangler",
"src": "omitted for brevity, full source would show up here",
"hash": "7d68b3232f8d820631ab73871530648b94ab610f598cab1986d7cd666232a0a0",
"url": "The URL that the ruleset might be installed from, if downloaded from a remote server",
"timestamp_stored": "2019-01-12T02:17:04.044Z",
"timestamp_enable": "2019-01-12T02:17:04.045Z",
"meta": {
"name": "Wrangler Core",
"description": "\r\n Wrangler Core Module,\r\n use example, use module v1_wrangler alias wrangler .\r\n This Ruleset/Module provides a developer interface to the PICO (persistent computer object).\r\n When a PICO is created or authenticated this ruleset will be installed to provide essential\r\n services.\r\n ",
"author": "BYU Pico Lab"
}
}
]
*/ |
Received Events
install_rulesets_requestedwrangler:install_rulesets_requestedInstalls the given rulesets in the pico that receives this event. AttributesDirectives Returned Code Block |
---|
send_directive("rulesets installed", { "rids": /* An array of rids that were installed*/ }); |
Corresponding Raised Events:
uninstall_rulesets_requestedwrangler:uninstall_rulesets_requestedUninstalls the given rulesets in the pico that receives this event. The directives returned will always be the same, meaning if the ruleset did not exist in the first place, the directive would still map "rids" to the RIDs given as the event attribute. Use the 687767607 function to programmatically check if a ruleset is installed. AttributesAttribute | Datatype | Description |
---|
rids OR rid | Array String | The RIDs of the rulesets to be uninstalled on this pico. Each RID can be an entry in an array, or in a semicolon denoted list (e.g. "io.picolabs.ruleset_one;io.picolabs.ruleset_two"). |
Directives Returned Code Block |
---|
send_directive("rulesets uninstalled", { "rids": /* An array of rids that were uninstalled*/ }); |
ruleset_needs_cleanup_periodwrangler:ruleset_needs_cleanup_periodThis event is used to signal to Wrangler to register a ruleset domain to wait for before fully deleting a pico, to allow the ruleset(s) time to cleanup. AttributesAttribute | Datatype | Description |
---|
domain | String | The ruleset domain to reigster to wait to cleanup. |
cleanup_finishedwrangler:cleanup_finishedThis event is used to signal to Wrangler that a ruleset domain previously registered for cleanup is finished. AttributesAttribute | Datatype | Description |
---|
domain | String | The ruleset domain that is done cleaning up. |
set_timeout_before_pico_deletedwrangler:set_timeout_before_pico_deletedThis event is used to change the time allotted for rulesets to cleanup before it times out and the pico deletes itself anyway. By default it is set to 5 minutes. AttributesAttribute | Datatype | Description |
---|
new_timeout | String | Has the same format as the second parameter of the time:add() function. (e.g. {"minutes":5} or {"seconds":5})
|
Raised Events
Anchor |
---|
| ruleset_added |
---|
| ruleset_added |
---|
|
ruleset_addedwrangler:ruleset_addedIs raised within the pico when new ruleset(s) have just been installed. This can be especially useful as an entry point for code execution on any ruleset. By selecting on this event and checking if your ruleset is one of the installed ones, your ruleset can begin execution upon installation. Attributes AddedAttribute | Datatype | Description |
---|
rids | Array | An array of rids that were installed |
Code Block |
---|
language | js |
---|
theme | Confluence |
---|
title | Example |
---|
| rule on_installation{
select when wrangler ruleset_added where rids >< meta:rid.klog("meta rid") // if this ruleset has just been installed
pre {
}
noop()
fired{
ent:ownerPolicy := owner_policy;
ent:owners := {"root": {"eci": new_channel{"id"}}};
raise game event "start_game"
attributes event:attrs;
}
} |
install_rulesets_errorwrangler:install_rulesets_errorThis event is raised when there was an error installing a ruleset into a pico. This may (but not only) include giving a RID that does not exist on the engine to install. Attributes AddedAttribute | Datatype | Description |
---|
rids | Array | An array of rids that failed to install |
rulesets_need_to_cleanupwrangler:rulesets_need_to_cleanupThis event is raised when a pico is now getting ready to delete. Rulesets that have registered for a cleanup period should do any necessary cleanup on this event and then raise wrangler:cleanup_finished with their domain to signal their completion. Will have passed through attributes given to wrangler:child_deletion.
|