Доработка. Контроль прибора РТР
Доработка. Контроль прибора РТР
This commit is contained in:
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user