Доработка. Контроль прибора РТР

Доработка. Контроль прибора РТР
This commit is contained in:
sasha80
2024-06-10 08:36:39 +03:00
parent a50daf51df
commit 99a6cd6b2c
6 changed files with 165 additions and 81 deletions

View File

@@ -30,12 +30,14 @@ func is_overlap(x1, x2, y1, y2) -> bool: return max(x1, y1) <= min(x2, y2)
func _check_index(obj, index) -> bool:
if (obj is Dictionary) and not obj.has(index):
return false
elif (obj is Array) and (index is int):
if index < 0 and index >= obj.size():
return false
return true
if obj is Dictionary:
if obj.has(index):
return true
elif obj is Array:
if index is int:
if (index >= 0) and (index < obj.size()):
return true
return false
## Возвращает значение поля хранящегося по указанному пути внутри объекта.[br]
@@ -47,17 +49,14 @@ func _check_index(obj, index) -> bool:
## и [b]false[/b], если иначе.
func get_value_by_path(obj, paths: Array, ret_val: Array):
var index = paths.pop_at(0)
ret_val[1] = false
if paths.size():
if _check_index(obj, index):
get_value_by_path(obj[index], paths, ret_val)
else:
return false
else:
if _check_index(obj, index):
ret_val[0] = obj[index]
else:
return false
return true
ret_val[1] = true
## Возвращает часть от входной строки ограниченную индексами символов.[br]