Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/seniru/timers4tfm
A library which provides easy and advanced timers for module developers
https://github.com/seniru/timers4tfm
library timers transformice transformice-lua-api
Last synced: about 1 month ago
JSON representation
A library which provides easy and advanced timers for module developers
- Host: GitHub
- URL: https://github.com/seniru/timers4tfm
- Owner: Seniru
- License: mit
- Created: 2019-10-04T12:28:28.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2020-04-27T07:01:05.000Z (over 4 years ago)
- Last Synced: 2024-08-07T18:36:48.370Z (5 months ago)
- Topics: library, timers, transformice, transformice-lua-api
- Language: Lua
- Homepage: https://seniru.github.io/Timers4TFM/
- Size: 83 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Timers4TFM
[![All Contributors](https://img.shields.io/badge/all_contributors-4-orange.svg?style=flat-square)](#contributors)
![GitHub file size in bytes](https://img.shields.io/github/size/Seniru/Timers4TFM/src/timer.min.lua?label=Code%20size%20%28minified%29&style=flat-square)
![GitHub Workflow Status](https://img.shields.io/github/workflow/status/Seniru/Timers4TFM/Build?logo=github&style=flat-square)
![CodeFactor Grade](https://img.shields.io/codefactor/grade/github/Seniru/Timers4TFM?logo=codefactor&style=flat-square)
![GitHub](https://img.shields.io/github/license/Seniru/Timers4TFM?style=flat-square)
![GitHub release (latest by date including pre-releases)](https://img.shields.io/github/v/release/Seniru/Timers4TFM?include_prereleases&style=flat-square)> A library which provides easy and advanced timers for module developers
> :warning: This library is still in beta phase. Use at your own risk!
> Contributions are always welcome## What is this?
**A library which provides easy and advanced timers for module developers.**
This project is inspired by
[mk's timer library](https://atelier801.com/topic?f=6&t=875052), make sure to
support that project too :heart:**_Background_**
As normal players - who aren't in module team - aren't allowed to use the Module
API's timers (`system.newTimer` and `system.removeTimer`), I decided to create a
brand new, advanced timer system for the benefit of all!**_There are many capabilities for these timers_**
- Create timers
- Reset timers
- Kill timers
- Loop timers
- Execute functions after/before mature
- And more!## How to use?
To use this library you need to insert this libraries code in top of your code.
[Use the full code _(Recommended for studying)_](https://raw.githubusercontent.com/Seniru/Timers4TFM/master/src/timer.lua)
|
[Use the minified version _(Recommended for production use)_](https://raw.githubusercontent.com/Seniru/Timers4TFM/master/src/timer.min.lua)
## Examples
#### Creating new timer
```lua
--insert the library code herelocal timer1 = Timer("timer1", function() end, 5000, false) -- Creating a very basic timer with a timeout value of 5000
function eventLoop()
Timer.process() -- You need to call this method inside eventLoop to start and process timers
end```
[Documentation](https://seniru.github.io/Timers4TFM/docs/src/1.html)
### Creating timers with callbacks
```lua
--a function to greet a user
function greet(name, nice)
print("Hello" .. name .. "It seems you are " .. (nice and "nice" or "not nice"))
end-- storing the timer in a variable is optional. Storing will be useful if you need to access information about the timer
Timer("callback", greet, 2000, false, "Seniru", true) --setting the callback to our greet function and pass "Seniru" and true as arguments
function eventLoop()
Timer.process()
end--Run this code to see the results!
```
[Documentation](https://seniru.github.io/Timers4TFM/docs/src/1.html)
### Looping timers
```lua
Timer("looping", function() print("prints") end, 3000, true)
-- This would print `prints` every 3 seconds. Note that you need to specify the time in milliseconds```
[Documentation](https://seniru.github.io/Timers4TFM/docs/src/1.html)
# Contributing
Do you want to contribute this project? Great! There are many way that you can
involve!Creating issues
You can create issues for,
- Something is not working (bug)
- Suggestion / Feature request
- General questions
Creating PRs
You can submit a PR for,
- Bug fixes
- Improvements
- Additions of new features
- Minor fixes (such as fixing a typo)
Please, make sure that you have searched well before creating a new issue or a
pull request. I'm actively responding to all kind of contributions :smile:
## Contributors โจ
Thanks goes to these wonderful people
([emoji key](https://allcontributors.org/docs/en/emoji-key)):
Seniru Pasan Indira
๐ป
All Contributors
๐
Lautenschlager
๐ป ๐
Ivรกn
๐
This project follows the
[all-contributors](https://github.com/all-contributors/all-contributors)
specification. Contributions of any kind welcome!