Scripting: SetAngles

SOLVED
Avatar
97 Posts
Posted Jun 09, 2012
Heyho,

currently I'm trying to parent a func_physbox with some special behaviors to a model. That works fine. Also the teleporting with a script of a second func_physbox to that models location is part of the project, and all that is working.
But the problem I have at the moment is the setting of the angels to the physbox (I want the angels of the model and put them into the func_physbox).
I can easily get the oriantation of the model with

local ang = modelOrigin.GetAngles();

but I just get error messages when I try to put these informations to that physbox with:

physBox.SetAngles(ang[0],ang[1],ang[2]);

The error I get:

AN ERROR HAS OCCURED [the index '0' does not exist]

CALLSTACK
*FUNCTION [cubeIsGeled()] reflectioncubeparent.nut line [10]
*FUNCTION [main()] InputRunScript line [1]

LOCALS
[ang] INSTANCE
[this] TABLE
[this] TABLE
 Entity ReflectCube1Phys encountered an error in RunScript()

To raise the numbers (1,2,3 or 2,3,4 ... ) doesn't help. Isn't there a way to print the whole array itself in squirrel, like in php with print_r (I know they are different languages, php is just the only one I'm good at)?

Advertisement
Registered users don’t see ads! Register now!
Posted Jun 10, 2012
Replied 3 hours later
What is in ang[0]? According to the error it says that there is nothing inside the array: ang at index 0. That is because ang is not an array but an INSTANCE.
Try referencing each angle variable of ang as ang.x ang.y ang.z.

EDIT: to display contents of something use the print() or printl() command.

Avatar
97 Posts
Posted Jun 10, 2012
Replied 7 hours later
It says that ang is a vector with three values inside (pitch, yaw, roll). Because of that i just thought about an array.

ang.x/y/z worked. Thank you!

Posted Jun 10, 2012
Replied 6 hours later
Sorry about that, Sprowl. The script I gave you doesn't work because of that. I'm used to C++ vectors with overloaded [] operators.
Advertisement
Registered users don’t see ads! Register now!
Posted Jun 12, 2012
Replied 1 day later

FelixGriffin wrote:
Sorry about that, Sprowl. The script I gave you doesn't work because of that. I'm used to C++ vectors with overloaded [] operators.

ahh silly C++, I know its so cool and everything, but man I love C#
and I was really happy to see this post.... because it was finally not a question of...

all these PeTI puzzlemakers wrote:
how can I brush this texxure into sticky gel cakelolololol

I also like to make VScripts, so it was interesting