Easy Solution For Equip System / Open BoolArray Check System

Godot Version

v4.6.3

(I’m somewhat a rookie)

Question

I’m currently working on an Equip system that relies on sets of 3 sizes of Modifiers, each taking up to 3 slots in the modifier, and I’m having a hard time figuring out a clean way to be able to check for consecutive rows of false in a bool array and have each upgrade modifier remember which index correlates to which bool, and be able to arrange those in any order.

I struggled thinking of a solution for this, to the point that I tried with some Text Bot solutions to see how those would do it, and those were almost functional. This is the closest I got to a solution, but it still had some holes in ordering (See in video).

func Check(Req):
	if slots.OpenSpots >= 1:
		for I in range(slots.Slots.size() - Req + 1):
			var Open = true
			for Q in range(Req):
				if slots.Slots[I+Q] == true:
					Open = false
					break
			if Open == true:
				for Q in range(Req):
					ActSlots.append(I + Q)
					slots.Slots[I + Q] = true
					match (I + Q+1):
						1: SQ1.color = Clr
						2: SQ2.color = Clr
						3: SQ3.color = Clr
						4: SQ4.color = Clr
						5: SQ5.color = Clr
						6: SQ6.color = Clr
				break
func _pressed():
Active = !Active
if Active and Owned:
SavedVars.set(SavedVarCorel, true)match Size:
“Small”:Clr = “Green”
if slots.OpenSpots >= 1:
Check(1)slots.OpenSpots -= 1
		"Medium":
			Clr = "Yellow"
			if slots.OpenSpots >= 2: 
				Check(2)
				slots.OpenSpots -= 2

		"Large":
			Clr = "Red"
			if slots.OpenSpots >= 3: 
				Check(3)
				slots.OpenSpots -= 3

else:
	SavedVars.set(SavedVarCorel, false)
	for I in ActSlots:
		slots.Slots[I] = false
		slots.OpenSpots += 1
	ActSlots.clear()

You have a problem in your indentation in your second code block there. Might want to fix it so we can read it. Also, is this C# or GDScript, because you’re writing it like it’s C# but in your post you indicated you were not using Mono.