Space Engineers

Space Engineers

JRGD-Jerry Rigged Torque Canceling Gravity Drive
151 Comments
DMMWolf 22 Aug, 2022 @ 3:24am 
This script is incompatible with any of the following.
1. Gravity drives with no gravity generators in one or more axis.
***2. Space Engineers.***

I Love how non specific this is!

It can just as easily mean Space Engineers the game as it does the people Building the ships!
Jerry  [author] 19 Jul, 2022 @ 2:54pm 
I don't recall using anything of that sort. You have perfect information on the ship. You just solve for how much force and in what direction each drive should apply to give you the correct force and torque at the same time.
IchBinUnoriginellWasNamenAngeht 17 Jul, 2022 @ 3:10pm 
When cancelling out the torque how is that done? Because to cancel to torque out you need to apply a force to generate a constant counter-torque. Do you use a controller like PT2 or I?
Mata52 31 May, 2022 @ 2:25am 
A note to my last comment and request for help: with further tests I can confirm it is only related to design matters. For some reason 3 grav drives do not work with certain designs. I have no clue what exactly the obstacle is, though. Definitely not the mass itself, however. Maybe the shape, size, number of blocks, location of the center of mass or something else.
Mata52 29 May, 2022 @ 5:30am 
I realise that this script is not going to be updated anymore by Jerry, however, I have an issue that maybe even somebody else will be able to help me with. For some reason when I build 3 grav drives on my ships they do not work in the up & down axis. When I press space and c (thrusters do work normally) the artificial masses do not even get turned on. The script does not seem to even want to assist my flight when I want to fly downwards and upwards. It works perfectly tho in any other direction and also its gyroscopic function seems to work correctly

I put those 3 drives in a triangular pattern. My ship is triangular itself and basically I have one drive (3x3) in the middle of the front of the ship and also 2 drives in the back of the ship spread from each other. I tried comparing my construction with one of the Jerry's examples (the red ship, whose grav drives work perfectly fine even up to this date). I have no idea what can be the cause and I would be glad to see any advice.
Jeff 28 Jan, 2022 @ 11:39am 
My Ship still speeds up in i think 1 direction
ShadedMJ 14 Apr, 2021 @ 2:03pm 
@Jerry : Script is _not_ broken. Only deprecated code.

// Lines 945-946 are
panel.WritePublicText(before + sf.ToString(width) + after, false);
panel.ShowPublicTextOnScreen();
// but should be
panel.WriteText(before + sf.ToString(width) + after, false);
panel.ContentType=VRage.Game.GUI.TextPanel.ContentType.TEXT_AND_IMAGE;
Jerry  [author] 28 Feb, 2021 @ 1:20am 
I don't expect to have time to update this script anytime in the future.

Feel free to use any part of my old code as long as credit is acknowledged. Just put my name under an asterisk in the workshop page or something.

That said, I wrote this in high school and I’m in grad school now so a lot of the math could really be made much more rigorous. I won’t be implementing anything, but I can describe a better and more accurate algorithm for anyone interested.


Chuck 26 Feb, 2021 @ 8:49am 
@Venator Here is a link to a working script that replicates most of the functions. On the downside, it doesn't do torque cancelling, so you will have to build the drive around the center of mass. Torque cancelling is planned for the future, according to the page.

https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=1878739837
Lance Corporal Venatori 6 Jan, 2021 @ 10:16pm 
is this being fixed/updated anymore?
HERETIC 17 Jul, 2020 @ 6:42am 
Keen update broke the script because of LCD api changes, is there any way we could expect a fix soon ?
Jerry  [author] 17 May, 2020 @ 3:31pm 
I wrote the thing in highschool. Its been three years and honestly I'm surprised it took that many updates for it to break.
Simon 13 Feb, 2020 @ 9:08am 
I setup the script properly but the reverse ( holding 's') does not work. (the artificial mass doesnt turn on, i dunno if grav gens do something in meantime).

if i use the LCD i get the force shown, but when pressing 's' now, the script breaks with error like:
"'count' must be non negative number [...] at System.String.CtorCharCount(Char c, int32 count) [...] at System.ScreenFormatter [...]"

can't get reversing to work.
K1ltu 9 Dec, 2019 @ 3:35pm 
For the love of god do not use this if you have even the remotest possibility of combat... If any part gets damaged it will error out... Next time bud be more liberal with try/catch blocks... Especially if its a non essential item like a LCD... That should not crash your script...
xTUx Death Lord 9 Sep, 2019 @ 6:30pm 
Incompatibilities:
This script is incompatible with any of the following.
1. Gravity drives with no gravity generators in one or more axis.
2. Space Engineers.

to bad i wanted to use this on space engineers.

joking aside are these just truly as simple as a mass of mass blocks and gravity gens on 3 planes ? (up/down, left/right, and front/back)

also you said "For effective placements of drives, make sure they are spread far apart and spread evenly. Make sure no three drives are in the same line as each other." on that note would it effect the speeds if we changed the range of each gravity gen to just cover the area of the mass blocks only and then put some other gravity blocks not tagged with the script to allow ship gravity in all other areas other then the gravity drives ? (i know this is only a very large ship that could have that option and out of my current building skills for now)
Scruffy 25 Apr, 2019 @ 5:01pm 
Alrighty, everything works for me now. I've rebuilt the gravdrive BP's I'll use and when I paste them in/weld them from projection, it works fine. Seems the mass blocks have ownership bugs. Just need to ensure they are 'placed' originally by you.

The simplest fix anyone can do for the LCD is to replace these lines (line 945-946 in the script)

panel.WritePublicText(before + sf.ToString(width) + after, false);
panel.ShowPublicTextOnScreen();


With:

panel.WriteText(before + sf.ToString(width) + after, false);
Scruffy 25 Apr, 2019 @ 1:40pm 
@InSpaces When you say an issue with the Gravity Gens, you mean an issue with artificial masses, right? I've noticed that pasted in masses just show as 0 KG's, o required input, 0 output. no matter what. if I partly grind it down and rebuild, still 0. But if I remove it, place a NEW artificial mass, then it works.

This has the issue of anything attached to the block also needing to be replaced.. basically an entire grav drive...

Does anyone know a fix for this? seems to make grab drives useless...
Scruffy 25 Apr, 2019 @ 4:18am 
@quasarwizard I don't think I should re-release someone elses script, but if this isn't updated shortly, i'll see about releaseing an update for the text panel update. The chanes to text panel API is what's throwing off the script. it shouldn't affect the script working, but i'll double check that...
Scruffy 25 Apr, 2019 @ 4:15am 
I can fix the text panel thing (for 1.190 update) but am i the only one who's seeing nothing from the grab drive?
I see the art masses firing up, but i have no movement...
Amy 14 Apr, 2019 @ 12:27pm 
"
Program[945,8]: Warning: 'IMyTextPannel.WritePublicText[string, bool)' is obsolete: 'LCD public text is deprecated'
Program[946,8]: Warning: 'IMyTextPannel.ShowPublicTextOnScreen[)' is obsolete: 'LCD public text is deprecated'
" Yay updates! And of course having fixed that by just removing that bit of code, in hopes of just getting my ships to work, now I'm running into the same issue as Crimson Revenant with the WASD being broken.
InSpades 12 Apr, 2019 @ 6:50pm 
@Crimson Revenant The problem you are running into affects all grav drive scripts equally. The problem centers around grav drives pasted in or when the world save is restarted for any reason.

Only work around so far is to grind down and replace all of your grav gens. On public servers that frequently restart, this isn't all that practical.

I am doing further testing to see where the exact break happens.
Crimson Revenant 10 Apr, 2019 @ 10:03am 
I think the new update broke the script somehow because I'm not getting any reaction from the drives when I WASD.
Enigmus 3 Apr, 2019 @ 8:04pm 
The script doesn't need a timer block any more, but the author forgot to remove that bit from the setup instructions.
Amy 2 Apr, 2019 @ 9:06pm 
I'm working on a ship, I set up 2 drives at the back, properly grouped and labeled. I set up the timer and the programmable block but it spits back an error of the following. What am I doing wrong?

Caught exception during execution of script: Object reference not set to an instance of the object.at.Program.WriteTableToPanel[[String title, Screenformatter sf, [MyTextPannel panel, String before, String after]
at Program.updateLcd()
at Program.Main(String argument, UpdateType updateType)
at Sandbox.Game.Entities.Blocks.MyProgrammableBlock.<>c__DisplayClass26.<ExecuteCode>b__25[IMyGridProgram program]
at Sandbox.Game.Entities.Blocks.MyProgrammableBlock.RunSandboxedProgramAction[Action']I action, String&responce]
Fish 13 Feb, 2019 @ 8:27pm 
Ah nvm, I took a look through the code and it searches for [JRGD] not [GD]
Fish 13 Feb, 2019 @ 8:21pm 
kinda rage inducing that i cant figure this out lol, what am i doing wrong? Im putting [GD] in the group name of every individual gravity drive on my ship but when i run "refresh" on the PB it keeps saying "Discovered 0 Valid gravity drive groups", any help?
Hal 10 Dec, 2018 @ 12:39pm 
Just a heads up, there seems to be an upper limit that this script can handle before crashing the game. It's probably an engine issue, not an issue with this mod. But for anyone with a Capital Ship-class or larger attempting to use this script on the Grav Drives, you'll probably crash. Or the script will read too complex, stop working, then crash. But either way, you'll crash. Again, heads up.
Brutam 25 Nov, 2018 @ 5:29pm 
gday mate trying to build a gd and i cant get this shell to stop bouncing what am i doing wrong please https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=1574915528
James Fire 2 Oct, 2018 @ 1:05pm 
Does this use WASD to control the drive?

Like this script https://github.com/Whiplash141/SpaceEngineersScripts/blob/master/Public/Gravity%20Drive%20Manager%20v24.cs?

If not, are these 2 compatible?
GrandBravo 29 Sep, 2018 @ 11:28am 
Finaly someone made a proper GravDrive script. Been waiting for this over 3 years xD

Can you make the script in a way that it tweeks the force of each gravity generator based on the center of mass? I was tolled CubeGrid.Physics.CenterOfMassLocal or CubeGrid.Physics.CenterOfMassWorld might be the commands obtaining the center of mass.

If you need help with the formula's, let me know by contacting me through steam.

Also, can you script it in such way that number 1 of the incompatibilities is fixed? It would be nice to have seperate generator spots where there is only thrust downwards for planets etc.
Dom452 22 Aug, 2018 @ 7:13am 
Same problem as Hippybaker - but with left/right strafing.
FPC 9 Aug, 2018 @ 4:08pm 
I will add...Script reads 6 grav drives, but seems to do nothing thereafter. Also throws an error when trying to use an LCD.
FPC 8 Aug, 2018 @ 7:11pm 
Any chance you could check and see what I am doing wrong? Can not seem to get this to work. This is a very advanced and as-yet unreleased ship...will be on workshop soon. Collaboration project. JD Horx (IMDC), Alysius, and I. https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=1471081275
AutoMcDonough 7 Aug, 2018 @ 1:04pm 
Glad to see you keeping it updated. 👍
hippybaker 31 Jul, 2018 @ 12:13pm 
Hi, it's me again..
So..
I seem to be having the trouble of GDs not working in the up and down direction..

My drives are set as a mass with a gravgen on 3 sides; and then repeated in rows.
I have a bow GD and two nacelle ones..
any ideas?
hippybaker 25 Jul, 2018 @ 1:11pm 
This is amazing. you have changed the whole game.
Love it!! Thanks you
Lander1 21 Jul, 2018 @ 9:02am 
Since the most recent update I have been having a recurring issue where the JRGD Script becomes too complex and has to be recompiled in the edit menu. I have uploaded the world file for you if you would like to tale a look at it; https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=1446924274
Lander1 26 Jun, 2018 @ 4:44pm 
Found a small incompatability, I built this Battleship https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=1422099215 for use as a target drone. It's primary drive is 6 Grav Drives, backed with hydrogen drive. I use the "Enemy AI: Search & Destroy script to automate the ship, however the grav drive is not used by the script...
Jeff 18 Jun, 2018 @ 2:03pm 
If i dont hav any experience with Scripts .... How can i install my own Gravity Drive ?
Jerry  [author] 9 Jun, 2018 @ 1:37pm 
Check out the big red ship gravity retrofit example. I've updated a link to the new version.
Jerry  [author] 9 Jun, 2018 @ 1:20pm 
@Nox Echo. Try looking at some of the example ships and how they have been set up. I havn't gone ahead and update them with the latest version but the old version on them should still work.
Lunatera 9 Jun, 2018 @ 2:39am 
what i like to do is put about 9 or more gravity generators in each direction, around a prebalanced set of mass (i have a very op ufo because of this but it has 12) the script i have and translated/tweaked, say i go left, all of the left gravity goes on, and the right side gravity goes on but in reverse
so i get 24g's in every direction instead of 12, need a script that will do this except a simple on/off rather than accelerating slowly, the timer block/updated autorefresh i put on it still lags in some servers, im not sure how yours works because ive tried pairing various things and the script either broke or didnt work no matter what i tried, its better if the gravitys are paired by direction, the mass blocks need to be seperate so you can properly balance the push.
Jerry  [author] 7 Jun, 2018 @ 11:43am 
Sorry for all the delay I'm now back home for the summer from college. Some of the classes I've been taking gave me some insight that could significantly optimize the math and underlying algorithm so stay tuned :D
ArtificerProdigy 20 May, 2018 @ 1:38pm 
It seems like the overhead on this script is such that my framerate drops so drastically as to make it unusable. Has anyone else experienced this?

Really neat script though, the comments made me laugh. Despite some refinement on the gyro assist config, it doesn't seem able to come back to equilibrium when turning. But I could very well have it misconfigured.
Lunatera 18 May, 2018 @ 10:37am 
i couldnt get this to work at all, i have some chinese one i stole from a ship in pvp though. :p
TheDrunkenGod 2 Apr, 2018 @ 11:15pm 
Is there a way to turn down the sensitivity in the script?
Zassi12 21 Mar, 2018 @ 12:44pm 
i had an error while setting it up and im not sure what this means

Caught exception during execution of script:Negating the minimum value of a twos complement number is invalid.
Valykry 10 Mar, 2018 @ 9:19pm 
why does this need a timer block? couldnt you add
[code]Runtime.UpdateFrequency = UpdateFrequency.Update1;[/code]
or the like? Would eliminate the need for a timer block. (Though if it only needs to run once a second, I'd use Update100 or the like)
At the very least, it would remove a few steps from setup, and in all liklihood, increase reliability.
overwerk 9 Mar, 2018 @ 2:19pm 
is there a way to disable torque cancelation on ships with more than one drive? cause i would like to trade the torque cancelation for more power instead, and also less server load
Zulu-1 4 Feb, 2018 @ 10:55am 
I added your script to my ship last night and everything was running well. Logged off for the night, returned the next morning, and now I get the error: "Caught exeption during execution of script: Object reference not set to an instance of an object." Any thoughts on what it could be...not refering to?