{"id":13528688,"url":"https://github.com/Lojemiru/Stopwatch","last_synced_at":"2025-04-01T14:32:45.612Z","repository":{"id":162756641,"uuid":"357477609","full_name":"Lojemiru/Stopwatch","owner":"Lojemiru","description":"A simple, control-focused replacement for GameMaker: Studio 2 alarms.","archived":false,"fork":false,"pushed_at":"2022-10-28T23:58:53.000Z","size":43,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-02T15:35:56.413Z","etag":null,"topics":["alarms","gamemaker","gamemaker-studio","gamemaker-studio-2"],"latest_commit_sha":null,"homepage":"","language":"Yacc","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Lojemiru.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2021-04-13T08:22:46.000Z","updated_at":"2023-01-14T16:29:17.000Z","dependencies_parsed_at":"2023-05-31T17:00:26.715Z","dependency_job_id":null,"html_url":"https://github.com/Lojemiru/Stopwatch","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lojemiru%2FStopwatch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lojemiru%2FStopwatch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lojemiru%2FStopwatch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lojemiru%2FStopwatch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Lojemiru","download_url":"https://codeload.github.com/Lojemiru/Stopwatch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246655215,"owners_count":20812600,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["alarms","gamemaker","gamemaker-studio","gamemaker-studio-2"],"created_at":"2024-08-01T07:00:22.789Z","updated_at":"2025-04-01T14:32:45.207Z","avatar_url":"https://github.com/Lojemiru.png","language":"Yacc","funding_links":[],"categories":["Timing"],"sub_categories":["Recommendations"],"readme":"# Deprecation\n\nI am moving on from GameMaker in general. I will provide support for this library as best possible if people still express interest in it, but I will not be actively using it and will be unlikely to add new features. Not that this simple library needed any in the first place.\n\nPull requests and issues will still be addressed, but you may get better long-term mileage with a fork.\n\n# Stopwatch\nA simple, control-focused replacement for GameMaker: Studio 2.3 alarms.\n\n## Why replace the default alarms?\n\nGameMaker alarms are convenient but somewhat limited. They create code that is difficult to read (*what does alarm[7] do, again?*),\nmust be manually looped, and - worst of all - are unable to be paused in any convenient fashion.\n\nStopwatch addresses all of these issues in an efficient, easy-to-use fashion.\n\n## Structs\n\n```\nAlarm(time, function, [loop], [resetTime])\n```\n\nA struct that will trigger a function once its internal timer has reached zero.\n\n*Note: If not looped, an Alarm's internal timer will immediately be set to negative one when it reaches zero to prevent its function from running multiple times.*\n\n| Argument | Description |\n| :--- | :--- |\n| time {int} | The starting value for the Alarm, and the default value to reset to if looped or `restart()`ed. |\n| function {function} | The function to run when the Alarm reaches zero. Function variables are encouraged, but global-scope ones will work as well. |\n| [loop] {bool} | Optional. False by default. Causes the Alarm to loop back to its initial `time` value once it reaches 0. |\n| [resetTime] {int} | Optional. `time` by default. Custom value to use on `restart()` or loop. |\n\n| Internal function | Description |\n| :--- | :--- |\n| run() | Causes the Alarm to tick down by one. Will trigger the `function` when it reaches zero and restart the countdown if `loop` was set to `true`. |\n| restart() | Resets the Alarm timer to its initial value. |\n\n## Functions\n\n| Function | Description |\n| :--- | :--- |\n| run_alarm(alarm) | Safely runs a single Alarm, exiting if it does not exist. |\n| run_alarms(array) | Safely runs an array of Alarms using `run_alarm`. |\n| create_alarm_array(size) | Returns an array of the given size, initialized to `noone` and ready to be populated with Alarms. |\n\n## How to use\n\nFirst, you'll need to [download the latest version](https://www.github.com/Lojemiru/Stopwatch/releases/latest) and import the Stopwatch script into your project.\nYou could also be doing this in the repository demo project.\n\nAn Alarm can be instantiated as follows:\n\n```gml\ntest_function = function() {\n  show_debug_message(\"test function run!\");\n}\ntimer = new Alarm(60, test_function);\n``` \n\nIt can then be run in a step event as follows:\n\n```gml\nif (global.paused) exit;\nrun_alarm(timer); // You could use timer.run() instead, but this ensures that we will not induce a crash if timer is noone.\n```\n \nA global pause variable is shown here to demonstrate the primary purpose of Stopwatch: only causing Alarms to count down when you intend for them to.\nThis allows you to use Alarms in tandem with a global pause system without having to define your own timer logic in every object that needs to run an event on a delay!\n\n## Other use cases\n\nWant an Alarm to automatically loop instead of re-initializing it in the triggered function? Just set the optional `loop` parameter to true!\n\n```gml\ntimer = new Alarm(120, test_function, true);\n```\n\nNeed to have a different starting countdown from the loop time? Use the optional `resetTime` parameter to set the loop time value.\n\n```gml\ntimer = new Alarm(1, test_function, true, 60);\n```\n\nDo you need to process Alarms in bulk or quickly replace default alarms? Use the array-based functions!\n\n```gml\nalarms = create_alarm_array(3);\nalarms[0] = new Alarm(25, test_function);\n// Skipping alarms[1] to show that you can leave this empty and instantiate it later when you want it to start counting!\nalarms[2] = new Alarm(40, test_function, true);\n```\n\nIn the step event:\n\n```gml\nif (global.paused) exit;\nrun_alarms(alarms);\n```\n\n## Licensing\n\nThis extension/repository is licensed under the MIT License. Attribution in the \"special thanks\" or similar section of your game credits is appreciated, but not required so long as the MIT License's conditions are met.\n\n## Special thanks\nYoYo Games: Creating this wonderful bowl of pixel-flavored spaghetti we call GameMaker.\n\nM3D: Showing me how to pass function references to structs for a previous utility.\n\nJuJu Adams: Leaving an interesting comment on a discussion about structs that got me to poke at the behavior of the `other` keyword in relation to structs.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLojemiru%2FStopwatch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FLojemiru%2FStopwatch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLojemiru%2FStopwatch/lists"}