31 lines
947 B
GDScript
31 lines
947 B
GDScript
extends Node
|
|
|
|
#if you have an error setting achievements or stats in debug mode remember to open your steam client
|
|
#with jmp games account or another account who bought this game. If error persist try to clos and reopen steam client.
|
|
|
|
const APP_ID: int = 4809260 #Train Goes Choo Choo
|
|
|
|
var is_on_steam: bool = false
|
|
|
|
func _init() -> void:
|
|
OS.set_environment("SteamAppId", str(APP_ID))
|
|
OS.set_environment("SteamGameId", str(APP_ID))
|
|
|
|
func _ready() -> void:
|
|
process_mode = Node.PROCESS_MODE_ALWAYS
|
|
|
|
var init := Steam.steamInitEx()
|
|
if init['status'] != Steam.STEAM_API_INIT_RESULT_OK:
|
|
push_error("Steam not initialized: %s" % init['verbal'])
|
|
return
|
|
|
|
is_on_steam = true
|
|
Steam.overlay_toggled.connect(_on_overlay_toggled)
|
|
|
|
func _process(_delta: float) -> void:
|
|
if is_on_steam:
|
|
Steam.run_callbacks() #every frame, forever
|
|
|
|
func _on_overlay_toggled(active: bool, _user_initiated: bool, _app_id: int) -> void:
|
|
get_tree().paused = active
|