+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 19

Thread: E2 seat functions!

  1. #1
    Wire Sofaking Azrael's Avatar
    Join Date
    Aug 2007
    Posts
    1,946

    Default E2 seat functions!

    I was building a spaceship the other day -- i just spawn a prop, weld on a seat and stick an E2 on it. That's pretty hard, right? I figured that I shouldn't have to go through all the trouble of spawning a seat. So, I wrote these functions for the community:
    • spawnSeat(): Spawns a seat above the E2 chip.
    • spawnSeat(E): Spawns a seat above the E2 chip and welds it to the specified entity for support.
    • despawnSeat(): Removes the seat. Because, I shouldn't have to go through the trouble of getting out the remover tool, right?
    • getSeat(): Returns the seat entity.
    • ejectSeat(): Useful for making a quick escape, ejectSeat() unwelds the seat and launches it upwards.

    Anyway, here is the code:
    [highlight=Lua]registerCallback( 'destruct', function( context )
    if context.entity.seat and context.entity.seat:IsValid() then context.entity.seat:Remove() end
    end )

    local function spawnSeat( chip, support )
    if chip.seat and chip.seat:IsValid() then return end
    local seat = ents.Create( 'prop_vehicle_prisoner_pod' )
    seat:SetModel( 'models/Nova/airboat_seat.mdl' )
    seat:SetPos( chip:GetPos() + chip:GetUp() )
    seat:SetAngles( chip:GetAngles() )
    seat:Spawn( )
    constraint.Weld( chip, seat )
    if support and support:IsValid() then
    constraint.Weld( support, seat )
    end
    chip.seat = seat
    end

    registerFunction( 'getSeat', '', 'e', function( self, args )
    if self.entity.seat and self.entity.seat:IsValid() then return self.entity.seat end return nil
    end )

    registerFunction( 'spawnSeat', '', 'e', function( self, args )
    spawnSeat( self.entity )
    end )

    registerFunction( 'spawnSeat', 'e', 'e', function( self, args )
    local support = args[2][1]( self, args[2] )
    spawnSeat( self.entity, support )
    end )

    registerFunction( 'despawnSeat', '', '', function( self, args )
    if self.entity.seat and self.entity.seat:IsValid() then self.entity.seat:Remove() end
    end )

    registerFunction( 'ejectSeat', '', '', function( self, args )
    if !(self.entity.seat and self.entity.seat:IsValid()) then return end
    constraint.RemoveConstraints( self.entity.seat, 'Weld' )
    local phys = self.entity.seat:GetPhysicsObject()
    phys:SetVelocity( self.entity:GetUp() * 100000 )
    end )[/highlight]

    Here is the code pastebinned for easy copying-and-pasting: http://ilovee2.pastebin.com/f60624d7e
    Last edited by Azrael; 03-12-2009 at 03:53 PM. Reason: OOPS

  2. #2
    Wire Sofaking oenmaster's Avatar
    Join Date
    Jan 2008
    Location
    fak where is my satnav (NL)
    Posts
    717
    Blog Entries
    1

    Default Re: E2 seat functions!

    lemme gees?
    • ejectSeat(): Useful for making a quick escape, ejectSeat() unwelds the seat and launches it upwards.
    you got that idea of the bail out addon :P???

  3. #3
    I think I think too much -HP-'s Avatar
    Join Date
    Feb 2009
    Location
    Behind you with a very sharp knife.
    Posts
    2,466

    Default Re: E2 seat functions!

    Cant you make it simpler?

    Good job, but can you make it so that you can select the model of the seat?

  4. #4
    Wirererer dpidcoe's Avatar
    Join Date
    Apr 2008
    Location
    san diego
    Posts
    250

    Default Re: E2 seat functions!

    does it fly the ship too? That'd be great if it could.

  5. #5
    Wirererer DataSchmuck's Avatar
    Join Date
    Nov 2007
    Posts
    106

    Default Re: E2 seat functions!

    why bother with spawning a prop? Just change the model of the e2 gate with the console command. I think its something like wire_expression2_model modelpath.mdl

  6. #6
    Wire Sofaking Azrael's Avatar
    Join Date
    Aug 2007
    Posts
    1,946

    Default Re: E2 seat functions!

    Quote Originally Posted by oenmaster View Post
    lemme gees?
    you got that idea of the bail out addon :P???
    No, I coded it and then somebody pointed it out to me that the bail out addon already does this. But I don't care.

    E2 <3!

  7. #7
    Wire Sofaking ZeikJT's Avatar
    Join Date
    Dec 2008
    Location
    California
    Posts
    1,391

    Default Re: E2 seat functions!

    For the spawning ones, instead of storing the entity in the E2 entity why not just return it when created? You already have it set to return an entity, why not make it true?

    Code:
    local function spawnSeat( chip, support )
            if chip.seat and chip.seat:IsValid() then return end
            local seat = ents.Create( 'prop_vehicle_prisoner_pod' )
            seat:SetModel( 'models/Nova/airboat_seat.mdl' )
            seat:SetPos( chip:GetPos() + chip:GetUp() )
            seat:SetAngles( chip:GetAngles() )
            seat:Spawn( )
            constraint.Weld( chip, seat )
            if support and support:IsValid() then
                    constraint.Weld( support, seat )
            end
            chip.seat = seat
            return seat
    end
    
    registerFunction( 'spawnSeat', '', 'e', function( self, args )
        return spawnSeat( self.entity )
    end )
     
    registerFunction( 'spawnSeat', 'e', 'e', function( self, args )
        local support = args[2][1]( self, args[2] )
        return spawnSeat( self.entity, support )
    end )
    That way people can create and store the entity with one line of code:
    [highlight=e2]
    @persist Seat:entity
    if(first()){
    Seat = spawnSeat(entity())
    }
    [/highlight]
    Against stupidity the Gods themselves contend in vain.
    -Friedrich Schiller

    The flame puts me in the mood to "Do it!".
    -Dart, Legend of Dragoon

  8. #8
    Wire Sofaking Azrael's Avatar
    Join Date
    Aug 2007
    Posts
    1,946

    Default Re: E2 seat functions!

    Quote Originally Posted by ZeikJT View Post
    For the spawning ones, instead of storing the entity in the E2 entity why not just return it when created? You already have it set to return an entity, why not make it true?

    Code:
    local function spawnSeat( chip, support )
            if chip.seat and chip.seat:IsValid() then return end
            local seat = ents.Create( 'prop_vehicle_prisoner_pod' )
            seat:SetModel( 'models/Nova/airboat_seat.mdl' )
            seat:SetPos( chip:GetPos() + chip:GetUp() )
            seat:SetAngles( chip:GetAngles() )
            seat:Spawn( )
            constraint.Weld( chip, seat )
            if support and support:IsValid() then
                    constraint.Weld( support, seat )
            end
            chip.seat = seat
            return seat
    end
    
    registerFunction( 'spawnSeat', '', 'e', function( self, args )
        return spawnSeat( self.entity )
    end )
     
    registerFunction( 'spawnSeat', 'e', 'e', function( self, args )
        local support = args[2][1]( self, args[2] )
        return spawnSeat( self.entity, support )
    end )
    That way people can create and store the entity with one line of code:
    [highlight=e2]
    @persist Seat:entity
    if(first()){
    Seat = spawnSeat(entity())
    }
    [/highlight]
    Because then you'd be able to spawn as many seats as you want. My solution allows one seat per chip.

  9. #9
    Wire Noob temp_Pyro-Fire's Avatar
    Join Date
    Mar 2009
    Posts
    5

    Default Re: E2 seat functions!

    man, welding stuff together sure is hard work!

    not to mention opening the vehicles page and clicking a seat!
    My god, the pain in my hands are overwhelming!
    this is Pyro-Fire's temporary account till i get my other computer running... cant remember the randomly generated password & don't wanna reset it again, so yeah.

  10. #10
    Wire Sofaking ZeikJT's Avatar
    Join Date
    Dec 2008
    Location
    California
    Posts
    1,391

    Default Re: E2 seat functions!

    Quote Originally Posted by AzraelUK View Post
    Because then you'd be able to spawn as many seats as you want. My solution allows one seat per chip.
    No, as you can see I didn't change the rest of the code.
    I just made it so the function returns the entity immediately.

    It's more convenience than necessity. I didn't mean to delete the other functions I just didn't feel like copy pasting something I didn't edit at all.
    Against stupidity the Gods themselves contend in vain.
    -Friedrich Schiller

    The flame puts me in the mood to "Do it!".
    -Dart, Legend of Dragoon

+ Reply to Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. Press E on adv pod to enter seat
    By Bobsymalone in forum Ideas & Suggestions
    Replies: 3
    Last Post: 11-03-2008, 01:20 PM
  2. Replies: 3
    Last Post: 10-17-2008, 01:40 AM
  3. Mouse controlled turret from within airboat seat
    By Talon876 in forum Installation and Malfunctions Support
    Replies: 2
    Last Post: 01-05-2008, 04:13 PM
  4. Taking damage in an airboat seat
    By George in forum Ideas & Suggestions
    Replies: 11
    Last Post: 01-05-2008, 01:56 AM
  5. Wired driver seat.
    By yaworski in forum Ideas & Suggestions
    Replies: 15
    Last Post: 04-10-2007, 01:50 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
proceed-collector
proceed-collector
proceed-collector
proceed-collector
linguistic-parrots
linguistic-parrots
linguistic-parrots
linguistic-parrots