Repository navigation
Mod Author Instructions
We provide the signals
- minute_has_passed
- hour_has_passed
- day_has_passed
If you want to for example run something every hour/minute or count how many hours/minutes have passed then run something.
These signals pass a mode agnostic time variable along with signal emission, meaning you don't have to use check_time() on every emission of one of these, just take in the time variable that is passed to your function.
- second_has_passed
This is provided but isn't encouraged for performance reasons, only use it if you REALLY need it and if you do use it, be very mindful of performance as in the case of in-game time, it's running very frequently.
- time_has_jumped
This will be useful for the future multiplayer integration, time_has_jumped will be emitted whenever anything relating to time needs to be synced instantly instead of on the next hour/minute tick. Joining a multiplayer lobby, once the time var is synced to the player, time_has_jumped will be emitted, telling you to update your mod's world-state/features to match the currently reflected time as it likely just changed/jumped beyond the normal amount and your mod needs to be re-synced to it.
This signal passes a mode agnostic time variable so you don't have to run check_time() on every emission, just take in the time variable that is passed to your function.
- config_has_updated
For when your mod depends on a specific LSTAPI user setting, you can listen for this and update your mod's state to the new config. This is provided so you don't have to depend on TackleBox yourself which is usually required for this functionality.
This signal passes the newly updated config so you don't have to re-fetch the config on emission, just take in the config variable that is passed to your function and do whatever with it, update it in that function or call an existing function that takes in a config and updates your mod according to it.
check_time() returns a dictionary of either the real life time or the in-game time (Default) depending on the users LSTAPI config. When you write your logic with check_time() it will be agnostic to either real time or LSTAPI's in-game time.
get_hour(), get_minute() and get_second(), for those who don't like using dictionaries you can grab the hour, minute or second as ints and write your logic with an int instead of a dictionary.
If you want a more real world example check out LonelyStars.
While it is LSTAPI's official companion mod, it uses the API like any other mod would, so it's great for demonstration purposes.
onready var LSTAPI = get_node_or_null("/root/LSTAPI")
onready var LSTAPI = get_node_or_null("/root/LSTAPI")
func _ready():
if LSTAPI != null:
LSTAPI.connect("minute_has_passed", self, "_on_minute_update")
func _on_minute_update(current_time):
print("Minute has updated.")
onready var LSTAPI = get_node_or_null("/root/LSTAPI")
var current_time
func _ready():
if LSTAPI != null:
LSTAPI.connect("minute_has_passed", self, "_on_minute_update")
func _on_minute_update(current_time):
if current_time["hour"] != 5:
print("Hour is not 5. Returning.")
return
print("Current Minute is: " + str(current_time["minute"])
if current_time["minute"] == 27:
print("Minute is 27. Do a thing!")
onready var LSTAPI = get_node_or_null("/root/LSTAPI")
var LSTAPI_config
func _ready():
if LSTAPI != null:
LSTAPI.connect("config_has_updated", self, "_on_config_update")
LSTAPI_config = LSTAPI.config
_scan_config()
func _scan_config():
if LSTAPI_config["real_time"] == true:
print("LSTAPI RealTime setting is being used.")
func _on_config_update():
LSTAPI_config = LSTAPI.config
_scan_config()
onready var LSTAPI = get_node_or_null("/root/LSTAPI")
func _ready():
if LSTAPI != null:
LSTAPI.connect("time_has_jumped", self, "_on_time_jump")
func _on_time_jump():
print("Update the worldstate NOW instead of the next hour/minute tick!!!")