Hi everybody! I'm experiencing the following problem in the bot i'm programming and I don't seem to be able to find the reason why it doesn't work:
I have a Global array TroopsInTown[101][10] which gets assigned a value in a function (TroopsInfo() ). If I call this function from the "main program" (i.e. not another function) the Global value of
an element in TroopsInTown[101][10] gets saved correctly and i can access it again later. (as in the code below; the two msgboxes give the same output)
However, if I call TroopsInfo() from inside another function (for istance I make the For loop in the code below a function, since i'm going to use the same sequence of functions a couple of times) then the value gets correctly assigned to TroopsInTown and it shows correctly in the message box inside "TroopsInfo", but the msgbox just after TroopsInfo is empty!! the only operation that it has done is exit the function and the value disappears as if it was a "Local variable" O.o
here is the code:
;non relevant Global $TroopsInTown[101][10], $ReturningTroops[101][151][11], $OutGoingTroops[101][151][11], $Hero ;non relevant For $ControlloNumeroVilli = 1 To $NumeroVilli SelectVillageNumber($ControlloNumeroVilli) FieldView() GetResourceFieldInfo() ;Call only in field view VillageView() GetBuildingsInfo() ;Call only in town view BuildingUnderConstructionInfo() ;Both field and town view are fine BarracksTraningCheck() ;Call only inside town view TroopsInfo() ;Call everywhere MsgBox(0,"", $TroopsInTown[$ControlloNumeroVilli][3]) Next ;non relevant Func TroopsInfo() ;the value of $TroopsInTown[$ControlloNumeroVilli][3] changes MsgBox(0,"", $TroopsInTown[$ControlloNumeroVilli][3]) Endfunc
thanks for the help