Dexter1993 Posted November 30, 2021 Share Posted November 30, 2021 (edited) Hello guys, I have an Array (buildings) and now I want to select them with a condition XY (_check). Only if the _check is True, the property should be shared. It must be taken out of the Buildings array completely. The script gets a certain number of buildings and over time more and more are taken away until there are none left in the array. I need a script that goes through an array and whenever a variable is not true, the exact position must be removed from the array. Global $building_1 = [1,2,3,4,"building_1") Global $building_2 = [5,6,7,8,"building_2") Global $building_3 = [9,10,11,12,"building_3") Global $all_Datas[][] = [[$building_1[0], $building_1[1], $building_1[2], $building_1[3],$building_1[4]] _ ,[$building_2[0], $building_2[1], $building_2[2], $building_2[3],$building_2[4]] _ ,[$building_3[0], $building_3[1], $building_3[2], $building_3[3],$building_3[4]]] While 1 $arrayLength = UBound($all_Datas, 1) - 1 Local $shared_array = [] For $i = 0 To $arrayLength Step +1 If _check($all_Datas[$i][0], $all_Datas[$i][1], $all_Datas[$i][2], $all_Datas[$i][3]) Then _ArrayInsert($shared_array, $i, $all_Datas[$i][4]) Else _ArrayDelete ($all_Datas,$i) EndIf Next _ArrayDisplay($shared_array,"All shared Array.") _ArrayDisplay($all_Datas,"All remaining Buildings") WEnd Thx Edited December 1, 2021 by Dexter1993 Link to comment Share on other sites More sharing options...
Solution Dexter1993 Posted December 1, 2021 Author Solution Share Posted December 1, 2021 I solved it myself: expandcollapse popup_searching() Func _searching() $arrayLength = UBound($all_datas) - 1 If $arrayLength = 0 Then MsgBox (1,"","Array is completly clear!") _ArrayDisplay($all_datas,"All remaining datas") Exit Else For $i = 0 To $arrayLength Step +1 If not _check() Then _ArrayDelete ($all_datas,$i) _searching() EndIf Next endif EndFunc ; checker Func _check() $random = Random(1,2,1) If $random = 1 Then Return True Else Return False EndIf EndFunc Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now