Jump to content
Thorimus

Error undefined variable in expression

Recommended Posts

Scripting newbie here. I'm trying to make and run a super-simple script that spawns a pipe in the ground, encircled by the parachute target, at a position relative to an object named "thepole".


pipe1 = create3DENEntity ["Object","Land_ConcretePipe_F",[position thepole select 1, position thepole select 2, getPosATL thepole select 1]];



circle1 = create3DENEntity ["Object","PARACHUTE_TARGET",[position thepole select 1, position thepole select 2, getPosATL thepole select 1]];



_y = 0; _p = 90; _r = 0;
pipe1 setVectorDirAndUp [
    [ sin _y * cos _p,cos _y * cos _p,sin _p],
    [ [ sin _r,-sin _p,cos _r * cos _p],-_y] call BIS_fnc_rotateVector2D
];

pipe1 enableSimulation false;

It's throwing me the error in the title and reffering to "pipe1", although according to the wiki page that is how you name an object spawned using create3EDEntity. I'm in Zeus using the "Bind variable to object" and "Execute Code Module" modules provided by Ares/CBA.

Also, is the position-defining portion of the create3DENEntity commands correct if I want it to spawn 1m east and 2 meters north of thepole? I haven't been able to find any documantation on this.

Share this post


Link to post
Share on other sites
9 minutes ago, Thorimus said:

that is how you name an object spawned using create3EDEntity

Can't find anywhere on the wiki page saying that.

 

10 minutes ago, Thorimus said:

Also, is the position-defining portion of the create3DENEntity commands correct

doesn't look correct to me. Why are you suddenly taking the Y coordinate of getPosATL as height?
Height is supposed to be Z coordinate not Y. They will float somwhere in the sky.

 

You are using create3DENEntity but nowhere in your post you say that you want to do this in Eden.

Share this post


Link to post
Share on other sites
9 minutes ago, Dedmen said:

You are using create3DENEntity but nowhere in your post you say that you want to do this in Eden.

I'm sorry, I'm not very good at this. What command would you suggest for spawning a structure using a script running on a Zeus server?

 

11 minutes ago, Dedmen said:

doesn't look correct to me. Why are you suddenly taking the Y coordinate of getPosATL as height?
Height is supposed to be Z coordinate not Y. They will float somwhere in the sky.

I was under the impression that it would be like [X, Y, Z,] which would mean [Longditude, Latitude, Height] hence having getPosATL (which alters height) last.

I'd appreciate some guidance as opposed to just telling me I'm wrong.

Share this post


Link to post
Share on other sites

create3DENEntity is a command that adds an entity in Eden Editor. Yes, only for Eden Editor not in-game.

Use createVehicle.

Share this post


Link to post
Share on other sites
6 minutes ago, POLPOX said:

create3DENEntity is a command that adds an entity in Eden Editor. Yes, only for Eden Editor not in-game.

Use createVehicle.

What would the command be for creating a concrete pipe, say "Land_ConcretePipe_F"? I've just tried using that command but can't seem to figure it out.

Share this post


Link to post
Share on other sites
pipe1 = createVehicle ["Land_ConcretePipe_F",[position thepole select 1, position thepole select 2, getPosATL thepole select 1],[],0,"NONE"];

 

Share this post


Link to post
Share on other sites
3 minutes ago, POLPOX said:

pipe1 = createVehicle ["Land_ConcretePipe_F",[position thepole select 1, position thepole select 2, getPosATL thepole select 1],[],0,"NONE"];

 

The command runs without errors, but the pipe does not appear.

Share this post


Link to post
Share on other sites

Wait a minute, wtf is your “position”? This won't do as you want at all!

pipe1 = createVehicle ["Land_ConcretePipe_F",getPosATL thepole,[],0,"NONE"];

Do this.

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites
7 minutes ago, Thorimus said:

The command runs without errors, but the pipe does not appear.

 

I'm sure he meant to write:

pipe1 = createVehicle ["Land_ConcretePipe_F",getposATL thepole,[],0,"NONE"];

Since the original example was holding an error in the Z coordinate of the position:

pipe1 = createVehicle ["Land_ConcretePipe_F",[position thepole select 1, position thepole select 2, getPosATL thepole select 1],[],0,"NONE"];

Cheers

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites
28 minutes ago, Grumpy Old Man said:

 

I'm sure he meant to write:


pipe1 = createVehicle ["Land_ConcretePipe_F",getposATL thepole,[],0,"NONE"];

Since the original example was holding an error in the Z coordinate of the position:


pipe1 = createVehicle ["Land_ConcretePipe_F",[position thepole select 1, position thepole select 2, getPosATL thepole select 1],[],0,"NONE"];

Cheers

Thanks. How would I go about offsetting it for example 3m west and 5m up in the sky?

E: NVM, added a setpos command to the script

Share this post


Link to post
Share on other sites
3 hours ago, Thorimus said:

What command would you suggest for spawning a structure

https://community.bistudio.com/wiki/createVehicle

 

3 hours ago, Thorimus said:

was under the impression that it would be like [X, Y, Z,] which would mean [Longditude, Latitude, Height]

Correct.

 

3 hours ago, Thorimus said:

hence having getPosATL (which alters height) last.

Not thaat correct..

 

 

 

Well.. I was writing this 3 hours ago but then got distracted by work...


You can move like this

(getPosATL thepole) vectorAdd [X offset, Y offset, Z offset]



X offset is the offset on the east/west axis. -5m moves 5m west. 5m moves 5m east.

 

(getPosATL thepole) vectorAdd [-3, 0, 5]

 

will move it 3m west and 5m up.

 

Which at the end leaves you with

 

pipe1 = createVehicle ["Land_ConcretePipe_F", (getposATL thepole) vectorAdd [-3, 0, 5] ,[],0,"NONE"];

 

  • Like 1

Share this post


Link to post
Share on other sites
3 hours ago, Dedmen said:
7 hours ago, Thorimus said:

hence having getPosATL (which alters height) last.

Not thaat correct..

 

To clarify, getPosATL doesn't "alter" anything. It returns (i.e. "gets") the given object's [X,Y,Z] position Above Terrain Level so you can reference those values in your script. Those values are returned in an array. Array elements start at an index of zero, so 

getPosATL thepole select 1

will return thepole's Y coordinate.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×