-
Notifications
You must be signed in to change notification settings - Fork 1
Documentation
Download the latest release from the Releases tab. Drag the downloaded file into your IDE window. You can also press "Import Local Package" under the Tools Menu, and select the file.
Frog alarms is also available on the YoYo Marketplace!
First, you'll need to initialize the FrogAlarms. Add the following code to the Create
event of an object.
Note: The fa
struct created here can hold many alarms.
// Create
fa = new FrogAlarms();
To count down all frog alarms that exist within the fa
struct, call the run()
function within the Step event.
// Step
fa.run();
A FrogAlarm can be created using the create()
function. FrogAlarms start running when created.
Argument | Type | Description |
---|---|---|
function | Function | A function that will run when the alarm is finished. |
time | Number | How long the alarm should run in frames |
index | String/Number | Optional. Adding an index to an alarm allows it to be referenced after it has started. Alarms with the same index will not be restarted or recreated. |
// Create
fa.create(
function() {
show_debug_message("Ribbit");
},
60
);
// Outputs `Ribbit` after 60 frames.
Adding an index prevents starting duplicate alarms
// Step
fa.create(
function() {
show_debug_message("Ribbit");
},
room_speed,
"my_frog_alarm"
);
// Outputs `Ribbit` ONCE every second.
Pauses the alarm.
Argument | Type | Description |
---|---|---|
index | String/Number or Array of String/Numbers |
fa.pause("my_frog_alarm");
fa.pause(["my_frog_alarm_2", 23]);
// Pauses FrogAlarms: my_frog_alarm, my_frog_alarm_2, and 23.
Resumes a paused alarm.
Argument | Type | Description |
---|---|---|
index | String/Number or Array of String/Numbers |
fa.resume("my_frog_alarm");
fa.resume(["my_frog_alarm_2", 23]);
// Resumes FrogAlarms: my_frog_alarm, my_frog_alarm_2, and 23.
Removes the alarm from the struct.
Note: FrogAlarms are auto-removed once they finish
Argument | Type | Description |
---|---|---|
index | String/Number or Array of String/Numbers |
fa.remove("my_frog_alarm");
fa.remove(["my_frog_alarm_2", 23]);
// Removes FrogAlarms: my_frog_alarm, my_frog_alarm_2, and 23.
Sets the alarm's time to the duration
Argument | Type | Description |
---|---|---|
index | String/Number or Array of String/Numbers |
fa.restart("my_frog_alarm");
fa.restart(["my_frog_alarm_2", 23]);
// Restarts FrogAlarms: my_frog_alarm, my_frog_alarm_2, and 23.
Returns an array of FrogAlarm indices.
Argument | Type | Description |
---|---|---|
function | Function | Optional. A function for filtering alarms before they are returned. This function uses one argument. Each alarm's index will be passed into this argument. If this function returns false, list() will not include that index in the array. |
show_debug_message( fa.list() );
// Outputs an array of all existing FrogAlarm indicies.
Alarms can be filtered using the optional function argument.
short_alarms = fa.list( function(alarm_idx) { return fa.get_time(alarm_idx) < 60; } );
fa.pause(short_alarms);
// This pauses all alarms with less than 60 frames remaining
Returns the current amount of time an alarm has remaining in frames.
Argument | Type | Description |
---|---|---|
index | String/Number |
Sets the time remaining for an alarm. If this time is greater than the alarm's duration, the duration will also be changed.
Argument | Type | Description |
---|---|---|
index | String/Number | |
time | Number | Time in frames. |
Returns the duration of the alarm in frames.
Argument | Type | Description |
---|---|---|
index | String/Number |
Sets the duration of an alarm. This function will NOT adjust the alarm's time.
Argument | Type | Description |
---|---|---|
index | String/Number | |
duration | Number | Time in frames. |
Returns true if the alarm is running. Returns false if the alarm is paused or does not exist.
Argument | Type | Description |
---|---|---|
index | String/Number |
Returns true if the alarm exists, false if it does not.
Argument | Type | Description |
---|---|---|
index | String/Number |