Skip to content

Commit 88f7730

Browse files
Improved how items are added to wands
1 parent 2ac1807 commit 88f7730

File tree

1 file changed

+34
-16
lines changed

1 file changed

+34
-16
lines changed

HUD/HUD.gd

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -402,12 +402,29 @@ func _process(delta):
402402
var clicked_array: Array
403403
var clicked_array_max: int = 6
404404
var clicked_array_type: String = ""
405+
var doswap := true
405406
match clicked:
406407
1:
407408
if slot != -1:
408409
clicked_array = Items.player_wands[Items.selected_wand].spells
409410
clicked_array_max = Items.player_wands[Items.selected_wand].spell_capacity
410411
clicked_array_type = "spell"
412+
413+
doswap = false
414+
print(clicked_array.size(), slot)
415+
if clicked_array.size() == clicked_array_max or mouse_spell == null or clicked_array.size() <= slot or Input.is_key_pressed(KEY_SHIFT):
416+
doswap = true
417+
else:
418+
var new_array = []
419+
for i in clicked_array.size() + 1:
420+
if i < slot + 1:
421+
new_array.append(clicked_array[i])
422+
elif i == slot + 1:
423+
new_array.append(mouse_spell)
424+
else:
425+
new_array.append(clicked_array[i-1])
426+
Items.player_wands[Items.selected_wand].spells = new_array
427+
mouse_spell = null
411428
0:
412429
if slot != -1:
413430
clicked_array = Items.player_spells
@@ -425,22 +442,23 @@ func _process(delta):
425442
clicked_array_type = "wand"
426443

427444

428-
if slot < clicked_array.size():
429-
var k = clicked_array[slot]
430-
431-
if k is Spell:
432-
clicked_array[slot] = mouse_spell
433-
mouse_spell = k
434-
elif k is Wand:
435-
clicked_array[slot] = mouse_wand
436-
mouse_wand = k
437-
438-
elif slot <= clicked_array_max and clicked_array_type == "spell":
439-
clicked_array.append(mouse_spell)
440-
mouse_spell = null
441-
elif slot <= clicked_array_max and clicked_array_type == "wand":
442-
clicked_array.append(mouse_wand)
443-
mouse_wand = null
445+
if doswap:
446+
if slot < clicked_array.size():
447+
var k = clicked_array[slot]
448+
449+
if k is Spell:
450+
clicked_array[slot] = mouse_spell
451+
mouse_spell = k
452+
elif k is Wand:
453+
clicked_array[slot] = mouse_wand
454+
mouse_wand = k
455+
456+
elif slot <= clicked_array_max and clicked_array_type == "spell":
457+
clicked_array.append(mouse_spell)
458+
mouse_spell = null
459+
elif slot <= clicked_array_max and clicked_array_type == "wand":
460+
clicked_array.append(mouse_wand)
461+
mouse_wand = null
444462

445463
while clicked_array.find(null) != -1:
446464
clicked_array.remove(clicked_array.find(null))

0 commit comments

Comments
 (0)