Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

Awesome Lists containing this project

README

        

Timers4TFM

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 here

local 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
Seniru Pasan Indira

๐Ÿ’ป
All Contributors
All Contributors

๐Ÿš‡
Lautenschlager
Lautenschlager

๐Ÿ’ป ๐Ÿ›
Ivรกn
Ivรกn

๐Ÿ›

This project follows the
[all-contributors](https://github.com/all-contributors/all-contributors)
specification. Contributions of any kind welcome!