|Attention||Topic was automatically imported from the old Question2Answer platform.|
I don’t know exactly if my question is right, but here is my problem. I have the following piece of code, which is called from another node:
extends Node var recursiveLoop_counter : int = 0 func updateChronology(tempoPriorities): var internPriorities = tempoPriorities var Priorities_order =  for i in internPriorities.size(): Priorities_order.append(0) recursiveLoop_counter = 0 OrderPriorities(internPriorities, Priorities_order) for i in range(1, min(internPriorities.size(), get_child_count())): get_node(str("ColorRect_NextTurn", i)).updateIcon(Priorities_order[i]) if internPriorities.size() < get_child_count(): var empty_slots : int = get_child_count() - internPriorities.size() for i in empty_slots: get_child(get_child_count()-1-i).removeChildren() func OrderPriorities(intPriorities, Priorities_order): var Highest_priority: float = -1 var ActiveCharacter: int = 0 for i in intPriorities.size(): if intPriorities[i] > Highest_priority: Highest_priority = intPriorities[i] ActiveCharacter = i Priorities_order[recursiveLoop_counter] = ActiveCharacter recursiveLoop_counter+=1 intPriorities[ActiveCharacter] = -1 if intPriorities.size()-recursiveLoop_counter > 0: OrderPriorities(intPriorities, Priorities_order) else: return Priorities_order
My problem is that it modifies the variable given in argument in the calling node.
For example, if in another node, I call it with this setup:
var ExampleArray = [5,4,1,2,8]
Then ExampleArray will be returned = [-1,-1,-1,-1,-1], althought it shouldn’t change at all.
I’m convinced it’s something with the functions previously written, as I can’t reproduce it on simpler cases, but impossible to see where it hurts…
Here is a link to the simpler case I could make to show this : GitHub_link
Thank you in advance <3