Updated SammiAPI

Updated get_deck_status() to properly return true or false if the deck is 1 or 0 for return
Updated modify_button() to be a variant, be it an int, color, or string to be passed for color.
This commit is contained in:
Mario Steele 2025-04-30 16:51:15 -05:00
parent 90e9f1f496
commit 16fcd30a6a

View file

@ -12,6 +12,7 @@ var client: SammiClient
var last_error: String = ""
var last_error_description: String = ""
func _ready() -> void:
client = SammiClient.new()
add_child(client)
@ -185,7 +186,7 @@ func get_deck_status(deck_id: String) -> bool:
last_error_description = res["Description"]
return false
else:
return true
return res["data"] == 1.0
else:
push_error("Error: %d: %s" % [response.code, response.error_message])
last_error = "HTTP Error: %d" % response.code
@ -277,7 +278,7 @@ func release_button(button_id: String) -> bool:
last_error_description = response.error_message
return false
func modify_button(button_id: String, text: String = "", color: int = -1, image: String = "", border: int = -1) -> bool:
func modify_button(button_id: String, text: String = "", color: Variant = null, image: String = "", border: int = -1) -> bool:
var api_path: String = "/api"
var req: Dictionary = {
"request": "modifyButton",
@ -285,8 +286,16 @@ func modify_button(button_id: String, text: String = "", color: int = -1, image:
}
if text != "":
req["text"] = text
if color != -1:
req["color"] = color
if color != null:
if color is int:
req["color"] = color
elif color is Color:
color.a = 0
req["color"] = color.to_abgr32()
elif color is String:
color = Color.from_string(color, Color.WHITE)
color.a = 0
req["color"] = color.to_abgr32()
if image != "":
req["image"] = image
if border != -1: