1. Post #1
    Box collector
    haza55's Avatar
    October 2005
    545 Posts
    I wrote this awhile back, and thought I should release it to the community.

    gmsv_datadesc allows a Lua programmer to read and write to Data Descriptor entries in C++ Entities.

    DATADESC Tables:
    These tables look like this.

    Code:
    BEGIN_DATADESC( CGrenadeFrag )
    
    	// Fields
    	DEFINE_FIELD( m_pMainGlow, FIELD_EHANDLE ),
    	DEFINE_FIELD( m_pGlowTrail, FIELD_EHANDLE ),
    	DEFINE_FIELD( m_flNextBlipTime, FIELD_TIME ),
    	DEFINE_FIELD( m_inSolid, FIELD_BOOLEAN ),
    	DEFINE_FIELD( m_combineSpawned, FIELD_BOOLEAN ),
    	DEFINE_FIELD( m_punted, FIELD_BOOLEAN ),
    	
    	// Function Pointers
    	DEFINE_THINKFUNC( DelayThink ),
    
    	// Inputs
    	DEFINE_INPUTFUNC( FIELD_FLOAT, "SetTimer", InputSetTimer ),
    
    END_DATADESC()
    That is the datadesc table for npc_grenade_frag

    This module will allow you to retrieve or set the data fields such as m_flNextBlipTime.

    This would be done like so.

    local e = ents.Create("npc_grenade_frag")
    e:Spawn()
    
    e:SetDataDescEntry("m_flNextBlipTime", CurTime() + 0.5)
    
    //We can also read it back
    
    print(e:GetDataDescEntry("m_flNextBlipTime"))
    
    // We can also see all our members and their types
    
    PrintTable(e:GetDataDescInfo())
    

    A Note: If it crashes, please post the field name and entity type and if you were Setting or Getting

    Download(Includes bin + src):
    Ver3
    Reply With Quote Edit / Delete Reply Australia Show Events Friendly Friendly x 2Useful Useful x 1 (list)

  2. Post #2
    Gold Member
    Deco Da Man's Avatar
    July 2007
    1,017 Posts
    fuck

    yes


    I love you.

    This opens up so many possibilities.
    Reply With Quote Edit / Delete Reply Australia Show Events Agree Agree x 2 (list)

  3. Post #3
    Taught by John Lua
    MakeR's Avatar
    May 2007
    2,914 Posts
    haza55, i think you just turned me! (that is if you are male)

    Edited:

    Can you get a table of all data descriptors of an entity?
    Reply With Quote Edit / Delete Reply United Kingdom Show Events Dumb Dumb x 1Optimistic Optimistic x 1 (list)

  4. Post #4
    Box collector
    haza55's Avatar
    October 2005
    545 Posts
    haza55, i think you just turned me! (that is if you are male)

    Edited:

    Can you get a table of all data descriptors of an entity?
    I could add that.

    Atm the best way is to just look inside the sourcesdk.

  5. Post #5
    Taught by John Lua
    MakeR's Avatar
    May 2007
    2,914 Posts
    I could add that.

    Atm the best way is to just look inside the sourcesdk.
    That's what i'm doing at the moment, but it would be a hell of a lot easier to add that feature.

    Edited:

    Haha, this is awesome. I just changed the 'm_nMaxBounces' datadesc entry for the combine ball so that it can bounce 50 times before dying.

  6. Post #6
    Box collector
    haza55's Avatar
    October 2005
    545 Posts
    :P

    Ok well I coded some extra stuff.

    Added heaps more field types(to my internal code).

    Read first post for DL.

  7. Post #7
    Taught by John Lua
    MakeR's Avatar
    May 2007
    2,914 Posts
    <3

  8. Post #8
    Box collector
    haza55's Avatar
    October 2005
    545 Posts
    Hmm appears I broke it. Once Sec.

  9. Post #9
    Taught by John Lua
    MakeR's Avatar
    May 2007
    2,914 Posts
    You can activate the dogs throwing and catching capabilities with this.

  10. Post #10
    Box collector
    haza55's Avatar
    October 2005
    545 Posts
    Entity(1):SetDataDescEntry("m_flGravity", 0.1)

    Ahhhh, <3 10% gravity on me.

    You can edit soooooo much!

    Oh right, Ill upload the fixed version in a sec.

  11. Post #11
    Taught by John Lua
    MakeR's Avatar
    May 2007
    2,914 Posts
    Entity(1):SetDataDescEntry("m_flGravity", 0.1)
    When i attempted that, my game crashed :S

  12. Post #12
    Box collector
    haza55's Avatar
    October 2005
    545 Posts
    Fixed

  13. Post #13
    likes men
    Python1320's Avatar
    May 2007
    1,720 Posts
    Holy crap, if this is what I think it is, huge thanks!

  14. Post #14
    Taught by John Lua
    MakeR's Avatar
    May 2007
    2,914 Posts
    entity.GetDataDescInfo is returning nil.

    Edited:

    Nevermind, fixed.

  15. Post #15
    Grocel's Avatar
    October 2008
    1,238 Posts
    It's can very usefull. :)

  16. Post #16
    Box collector
    haza55's Avatar
    October 2005
    545 Posts
    And who said we couldn't modify the HL2 jeep's gun so it shoots 1000 round/s.


  17. Post #17
    Jaykin Bacon: Episode 3
    SteveUK's Avatar
    May 2005
    2,452 Posts
    iirc if you wanted to use the HL2 grenade in a SWEP, you couldn't make it kill credit. But it's easy enough now if you set m_hThrower to the player.

  18. Post #18
    likes men
    Python1320's Avatar
    May 2007
    1,720 Posts
    And who said we couldn't modify the HL2 jeep's gun so it shoots 1000 round/s.

    :SetBodygroup( 1, 1 ) !!!

    Someone is having fun with dumb ratings. This post got dumb rating right after I clicked Submit.
    Reply With Quote Edit / Delete Reply Finland Show Events Dumb Dumb x 1 (list)

  19. Post #19
    Gold Member

    July 2006
    1,953 Posts
    Dumbbot on the move.

    Also, epic module.

  20. Post #20

  21. Post #21
    devmon's Avatar
    July 2007
    256 Posts
    So everyone here is dumb?

  22. Post #22
    Gold Member
    Deruu's Avatar
    December 2007
    443 Posts
    So everyone here is dumb?
    Someone figured it would be funny to create a bot that automatically rates everyone dumb, just ignore it.

  23. Post #23
    Mr_Roberto's Avatar
    October 2008
    133 Posts
    My babies. You must have them.

  24. Post #24
    Jaykin Bacon: Episode 3
    SteveUK's Avatar
    May 2005
    2,452 Posts
    A really useful function is if you could hook output functions
    Reply With Quote Edit / Delete Reply United Kingdom Show Events Agree Agree x 1 (list)

  25. Post #25
    likes men
    Python1320's Avatar
    May 2007
    1,720 Posts
    Linux version possibility? It doesn't detour or sigscan so porting should be quite easy...Right? EDIT: Right!
    Code:
    srcds GServ ~/developement/gmsv_datadesc> make -s
    srcds GServ ~> cd ~/srcds/clone/orangebox/
    srcds GServ ~/srcds/clone/orangebox> ./srcds_run -game garrysmod +map gm_construct -port 27019
    --snip--
    Connection to Steam servers successful.
       VAC secure mode is activated.
    lua_run require'datadesc'
    > require'datadesc'...
    Loaded GM Lua DLL.
    bot
    lua_run PrintTable(Entity(1):GetDataDescInfo())
    > PrintTable(Entity(1):GetDataDescInfo())...
    m_flSuitUpdate  =       FIELD_TIME
    m_flPoseParameter       =       FIELD_FLOAT
    m_hLightingOrigin       =       FIELD_EHANDLE
    --snip--
    Edited:

    Linux Download: http://g.iriz.org/~srcds/modules/
    It might work or might not work. EDIT: just tested and seems to work as well as the original version.
    Reply With Quote Edit / Delete Reply Finland Show Events Agree Agree x 2Useful Useful x 1 (list)