OFPEC Forum

Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: Rommel92 on 16 Jun 2008, 01:19:01

Title: Array Help [GIVEN UP + CLOSED]
Post by: Rommel92 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:
Title: Re: Array Help [SOLVED]
Post by: Spooner on 16 Jun 2008, 13:31:03
This looks very, very fishy to me:
Code: [Select]
_platoon = _platoon - _platoon;
Title: Re: Array Help [NOT SOLVED ANYMORE]
Post by: Rommel92 on 16 Jun 2008, 14:03:32
hehe.
(http://img206.imageshack.us/img206/7909/glolxm2.jpg)

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.
Title: Re: Array Help [NOT SOLVED]
Post by: Rommel92 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:
Title: Re: Array Help [NOT SOLVED]
Post by: loki72 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:
Title: Re: Array Help [NOT SOLVED]
Post by: Rommel92 on 16 Jun 2008, 23:43:35
String of _x + "SMenu" = "_x" + "SMenu"

Say _x = 1.

"1SMenu".

These are dynamic arrays for a dialog.
Title: Re: Array Help [NOT SOLVED]
Post by: loki72 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.


Title: Re: Array Help [NOT SOLVED]
Post by: Rommel92 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.
Title: Re: Array Help [NOT SOLVED]
Post by: loki72 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.
Title: Re: Array Help [NOT SOLVED]
Post by: Rommel92 on 17 Jun 2008, 00:06:38
There you go. Be back in 6 hours.
Title: Re: Array Help [NOT SOLVED]
Post by: loki72 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:
(http://img262.imageshack.us/img262/3194/rommel1ob9.jpg)

however.. by adding a "  it looks like this:
(http://img508.imageshack.us/img508/2525/rommel2og1.jpg)


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


Title: Re: Array Help [NOT SOLVED]
Post by: Mr.Peanut 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] ]
]

Title: Re: Array Help [NOT SOLVED]
Post by: Rommel92 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.
Title: Re: Array Help [NOT SOLVED]
Post by: loki72 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...

(http://img209.imageshack.us/img209/9485/erroryw9.jpg)

sry...
Title: Re: Array Help [NOT SOLVED]
Post by: Mr.Peanut 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] ]
]
Title: Re: Array Help [NOT SOLVED]
Post by: loki72 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:

(http://img357.imageshack.us/img357/7378/rommel1oo6.jpg)

the 2nd this:
(http://img141.imageshack.us/img141/4176/rommel2tm8.jpg)


and his orginal.. just to be sure, i didn't screw it up....
(http://img155.imageshack.us/img155/7509/rommel3gy3.jpg)



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..

Title: Re: Array Help [NOT SOLVED]
Post by: Rommel92 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
Title: Re: Array Help [GIVEN UP + CLOSED]
Post by: h- 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.