Home   Help Search Login Register  

Author Topic: Call Compile Format ?  (Read 2038 times)

0 Members and 1 Guest are viewing this topic.

Offline Knight Trane

  • Members
  • *
Call Compile Format ?
« on: 30 Mar 2009, 19:10:29 »
Ok,

Trying to write a script that uses "call compile format".  This is how I setup my array:

Code: [Select]
flagcarrier = rng
array = [];
array = array + ["objName",xdist1,ydist1,tnDir,"laneNumber",xdist2,ydist2,lnDir,];

{
call compile format [%1 = "Land_strelecky_post_new" createVehicle [(rng select 0)+ %2,(rng select 1)+%3,0],_x select 0,_x select 1,_x select 2];];
)foreach array;

I'm trying to construct a range by use of an "addaction" on flagcarrier. The reason I'm scripting it is , one to learn how, and two, allow different types of ranges at the same location without overlap.

My question is about using the 
Code: [Select]
[(rng select 0)+ %2,(rng select 1)+%3,0]to calculate the x and y position off of rng to place my targets.

This is all for multiplayer so I left off the _in the variable names.

I'm sure I'm not using the "" properly, but I'll figure that out.  It's the structure I'm having trouble with.

Any help would be appriciated.

KT,

Offline i0n0s

  • Former Staff
  • ****
Re: Call Compile Format ?
« Reply #1 on: 30 Mar 2009, 22:47:08 »
Code: [Select]
%1 = "Land_strelecky_post_new" createVehicle [(rng select 0)+ %2,(rng select 1)+%3,0]Has to be one string, so it should be:
Code: [Select]
'%1 = "Land_strelecky_post_new" createVehicle [(rng select 0)+ %2,(rng select 1)+%3,0]'
And the underscore doesn't depend on mp or not!

Btw: What is your question?

Offline Knight Trane

  • Members
  • *
Re: Call Compile Format ?
« Reply #2 on: 30 Mar 2009, 23:34:24 »
I'll rephrase it.

obj1 = getPos flagcarrier;

If I want to place an object 5m to the East right and 100m North of obj1, do I write
Code: [Select]

 object2 = "Land_strelecky_post_new" createVehicle [(obj1 select 0)+ 5,(object1 select 1)+100,0]

I'm a little confused on how to write the expression.  ie how and when to use [] and ().

Offline Rommel92

  • Members
  • *
Re: Call Compile Format ?
« Reply #3 on: 31 Mar 2009, 00:23:44 »
When to use () with arrays.

Code: (examples) [Select]
array = [player, man2]
data = damage array select 0;

<should be>

array = [player, man2]
data = damage (array select 0);

Otherwise the interpreter would try and retrieve the damage of: [player, man2], and then failing that, it would try to select 0 of the return value... very messy.  :D

Offline Knight Trane

  • Members
  • *
Re: Call Compile Format ?
« Reply #4 on: 31 Mar 2009, 17:08:00 »
Ok,
--Edited 05:07 31 Mar 09
Code: [Select]
start=getPos _flagcarrier
array=[]
array=array+[player,man2,5,100];

{
         call compile format ['%1 = "What_ever" createVehicle [(start select 0) + %2,(start select 1)+%3,0]', _x select 1, _x select 2, _x select 3];
}foreach array;
So this should create an object ("What_ever"), named "man2", 5m to the East, and 100m North of my object _flagcarrier.
What if element 3 of array was -5?  Would it be read as (start select 0)+(-5)?  Putting my object 5m to the West, or would I have to adjust it something else.  I read somewhere that the engine didn't see the "-" sign, but I see it all over in scripts.  Confusing.

KT
« Last Edit: 31 Mar 2009, 18:15:12 by Knight Trane »

Offline Deadfast

  • Members
  • *
Re: Call Compile Format ?
« Reply #5 on: 31 Mar 2009, 17:25:43 »
You got the createVehicle syntax wrong.

It's supposed to be:
name = type createVehicle position.


Also format for the compile is wrong.

_x select 1 would return man2
_x select 2 would return 5
_x select 3 would return 100

Offline Knight Trane

  • Members
  • *
Re: Call Compile Format ?
« Reply #6 on: 31 Mar 2009, 18:47:09 »
Oops! Thanks,

  I should have some coffee before I post.  "man2" is the name(variable) I'm creating.  "player" has nothing to do with this example, except as an element I could use in another call later in the script.


Quote
What if element 3 of array was -5?  Would it be read as (start select 0)+(-5)?  Putting my object 5m to the West, or would I have to adjust it something else?

--Edit
Well I'm getting errors on it as is.  I'll do some testing and post the actual script when I get home.

--Edit:       Today at 06:54:53 PM

Ok, this is what I got:
Code: [Select]
rngpos = getpos sb1;

/*  Create range array krr_array
krr_array = [];
krr_array = krr_array + ["TargetName",xm left/right,ym out from shooting blok,"Lane",Lnpos xm left/right of sb1,Lnpos ym from sb1,Dir lane];*/

krr_array = [];
krr_array = krr_array + ["krt111",-10,100,180,"krln1",0,10,0];
krr_array = krr_array + ["krt112",10,100,180,"krrln1",0,10,0];
krr_array = krr_array + ["krt121",-15,150,180,"krrln1",0,10,0];
krr_array = krr_array + ["krt122",0,150,180,"krrln1",0,10,0];
krr_array = krr_array + ["krt123",15,150,180,"krrln1",0,10,0];
krr_array = krr_array + ["krt131",-15,200,180,"krrln1",0,10,0];
krr_array = krr_array + ["krt132",0,200,180,"krrln1",0,10,0];
krr_array = krr_array + ["krt133",15,200,180,"krrln1",0,10,0];
krr_array = krr_array + ["krt141",-15,250,180,"krrln1",0,10,0];
krr_array = krr_array + ["krt142",-7,250,180,"krrln1",0,10,0];
krr_array = krr_array + ["krt143",7,250,180,"krrln1",0,10,0];
krr_array = krr_array + ["krt144",15,250,180,"krrln1",0,10,0];
krr_array = krr_array + ["krt151",-15,300,180,"krrln1",0,10,0];
krr_array = krr_array + ["krt152",-7,300,180,"krrln1",0,10,0];
krr_array = krr_array + ["krt153",7,300,180,"krrln1",0,10,0];
krr_array = krr_array + ["krt154",15,300,180,"krrln1",0,10,0];
krr_array = krr_array + ["krt161",-15,350,180,"krrln1",0,10,0];
krr_array = krr_array + ["krt162",-7,350,180,"krrln1",0,10,0];
krr_array = krr_array + ["krt163",7,350,180,"krrln1",0,10,0];
krr_array = krr_array + ["krt164",15,350,180,"krrln1",0,10,0];

{
call compile format['%1 = "Land_strelecky_post_new" createVehicle [(rngPos select 0) + %2,(rngPos select 1) + %3,0];',_x select 4,_x select 5,_x select 6];

} foreach krr_array;

krr_array

The error I get is:
...%2,(rngPos select 1) + %3,0];',_x# select 4,_x select 5,_x select 6];

error typed string, expected array config entry



« Last Edit: 01 Apr 2009, 01:08:17 by Knight Trane »

Offline Deadfast

  • Members
  • *
Re: Call Compile Format ?
« Reply #7 on: 01 Apr 2009, 15:31:27 »
Well, the problem is your array.


What you currently get is this:
["krt111",-10,100,180,"krln1",0,10,0,krt112",10,100,180,"krrln1",0,10,0, ...];


I believe you want to achieve this:
[["krt111",-10,100,180,"krln1",0,10,0], ["krt112",10,100,180,"krrln1",0,10,0], ...];


If so just add an extra set of squared brackets to the values added into the array:

krr_array = [];
krr_array = krr_array + [["krt111",-10,100,180,"krln1",0,10,0]];



That should do the trick.


Oh, one more thing: createVehicle doesn't create the object precisely on the given coordinates.

To get the object on the exact spot simply setPos it after creating it.
« Last Edit: 01 Apr 2009, 15:42:09 by Deadfast »