Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/foopis23/godot-interval-system
Godot plugin for executing a code snippet, with a fixed time delay between each call.
https://github.com/foopis23/godot-interval-system
gdscript godot godot-plugin
Last synced: 7 days ago
JSON representation
Godot plugin for executing a code snippet, with a fixed time delay between each call.
- Host: GitHub
- URL: https://github.com/foopis23/godot-interval-system
- Owner: foopis23
- Created: 2024-10-27T16:00:35.000Z (about 2 months ago)
- Default Branch: master
- Last Pushed: 2024-10-28T18:37:58.000Z (about 2 months ago)
- Last Synced: 2024-12-16T08:15:57.571Z (7 days ago)
- Topics: gdscript, godot, godot-plugin
- Language: GDScript
- Homepage:
- Size: 11.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Godot Interval System
Godot Plugin for executing a code snippet, with a fixed time delay between each call. This an alterative to Godot's Timer node.## Usage
Creating an interval is simple. Just call the `create` method with the interval time in seconds, the function to call, and optionally if the function should be called in idle time and the node that the interval is attached to (if any. Passing a node will clear the interval when the node is removed from the scene tree). The method will return an id that can be used to clear the interval.```
IntervalSystem.create(2, func(): print("hello world"), false, self)
```## Installation
1. Download the repository
2. Copy the `addons` folder to your project folder
3. Enable the plugin in the project settings## Notes
### Timing Accuracy
Intervals can only be processed once per frame process. Low frame rates can produce inaccurate interval times.## Reference
### IntervalSystem
#### Properties
| Type | Name |
| --- | --- |
| Dictionary | intervals |#### Methods
| Returns | Method |
| --- | --- |
| int | create(intervalInSeconds: float, callable: Callable, deferred = false, src: Node = null) |
| bool | clear(intervalId: int) |### Property Descriptions
#### Dictionary intervals = {}
The dictionary containing all the intervals### Method Descriptions
#### int create(intervalInSeconds: float, callable: Callable, deferred = false, src: Node = null) -> int
Creates a new interval that will call "callable" every "intervalInSeconds" seconds. If "deferred" is true, the function will be called in idle time. If "src" is not null, the interval will automatically clean itself up when the node is deleted. Returns the interval id for manual cleanup.#### clear(intervalId: int) -> bool
Clears the interval with the given id. Returns true if the interval was cleared, false if it was not found.### Interval
#### Properties
| Type | Name |
| --- | --- |
| int | id |
| float | intervalInSeconds |
| Callable | callable |
| bool | deferred |
| Node | src |
| float | elapsed |#### Methods
| Returns | Method |
| --- | --- |
| void | _init(_id: int, _intervalInSeconds: float, _callable: Callable, _deferred = false, _src: Node = null) |
| void | run() |### Property Descriptions
#### int id
The id of the interval#### float intervalInSeconds
The time between each call#### Callable callable
The function to call each time#### bool deferred
If the function should be called in idle time#### Node src
The node that the interval is attached to (if any). This is used to automatically clean up the interval when the node is deleted#### float elapsed
The time elapsed since the last call### Method Descriptions
#### void _init(_id: int, _intervalInSeconds: float, _callable: Callable, _deferred = false, _src: Node = null)
Constructor for the interval#### void run()
Runs the callable and handles deferred vs immediate execution