Please or Register to create posts and topics.

[Solved] Scripting: SetAngles

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

Code: Select all
local ang = modelOrigin.GetAngles();

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

Code: Select all
physBox.SetAngles(ang[0],ang[1],ang[2]);

The error I get:

Code: Select all
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)?

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.

?????????????????????????????TWP Releases | My Workshop

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!

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

Falsi sumus crusto!
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



Also, I made a map just for you! Sunset
Click Here to view my Workshop and play my puzzlemaker maps