Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @name Starkkz's Auto Landing Gear x3 [Forward, Left, Right]
- @inputs Parent:entity Wheels:array
- @persist [FrontWheel LeftWheel RightWheel]:entity
- @persist [FrontHolo LeftHolo RightHolo]:entity
- @persist Update FirstUpdate Active
- if (first()){
- runOnLast(1)
- rangerPersist(1)
- rangerFilter(Wheels)
- local HighestX = 0
- local HighestY = 0
- local LowestY = 0
- foreach (I, Wheel:entity = Wheels){
- local Position = Parent:toLocal(Wheel:pos())
- if (abs(Position:x()) > HighestX){
- HighestX = abs(Position:x())
- FrontWheel = Wheel
- }
- if (Position:y() < LowestY){
- RightWheel = Wheel
- LowestY = Position:y()
- }
- if (Position:y() > HighestY){
- LeftWheel = Wheel
- HighestY = Position:y()
- }
- Wheel:setAlpha(0)
- }
- FrontRanger = rangerOffset(100, FrontWheel:pos(), vec(0, 0, 1))
- LeftRanger = rangerOffset(100, LeftWheel:pos(), vec(0, 0, 1))
- RightRanger = rangerOffset(100, RightWheel:pos(), vec(0, 0, 1))
- FrontHolo = holoCreate(1)
- holoAlpha(1, 0)
- holoPos(1, FrontRanger:pos() + vec(0, 0, FrontWheel:boxSize():z()/2))
- holoAng(1, Parent:angles())
- holoParent(1, Parent)
- LeftHolo = holoCreate(2)
- holoAlpha(2, 0)
- holoPos(2, LeftRanger:pos() + vec(0, -LeftWheel:boxSize():y()/2, 0))
- holoAng(2, Parent:angles())
- holoParent(2, Parent)
- RightHolo = holoCreate(3)
- holoAlpha(3, 0)
- holoPos(3, RightRanger:pos() + vec(0, RightWheel:boxSize():y()/2, 0))
- holoAng(3, Parent:angles())
- holoParent(3, Parent)
- holoCreate(4)
- holoPos(4, FrontWheel:pos())
- holoAng(4, FrontWheel:angles())
- holoModel(4, FrontWheel:model())
- holoParent(4, 1)
- holoCreate(5)
- holoPos(5, LeftWheel:pos())
- holoAng(5, LeftWheel:angles())
- holoModel(5, LeftWheel:model())
- holoParent(5, 2)
- holoCreate(6)
- holoPos(6, RightWheel:pos())
- holoAng(6, RightWheel:angles())
- holoModel(6, RightWheel:model())
- holoParent(6, 3)
- holoCreate(7)
- holoAng(7, Parent:toWorld(ang(0, 90, 0)))
- holoPos(7, FrontWheel:toWorld(vec(0, -FrontWheel:boxSize():y()/2, 0)))
- holoScale(7, vec(1, 1, (FrontRanger:distance() + FrontWheel:boxSize():z()/2)/23))
- holoModel(7, "models/sprops/trans/misc/shock_3.mdl")
- holoParent(7, 1)
- holoCreate(8)
- holoAng(8, Parent:toWorld(ang(0, 90, 0)))
- holoPos(8, FrontWheel:toWorld(vec(0, FrontWheel:boxSize():y()/2, 0)))
- holoScale(8, vec(1, 1, (FrontRanger:distance() + FrontWheel:boxSize():z()/2)/23))
- holoModel(8, "models/sprops/trans/misc/shock_3.mdl")
- holoParent(8, 1)
- holoCreate(9)
- holoAng(9, Parent:toWorld(ang(0, 90, 0)))
- holoPos(9, LeftWheel:toWorld(vec(0, -LeftWheel:boxSize():y()/2, 0)))
- holoScale(9, vec(1, 1, (LeftRanger:distance() + LeftWheel:boxSize():y()/2)/23))
- holoModel(9, "models/sprops/trans/misc/shock_3.mdl")
- holoParent(9, 2)
- holoCreate(10)
- holoAng(10, Parent:toWorld(ang(0, 90, 0)))
- holoPos(10, RightWheel:toWorld(vec(0, RightWheel:boxSize():y()/2, 0)))
- holoScale(10, vec(1, 1, (RightRanger:distance() + RightWheel:boxSize():y()/2)/23))
- holoModel(10, "models/sprops/trans/misc/shock_3.mdl")
- holoParent(10, 3)
- rangerFilter(Parent)
- rangerFilter(Parent:getConstraints())
- timer("Rotate", 100)
- timer("CheckGround", 100)
- }elseif (dupefinished()){
- rangerFilter(Parent)
- rangerFilter(Parent:getConstraints())
- }elseif (clk("Gear")){
- Update = 0
- FirstUpdate = 0
- local FrontAngle = round(Parent:toLocal(FrontHolo:angles()))
- local LeftAngle = round(Parent:toLocal(LeftHolo:angles()))
- local RightAngle = round(Parent:toLocal(RightHolo:angles()))
- if (Active){
- if (FrontAngle:pitch() < 90){
- FrontAngle = FrontAngle + ang(10, 0, 0)
- Update = 1
- }
- if (LeftAngle:roll() > -90){
- LeftAngle = LeftAngle - ang(0, 0, 10)
- Update = 1
- }
- if (RightAngle:roll() < 90){
- RightAngle = RightAngle + ang(0, 0, 10)
- Update = 1
- }
- }else{
- if (FrontAngle:pitch() > 0){
- FrontAngle = FrontAngle - ang(10, 0, 0)
- Update = 1
- }
- if (LeftAngle:roll() < 0){
- LeftAngle = LeftAngle + ang(0, 0, 10)
- Update = 1
- }
- if (RightAngle:roll() > 0){
- RightAngle = RightAngle - ang(0, 0, 10)
- Update = 1
- }
- }
- if (Update){
- holoAng(1, Parent:toWorld(FrontAngle))
- holoAng(2, Parent:toWorld(LeftAngle))
- holoAng(3, Parent:toWorld(RightAngle))
- timer("Gear", 100)
- }
- }elseif (clk("Rotate")){
- if (!Active & !Update & !FirstUpdate){
- holoAng(4, FrontWheel:angles())
- holoAng(5, LeftWheel:angles())
- holoAng(6, RightWheel:angles())
- }
- timer("Rotate", 100)
- }elseif (clk("CheckGround")){
- local Flies = 1
- foreach (I, Entity:entity = Wheels){
- local Ranger = rangerOffset(100, Entity:pos(), vec(0, 0, -1))
- if (Ranger:hit()){
- Flies = 0
- break
- }
- }
- if (Flies != Active){
- FirstUpdate = 1
- Active = Flies
- stoptimer("Gear")
- timer("Gear", 100)
- }
- timer("CheckGround", 100)
- }elseif (last()){
- FrontWheel:setAlpha(255)
- LeftWheel:setAlpha(255)
- RightWheel:setAlpha(255)
- }elseif (~Wheels | ~Parent){
- reset()
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement