Home   Help Search Login Register  

Author Topic: Array Help [GIVEN UP + CLOSED]  (Read 2840 times)

0 Members and 1 Guest are viewing this topic.

Offline Rommel92

  • Members
  • *
Array Help [GIVEN UP + CLOSED]
« on: 16 Jun 2008, 01:19:01 »
The script below deletes Groups out of an array which is setup like this: [[Group1,Group2,Group3,Group4],[Group1,Group2,Group3,Group4],[Group1,Group2,Group3,Group4]] etc. It is designed to only delete only one of the sets of four. It does this great, however a trace (<NULL-GROUP>) is left behind, and I can't figure how to remove it.  :dunno:
Code: (Disband.sqf) [Select]
_Disband =
{
private ["_group"];

_group = _this select 0;

{deleteVehicle _x} forEach units _group;
deleteGroup _group;
};

_side = _this select 0;
_platoon = _this select 1;

player groupChat format ["%1", _this];

_company = call compile format["%1COMPANY",_side];
_platoon = _company select (_platoon - 1);

player groupChat format ["%1 --- %2", _company, _platoon];

{[_x] call _Disband} forEach _platoon;

_platoon = _platoon - _platoon;

player groupChat format ["%1 --- %2", _company, _platoon];

Solved

Sorry about this Mods, I won't post in future, I solve me own problems to quick... minimum two hours plus screaming only for posting up in future I thinks.

 :P

Code: [Select]
{[_x] call _Disband} forEach _platoon;

_platoon = _platoon - _platoon;

call compile format["%1COMPANY set [%2, %3]", _side, (_platoonN - 1), _platoon];

player groupChat format ["%1 --- %2", _company, _platoon];
Was the answer... Forgot _platoon is local the script cause its a local variable...  :whistle:
« Last Edit: 19 Jun 2008, 01:14:11 by Rommel92 »

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Array Help [SOLVED]
« Reply #1 on: 16 Jun 2008, 13:31:03 »
This looks very, very fishy to me:
Code: [Select]
_platoon = _platoon - _platoon;
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Rommel92

  • Members
  • *
Re: Array Help [NOT SOLVED ANYMORE]
« Reply #2 on: 16 Jun 2008, 14:03:32 »
hehe.


WESTCOMPANY = [[WEST 1-1-B],[],[],[]]

Code: [Select]
private ["_num","_sqdNum","_result"];

_num = _this select 0;

_MenuSquads = [[ ["Item", "-"] ]];
{
_MenuSquads = _MenuSquads +
[
[["Item", format["%1 >",_x]],["SubMenu", format["%1",_x] + "SMenu"]]
]
} forEach call compile format ["%1COMPANY select %2", side player, _num - 1];

_MenuSquads = _MenuSquads + [[ ["Item", "-"] ],[ ["Item", "Close Menu"],["Close", true]]];


//////-----------------------------------------------------------------------------//////


_MenuInnerSquads = [];
{
call compile format["%1Result = %1COMPANY select %2 find '%3'", side player, _num - 1, _x];

player globalChat format ["%1",call compile format["%1Result", side player]];
_MenuInnerSquads = _MenuInnerSquads +
[
[format["%1",_x] + "SMenu",
[
["Caption", format["%1",_x]],
["Items",
[
[ ["Item", "-"] ],
[ ["Item", "Waypoints >"], ["SubMenu","Waypoints"], ["Action",format["%1Result = %1COMPANY select %2 find '%3'", side player, _num - 1, _x]], ["Close", false]],
[ ["Item", "Formation >"], ["SubMenu","Formations"]],
[ ["Item", "-"] ],
[ ["Item", "Open Fire"], ["Action", ""], ["Close", false] ],
[ ["Item", "Hold Fire"], ["Action", ""], ["Close", false] ],
[ ["Item", "-"] ],
[ ["Item", "Hold Position"], ["Action", ""], ["Close", false] ],
[ ["Item", "-"] ],
[ ["Item", "Close Menu"],["Close", true]]
]
]
]
]
]
} forEach call compile format ["%1COMPANY select %2", side player, _num - 1];


//////-----------------------------------------------------------------------------//////


_MenuWaypoints = [[ ["Item", "-"] ]];
{
_MenuWaypoints = _MenuWaypoints +
[
[ ["Item", _x] ,["Action", format["[[%1,%2] '%3'] call compile preProcessFile ''Scripts\TCIM\Waypoint.sqf''",_num,call compile format ["%1Result", side player],_x]], ["Close", true] ]
]
} forEach ["MOVE", "SAD", "GETIN NEAREST", "GETOUT", "TR UNLOAD", "GUARD", "SENTRY", "CLEAR ALL"];


//////-----------------------------------------------------------------------------//////


_MenuWaypoints = _MenuWaypoints + [[ ["Item", "-"] ],[ ["Item", "Close Menu"],["Close", true]]];

_MenuFormations = [[ ["Item", "-"] ]];
{
_MenuFormations = _MenuFormations +
[
[["Item", _x],["Action", ""], ["Close", true]]
]
} forEach ["COLUMN", "STAG COLUMN", "WEDGE", "ECH LEFT", "ECH RIGHT", "VEE", "LINE", "FILE", "DIAMOND"];

_MenuFormations = _MenuFormations + [[ ["Item", "-"] ],[ ["Item", "Close Menu"],["Close", true]]];

_MenuStructureArray =
[
["MainMenu",
[
["Caption", "Squads"],
["Items", _MenuSquads]
]
],
["Waypoints",
[
["Caption", "Waypoints"],
["Items", _MenuWaypoints]
]
],
["Formations",
[
["Caption", "Formations"],
["Items", _MenuFormations]
]
]
] + _MenuInnerSquads;


//////-----------------------------------------------------------------------------//////


_MenuStructureArray execVM "Dialogs\TCIM.sqf";
Issue:

Error in expression <[2871] call PUM3_ClickButton; [[1,-1] 'MOVE'] call compile preProcessFile ''Sc>
  Error position: <'MOVE'] call compile preProcessFile ''Sc>
  Error Missing ]


Also, the find isn't working.

HELP ME OFPEC. PLEASE!
 :weeping: :weeping: :weeping:


DESIRED RESULT
Code: [Select]
[[1,0], "MOVE"] execVM "WAYPOINT.SQF"
etc.

7 hours and counting on this one issue.
« Last Edit: 16 Jun 2008, 14:08:42 by Rommel92 »

Offline Rommel92

  • Members
  • *
Re: Array Help [NOT SOLVED]
« Reply #3 on: 16 Jun 2008, 23:30:00 »
Nah no semi-colons were missing mate. Its simply a string error. I just can't get it figured...  :no:

Offline loki72

  • Former Staff
  • ****
    • Loki's Nightmare
Re: Array Help [NOT SOLVED]
« Reply #4 on: 16 Jun 2008, 23:37:19 »
greetings,

just looking through your post.. this looks suspect

Code: [Select]
[format["%1",_x] + "SMenu",
i do see the other bracket it 'should have' at the bottom... have you tried the script without the added hint?

just throwing my 2 cents in :whistle:
« Last Edit: 16 Jun 2008, 23:39:33 by loki72 »

Offline Rommel92

  • Members
  • *
Re: Array Help [NOT SOLVED]
« Reply #5 on: 16 Jun 2008, 23:43:35 »
String of _x + "SMenu" = "_x" + "SMenu"

Say _x = 1.

"1SMenu".

These are dynamic arrays for a dialog.

Offline loki72

  • Former Staff
  • ****
    • Loki's Nightmare
Re: Array Help [NOT SOLVED]
« Reply #6 on: 16 Jun 2008, 23:48:36 »
right.. but i am only asking if this.

Code: [Select]
[format["%1",_x] + "SMenu",
should be this?
Code: [Select]
[format["%1",_x]] + "SMenu",
i've been trying to figure out the same dialog system and these questions, i am sure, will have bearing on what i do in the future.


« Last Edit: 16 Jun 2008, 23:50:56 by loki72 »

Offline Rommel92

  • Members
  • *
Re: Array Help [NOT SOLVED]
« Reply #7 on: 16 Jun 2008, 23:59:15 »
Negative.

Its right the way it is, that menu works fine, if anyone wants I'll upload the mission to show.

Offline loki72

  • Former Staff
  • ****
    • Loki's Nightmare
Re: Array Help [NOT SOLVED]
« Reply #8 on: 17 Jun 2008, 00:04:46 »
don't know if i'll be a help but i'd be happy to load it up and give it a go.

Offline Rommel92

  • Members
  • *
Re: Array Help [NOT SOLVED]
« Reply #9 on: 17 Jun 2008, 00:06:38 »
There you go. Be back in 6 hours.

Offline loki72

  • Former Staff
  • ****
    • Loki's Nightmare
Re: Array Help [NOT SOLVED]
« Reply #10 on: 17 Jun 2008, 01:52:34 »
hmmm.. here's what i found.. and will need another to explain it to me.

it appears the issue is in this section:

order.sqf
Code: [Select]
_MenuWaypoints = _MenuWaypoints +
[
[ ["Item", _x] ,
["Action", format["[[%1,%2] '%3']  call compile preProcessFile ''Scripts\TCIM\Waypoint.sqf''",
_num, call compile format ["%1Result", side player],_x]],
["Close", true] ]
]

looks like this:


however.. by adding a "  it looks like this:



i'm not afraid to say it... this is beyond my current level of understanding...  :P


« Last Edit: 17 Jun 2008, 01:54:36 by loki72 »

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Array Help [NOT SOLVED]
« Reply #11 on: 17 Jun 2008, 13:54:47 »
Well, what does:
Code: [Select]
hint format["[[%1,%2] '%3']  call compile preProcessFile ''Scripts\TCIM\Waypoint.sqf''",1,0, "MOVE"]display? And why do you say you want execVM "Scripts\TCIM\Waypoint.sqf'' when you have put call compile preProcessFile ''Scripts\TCIM\Waypoint.sqf''?
After the ["Action", do you require a string or a code string?
If a string, and assuming you want execVM
Code: [Select]
_MenuWaypoints = _MenuWaypoints +
[
[ ["Item", _x] ,
["Action", format["""[[%1,%2] '%3']  execVM "''Scripts\TCIM\Waypoint.sqf''"",
_num, call compile format ["%1Result", side player],_x]],
["Close", true] ]
]

urp!

Offline Rommel92

  • Members
  • *
Re: Array Help [NOT SOLVED]
« Reply #12 on: 18 Jun 2008, 00:02:48 »
I was just referring to get it working, I havent got my PC for a week, so one of you guys could try out the solutions I'd be really thankful... else just post a few more possible answers and I'll try em on the weekend.

 :good:

Thanks guys.

Offline loki72

  • Former Staff
  • ****
    • Loki's Nightmare
Re: Array Help [NOT SOLVED]
« Reply #13 on: 18 Jun 2008, 00:15:03 »
here's what i put:

Code: [Select]
_MenuWaypoints = [[ ["Item", "-"] ]];
{
_MenuWaypoints = _MenuWaypoints +
[
[ ["Item", _x] ,
["Action", format["""[[%1,%2] '%3']  execVM "''Scripts\TCIM\Waypoint.sqf''"",
_num, call compile format ["%1Result", side player],_x]],
["Close", true] ]
]
} forEach ["MOVE", "SAD", "GETIN NEAREST", "GETOUT", "TR UNLOAD", "GUARD", "SENTRY", "CLEAR ALL"];



here's what i got...



sry...
« Last Edit: 18 Jun 2008, 00:30:45 by loki72 »

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Array Help [NOT SOLVED]
« Reply #14 on: 18 Jun 2008, 17:54:05 »
Missed a quote. Ugh. Two guesses:
Code: [Select]
_MenuWaypoints = _MenuWaypoints +
[
[ ["Item", _x] ,
["Action", format["""[[%1,%2] ""%3""]  execVM "''Scripts\TCIM\Waypoint.sqf'""""",
_num, call compile format ["%1Result", side player],_x]],
["Close", true] ]
]

Code: [Select]
_MenuWaypoints = _MenuWaypoints +
[
[ ["Item", _x] ,
["Action", call compile format["{[[%1,%2] '%3']  execVM "''Scripts\TCIM\Waypoint.sqf''"}",
_num, call compile format ["%1Result", side player],_x]],
["Close", true] ]
]
urp!

Offline loki72

  • Former Staff
  • ****
    • Loki's Nightmare
Re: Array Help [NOT SOLVED]
« Reply #15 on: 18 Jun 2008, 22:03:24 »
i will try once more for ya rommel.. give mec a sec to be back to edit this: :D

edit:

1st new code gave this:



the 2nd this:



and his orginal.. just to be sure, i didn't screw it up....




this is only a guess.. but my gut says its this part...
Code: [Select]
format["[[%1,%2] '%3']
everywhere else the %1 %2 variables are in "".. these seem to be the only ones without..?

still only a guess..

« Last Edit: 18 Jun 2008, 22:29:39 by loki72 »

Offline Rommel92

  • Members
  • *
Re: Array Help [NOT SOLVED]
« Reply #16 on: 18 Jun 2008, 23:16:59 »
haha, I know its there mate. I was just wondering if you guys could change it get the Find working and the Move string (which wouldn't of been hard to mess with, its mainly the find.)

Not to worry. Speaking to Sickboy sent me in a different direction on how to approach this. Thanks Lads!

 :P

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: Array Help [GIVEN UP + CLOSED]
« Reply #17 on: 19 Jun 2008, 07:49:03 »
Just pointing out that you can not use hyphens (I mean the character ' ), not singular or several in a row anywhere in ArmA scripts other than inside strings.
And if you call compile whatnot any string with ' in it you're doomed..

Having wrong characters in the code usually result in "missing [" errors.
« Last Edit: 19 Jun 2008, 07:50:56 by h- »
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.