Skip to main content

Reaction

This is used in the file of a Trigger.

Media#

Don't forget to open http://localhost:5000/ to ear sounds !

Sound#

FieldTypeRequiredDefaultDescription
filestringโœ”๏ธnoneFile in workspace ./resources/media/ or URL
volumenumberโŒ1Volume between 0 and 1
Return#

Return a Promise who resolve when sound is finished.

Example#
const reaction = async (event) => {
await media.play("workspace://audio/mario.mp3", 1)
}

File#

Write#

FieldTypeRequiredDefaultDescription
filestringโœ”๏ธnone
datastringโœ”๏ธnone
Return#

void

Example#
const reaction = async (event) => {
file.write("monfichier.txt", data)
}

Read#

FieldTypeRequiredDefaultDescription
filestringโœ”๏ธnone
Return#

string

Example#
const reaction = async (event) => {
const content = file.read("monfichier.txt")
console.log(content)
}

Append#

FieldTypeRequiredDefaultDescription
filestringโœ”๏ธnone
datastringโœ”๏ธnone
Return#

void

Example#
const reaction = async (event) => {
file.append("monfichier.txt", "\ncoucou")
}

Temp Variable#

Get#

FieldTypeRequiredDefaultDescription
keystringโœ”๏ธnone
Return#

Return Promise<any>.

Example#
const reaction = async (event) => {
const valeur = temp.get("waza")
console.log({ valeur })
}

Set#

FieldTypeRequiredDefaultDescription
keystringโœ”๏ธnone
dataanyโœ”๏ธnone
Return#

Return the value set

Example#
const reaction = async (event) => {
const valeur = temp.set("waza", "test")
console.log({ valeur })
}
const reaction = async (event) => {
const valeur = temp.set("waza", 42)
console.log({ valeur })
}
const reaction = async (event) => {
const valeur = temp.set("waza", { test: 42 })
console.log({ valeur })
}

Cache Variable#

Get#

FieldTypeRequiredDefaultDescription
keystringโœ”๏ธnone
fileNamestringโŒnone
Return#

Return Promise<any>.

Example#
const reaction = async (event) => {
const valeur = cache.get("waza")
console.log({ valeur })
}

Set#

FieldTypeRequiredDefaultDescription
keystringโœ”๏ธnone
dataanyโœ”๏ธnone
fileNamestringโŒnone
Return#

Return the value set

Example#
const reaction = async (event) => {
const valeur = cache.set("waza", "test")
console.log({ valeur })
}
const reaction = async (event) => {
const valeur = cache.set("waza", 42)
console.log({ valeur })
}
const reaction = async (event) => {
const valeur = cache.set("waza", { test: 42 })
console.log({ valeur })
}

Utils#

Sleep#

FieldTypeRequiredDefaultDescription
msnumberโœ”๏ธnoneA number
Return#

Return Promise<void>.

Example#
const reaction = async (event) => {
await utils.sleep(5000)
}

Event#

New#

FieldTypeRequiredDefaultDescription
objectobjectโœ”๏ธnoneYour event data !
Return#

void

Example#
const reaction = async (event) => {
event.new('my-event', {
data: 42
})
}