-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathslots.gd
More file actions
29 lines (24 loc) · 715 Bytes
/
Copy pathslots.gd
File metadata and controls
29 lines (24 loc) · 715 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#Ugly solution, but faster than move entire children.
@tool
extends Node2D
@export var sl_oder = [] : set = slots_oder
func set_rest():
if get_children().size()!=0:
for i in get_children().size():
get_child(i).z_index=i
func to_rest():
if get_children().size()!=0:
for i in get_child_count():
get_child(i).z_index=i
func slots_oder(arr=[]):
if not (sl_oder==arr):
sl_oder=arr.duplicate();
to_rest()
if get_children().size()!=0 && arr.size()!=0 && arr.size()%2==0:
var buf = get_children();
for i in range(0,arr.size(),2):
buf.erase(get_child(arr[i]))
for i in range(0,arr.size(),2):
buf.insert(arr[i]+arr[i+1],get_child(arr[i]))
for i in buf.size():
buf[i].z_index=i