PDA

View Full Version : [GMOD] Hyper Drive Upgrade



CodeBrain
April 24th, 2009, 04:47 PM
Anyone who is anyone saw the tutorial for making a "hyper drive" module for a ship/vehicle, which had a lot of chips on it?

In case you didn't, here it is:

SsUlbYMytms

Well, I rewatched that tutorial. I felt it was necessary to "upgrade" it. This time, instead of millions of chips, I said "Let there be Expression!"

So, here is the Expression...



@name CodeBrain's HyperDrive
@inputs GPSx GPSy GPSz GPS2x GPS2y GPS2z
@outputs Jump_X Jump_Y Jump_Z
@persist Sub Sub2 Sub3 Sub4 Mult Mult2 Mult3 Mult4 Mult5 Mult6 Add Div Div2 Div3 SqRt

Sub = GPSx - GPS2x
Sub2 = GPSy - GPS2y
Sub3 = GPSz - GPS2z
Mult = Sub * Sub
Mult2 = Sub2 * Sub2
Mult3 = Sub3 * Sub3
Add = Mult + Mult2 + Mult3
SqRt = sqrt(Add)
Div = Sub / SqRt
Div2 = Sub2 / SqRt
Div3 = Sub3 / SqRt
Mult4 = Div * 2000
Mult5 = Div2 * 2000
Mult6 = Div3 * 2000
Jump_X = Mult4 + GPSx
Jump_Y = Mult5 + GPSy
Jump_Z = Mult6 + GPSz
NOTE:I might of got it wrong, I am currently at school right now. I will update this post when I get back home.

How to wire:

You'll need the following:

2 GPS's
The Expression
HoverDrive Controller
And a Numpad Input.

Tutorial:

1. Place first GPS on the front of your prop (Lets use a 1x1 Tile board.), and the second on the back of the prop. (With SmartSnap, this isn't hard.)

2. Place the Expression somewhere on the 1x1 plate.

3. Place a Numpad Input somewhere on the 1x1 plate.

4. Spawn a HoverDrive Controller, and Easy Weld (Or Easy Precision) it to the 1x1 plate.

5. Wire the GPSx, GPSy, and GPSz inputs to the front GPS.

6. Wire the GPS2x, GPS2y, and the GPS2z inputs to the back GPS.

7. Wire the Target_X on the HoverDrive to the Jump_X output.

8. Wire the Target_Y on the HoverDrive to the Jump_Y output.

9. Wire the Target_Z on the HoverDrive to the Jump_Z output.

10. Finally, wire the SetJumpTarget and Jump on the HoverDrive to the Numpad Input.

Okay, you SHOULD be set. If it does not work, it might be my knowledge on the Hoverdrive. Also it might be the @persist part, I havent checked. I will once I get home.

If you need help, wire 3 screens (Doesn't matter the name) to the Jump Coordinates (Jump_X, Jump_Y, and Jump_Z), and see what they are.

Normally, it should be somewhere in 1000 to 5000. It depends on the map size. If it is higher than normal (Say 20000) then something is wrong. You could also use the Debugger tool instead of the screens, I like the screens though :D

I hope you enjoyed the tutorial!

n00b1n8R
April 24th, 2009, 10:43 PM
The hyperdrive doesn't use half as many chips as the one in that vid O__o

Also, how is expression 2 different/better than the old one (which I still use)?
Is it just that it's all written in code (Lua style or what?) or is there extra features?

CodeBrain
April 24th, 2009, 10:57 PM
The hyperdrive doesn't use half as many chips as the one in that vid O__o

Also, how is expression 2 different/better than the old one (which I still use)?
Is it just that it's all written in code (Lua style or what?) or is there extra features?

It's the basic route.

1. Fixed Bugs
2. More features (Now allowing entity() calls, and more operations
3. Persist, which makes a value retain a value, but without it taking a Input/Output space (Say if I just moved EVERYTHING from @persist into output. That would take forever to do. With @persist it's all nice and clean.
4. Upgraded Coding Format

The thing is with #4, I didnt know how the "If statement" was done. I originally started with Expression 1, as all of us did. I was so used to type "If" instead of "if". In Expression 2, "If" is not an operator, only "if" is.

Also, equal signs (=) cannot be used in the first part of a if statement (At least, I think so...)

Final thing. In Expression 2, we use ( ) and { } instead of spaces and ->.

Heathen
April 24th, 2009, 11:03 PM
thats badass but idgi