iOS Issue with Referencing Static Functions

Godot Version

v4.4.1

Question

I’m trying to use a “check” and “apply” function in a card game script that changes based on which card is played. I have resources for each card that include things like name, description, sprite etc as well as a script reference. The script has the “check” and “apply” functions.

Essentially, I want to dynamically execute these functions based on which card is being played. I’m running into an issue where the version on my computer works, but my iOS build fails to call the function (stating it doesn’t exist). I believe this is because the version on my computer is pre-complied? Either way I think I am doing something incorrectly.

card resource script:

extends Node

static func check(board: Board) -> bool:
	var normalized_array = board.get_normalized_ducks()
	if normalized_array.size() != 1:
		board.error.emit("Exactly 1 Duck must be selected")
		return false
	elif normalized_array[0] is not int:
		board.error.emit("No Duck selected")
	return true
	#return normalized_array.size() == 1 and normalized_array[0] is int

static func apply(board: Board) -> void:
	board.abduckt()

And I’m calling those functions here:

if card_to_play is ActionCard:
	if board.get_selected_duck_array() != []:
		var script = card_to_play.card_data.script_ref
		if script.check(board):
			script.apply(board)
			action_card_manager.remove_card(card_being_dragged)
			board.convert_to_colors()
		else:
			board.deselect()

I’m probably not approaching resources correctly here maybe?

Thanks for any help!

What is script_ref?

script_ref is the gd script referenced in the original post (with check and apply functions)

How do you assign this? Perhaps print its value just before calling the functions.

A Card object has a CardData variable that gets assigned to it. Then the script is referenced from that CardData variable

What does script.has_method("check") return?

It returns “true”, but that’s when I’m running it locally. On iOS, it causes an issue - I think because the code for the static functions “check” and “apply” are not compiled yet when they are called running on mobile.

I’m starting to think I may need to restructure the cards. If I have a base Card class, I could use inheritance to extend that class into sub-classes for each card. Those would then override the default “check” and “apply” functions. I’m not sure how to integrate that with my current resources though

Why is your resource script extending Node? Shouldn’t it be extending Resource?