Scripts / Is there a lua command that will give me the "Y" angle of an entity?

Author
Message
m2design
GameGuru TGC Backer
14
Years of Service
User Offline
Joined: 25th Mar 2010
Location:
Posted: 14th Oct 2015 00:05
I have been working on a lua file that will allow me to open and close a single door. I have it working (sort of) but my problem at the moment is I need
to determine the "Y" angle of the door before I begin to rotate it open. Is there an existing LUA command that will return said angle to my script so I can then rotate the door 1 degree at a time , 90 times.
I know that I could just animate the door and use LUA_door but I want open and close the door with out the animation step.
Windows 10,64 bit|AMD FX-6200 Six-core-3.80 Ghz |CPU PASSMARK 6,142 |Memory 10GB |NVIDIA GEFORCE GTX 660 SC |GPU PASSMARK 4,114
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 14th Oct 2015 09:38
Directly no, you can use the RotateY() command to rotate it locally though if you know the fps.
Set a standard variable to increase to 90 and at the same time rotate the door by the fps value, this should give you a 90 degree turn.

Or if its not something the player can see when the game starts you can move it forward a bit (with MoveForward() ), check the angle required to rotate back to its starting point (then add 180 cos that's obviously "behind it") and then set it back to its original place.
Then you can rotate it with the much more reliable SetRotation()
life\'s one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, AMD R9 200 series , directx 11
m2design
GameGuru TGC Backer
14
Years of Service
User Offline
Joined: 25th Mar 2010
Location:
Posted: 14th Oct 2015 16:20
@smallg
Thanks for the info. I first used the RotateY() and was able to open and close the door but depending on where the building and the door is located the FPS
value is not a constant value.

I will see if I can figure out how to code your second option. I have been working with SetRotation() but without the actual starting "Y angle" I could not get a consistant 90 rotation. Due to the variable insertion angle of the door the rotation using the add one degree at a time obviously did not work.
Windows 10,64 bit|AMD FX-6200 Six-core-3.80 Ghz |CPU PASSMARK 6,142 |Memory 10GB |NVIDIA GEFORCE GTX 660 SC |GPU PASSMARK 4,114
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 14th Oct 2015 16:54
life\'s one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, AMD R9 200 series , directx 11
m2design
GameGuru TGC Backer
14
Years of Service
User Offline
Joined: 25th Mar 2010
Location:
Posted: 14th Oct 2015 18:20
From the standpoint my simple knowledge of LUA, that my friend is pure genius...
@ smallg

Did you just create this script or was it something you just had laying around ??
The operation of your script is almost PERFECT !!
This is a LUA script that should be included in any future updates to Game-guru Scriptbank files and or you should add it to the store.

After I give the script a through review , I am sure I will walk away a with a much better understanding of scripting in LUA.

Just how long did it take you to figure this out?
Slowing down the door opening speed would the only improvement ...

Again it is a joy to behold ...
Windows 10,64 bit|AMD FX-6200 Six-core-3.80 Ghz |CPU PASSMARK 6,142 |Memory 10GB |NVIDIA GEFORCE GTX 660 SC |GPU PASSMARK 4,114
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 14th Oct 2015 18:40 Edited at: 14th Oct 2015 18:42
i wrote it just now, i tried the rotateY first but i found it was too unreliable (as expected)

to adjust the speed i've commented the line (also fixed the ability to open/close the door while it's opening/closing)
p.s. i expect it only goes too fast because your frame rate is high, for me (at 60fps which IMO is already higher than id expect a full game to run at) it's fine.

life\'s one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, AMD R9 200 series , directx 11
m2design
GameGuru TGC Backer
14
Years of Service
User Offline
Joined: 25th Mar 2010
Location:
Posted: 15th Oct 2015 00:17 Edited at: 15th Oct 2015 00:18
Sorry had to go out for awhile. In my previous post I was not exactly clear ... I did not mean the door/open sequence was too fast. What I was trying to say was that just the door OPEN routine is too fast - it just snaps open.
On my system the moving of the entity is hardly noticeable, unless I mess around with "50" value .

Again well done! By checking the time stamps on our posts it appears you did the routine in about 40 minutes. [how you do that?]
Windows 10,64 bit|AMD FX-6200 Six-core-3.80 Ghz |CPU PASSMARK 6,142 |Memory 10GB |NVIDIA GEFORCE GTX 660 SC |GPU PASSMARK 4,114
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 15th Oct 2015 10:19
I still don't understand, you aren't supposed to see the "snap open", that's just needed to check the starting angle.
The door should start closed, its just a tiny movement to workaround the angle limit.
Hopefully when the level loads the player won't be near any such doors so he won't even be aware it happened.

Is that what you're talking about?
If the door isnt finding the correct angle then yh you will need to adjust that part
life\'s one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, AMD R9 200 series , directx 11
m2design
GameGuru TGC Backer
14
Years of Service
User Offline
Joined: 25th Mar 2010
Location:
Posted: 15th Oct 2015 18:09 Edited at: 15th Oct 2015 18:42
@smallg

Just thought you might be interested...
Example: Door placed between 2 doors (to represent opening in a wall) the two adjacent doors use the Default.lua file and are in static mode.
The operable door in the middle uses the new door_manual.lua file.
In cases where the door is tested where the door is a stand alone element it seems to function as required. Also if the door is placed a distance above the terrain during the operation it will always return to ground.

Windows 10,64 bit|AMD FX-6200 Six-core-3.80 Ghz |CPU PASSMARK 6,142 |Memory 10GB |NVIDIA GEFORCE GTX 660 SC |GPU PASSMARK 4,114
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 15th Oct 2015 18:46
set the door immobile = yes , normal doors use this by default
life\'s one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, AMD R9 200 series , directx 11
m2design
GameGuru TGC Backer
14
Years of Service
User Offline
Joined: 25th Mar 2010
Location:
Posted: 15th Oct 2015 20:23
With that simple change everything works as you intended.

I believe that by going through your code I have moved to a more comfortable place in regards to LUA scripting.
I thank you very much... wish I could buy you a beer !!
Windows 10,64 bit|AMD FX-6200 Six-core-3.80 Ghz |CPU PASSMARK 6,142 |Memory 10GB |NVIDIA GEFORCE GTX 660 SC |GPU PASSMARK 4,114
m2design
GameGuru TGC Backer
14
Years of Service
User Offline
Joined: 25th Mar 2010
Location:
Posted: 16th Oct 2015 18:13
@smallg

Possible issue...
Because I was unsuccessful in my attempt to create a workable door lua script on my own I would like to know if you have a problem if I use the code you provided me.

I have no realistic intentions of ever creating a game for sale in the market place using your code but if I or anyone of those who have read our posts in this thread where to do so would we have your permission?

My attempts were semi functional up to the point that I was unable to solve the Angle concept. This still leaves me uncomfortable with the fact that your code has become public in some small way.

Again I want to thank you for all your help. Please let me know if you would like me to request a mod remove this thread. (if that is possible)
Windows 10,64 bit|AMD FX-6200 Six-core-3.80 Ghz |CPU PASSMARK 6,142 |Memory 10GB |NVIDIA GEFORCE GTX 660 SC |GPU PASSMARK 4,114
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 16th Oct 2015 19:29
all my scripts are free to use as you wish, that's why i share them, no worries
life\'s one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, AMD R9 200 series , directx 11

Login to post a reply

Server time is: 2024-05-04 22:27:41
Your offset time is: 2024-05-04 22:27:41