1. Post #1
    TomyLobo's Avatar
    April 2009
    269 Posts
    Download

    What it does
    lua_reloadent reloads the code of a single entity, weapon or tool type.

    Advantages over lua_reloadents
    It's a lot more reliable and less intrusive than lua_reloadents.
    With lua_reloadents, you usually have to rebuild your test contraption if there was any "complex" component in it.
    Reloading a single entity class with lua_reloadent will most likely not break anything, apart for some pitfalls.
    Read the "pitfalls" section of the description in the Lua file for more details.

    How to use
    lua_reloadent class/toolmode
    For more info see the "Usage" section of the description in the Lua file.

    Version history
    1.5.2 - You can now choose whether to reload a tool, SENT or SWEP. See the "Usage" section in the Lua file for how.
    1.5.1 - Fixed an oversight error in the gmod13 support for weapons.
    1.5.0 - Added support for the current GMod 12/13 versions. (as of 2012-06-15)
    1.4.1 - Auto-complete is now case-insensitive. Fixed a server-side Lua error in lua_loadent.
    1.4 - Added auto-completition for both server-side and client-side lua_reloadent* commands
    1.3 - lua_(re)loadent now looks into the current gamemode's directory as well. It's just using FindInLua now.
    1.2.1 - lua_loadent now fills all necessary fields for both SENTs and SWEPs
    1.2 - Made lua_loadent work with SWEPs as well
    1.1 - Added lua_loadent
    1.0 - First public release

    GitHub
    I put all my stuff on GitHub. lua_reloadent is available at:
    https://github.com/TomyLobo/lua_reloadent
    This URL can also be used by an SVN client.

    Reply With Quote Edit / Delete Reply Germany Show Events Useful Useful x 19Lua King Lua King x 3 (list)

  2. Post #2
    TheGreatVax's Avatar
    March 2008
    137 Posts
    I fucking love you.
    Feature this in Garry's Mod!

    EDIT: It works completely flawlessly and even displays lua errors (if the reloaded file has any), god bless you.
    EDIT2: Request: if possible, make a lua_loadent, to load newly created entities
    Reply With Quote Edit / Delete Reply Germany Show Events Agree Agree x 5 (list)

  3. Post #3
    TomyLobo's Avatar
    April 2009
    269 Posts
    loading new ents is a bit more complicated. mostly due to scripted_ents.Register being undocumented :)

  4. Post #4
    Gold Member
    Carnag3's Avatar
    March 2006
    275 Posts
    misread OP
    Reply With Quote Edit / Delete Reply United Kingdom Show Events Disagree Disagree x 1Lua King Lua King x 1 (list)

  5. Post #5
    Gold Member
    Deco Da Man's Avatar
    July 2007
    1,005 Posts
    loading new ents is a bit more complicated. mostly due to scripted_ents.Register being undocumented :)
    Liar... (Refresh the page)

  6. Post #6
    Gold Member
    Gbps's Avatar
    December 2008
    3,438 Posts
    Liar... (Refresh the page)
    Like a hawk, like a hawk.

    Edited:

    This is awesome, thank you very much for this :3

  7. Post #7
    TomyLobo's Avatar
    April 2009
    269 Posts
    Added lua_loadent, updated first post. Thanks, deco

  8. Post #8
    TheGreatVax's Avatar
    March 2008
    137 Posts
    I can't load SWEPs, everytime I use it with "lua_loadent file" it gives me
    Code:
    No source file for entity 'file' found.
    Entities appearently work fine

    Well yeah, reloadent works fucking perfectly without any problems (Single and multiplayer) and hell I love you for that :P
    But anyway, please add support for autorun files if you can!

  9. Post #9
    TomyLobo's Avatar
    April 2009
    269 Posts
    you can just use lua_openscript(_cl) on autorun files :D

    SWEPs as well? man you're lazy

    Edited:

    Made lua_loadent work with SWEPs as well, updated first post

  10. Post #10
    TheGreatVax's Avatar
    March 2008
    137 Posts
    Well lua_(re)loadent certainly saves a lot time since it's literally instantly, so why not have it work with everything? :P

    Edit: when loading a swep it gives me the error:
    Code:
    attempt to index field 'Primary' (a nil value)
    which is
    SWEP.Primary.Recoil 		= 1

  11. Post #11
    TomyLobo's Avatar
    April 2009
    269 Posts
    meh, i'm more of a builder type, so I didn't make any weapons yet.
    make a list of stuff that is expected to be there :)

    EDIT: or I could just put PrintTable(SWEP) in an otherwise empty shared.lua :D

    Edited:

    lua_loadent now fills all necessary fields for both SENTs and SWEPs.
    first post updated.

  12. Post #12
    Gold Member
    conman420's Avatar
    January 2007
    1,778 Posts
    Hmm. Does it allow you to load multiple entities in one concommand? Then you could do:

    bind / "lua_reloadent sent_exploder sent_magical sent_destructo"

    Or perhaps works with a prefix. Like "lua_reloadent oe_*" :)

  13. Post #13
    Gold Member
    Gbps's Avatar
    December 2008
    3,438 Posts
    So far, when I do lua_reloadent on a weapon defined in gamemodes/[gamemode]/entities/weapons/, it gives me an error for being unable to find the file to load.

  14. Post #14
    TheGreatVax's Avatar
    March 2008
    137 Posts
    -stupid post-
    Reply With Quote Edit / Delete Reply Germany Show Events Funny Funny x 1 (list)

  15. Post #15
    Gold Member
    LuaStoned's Avatar
    September 2007
    1,300 Posts
    "lua_reloadent <ent>; <ent>; ent>"
    (It would work like that) Would be a nice addition
    ; would not work as seperator since it's the source seperator
    It would look like this:
    Code:
    ] lua_reloadent sent_omg1; sent_omg2; sent_omg3
    > lua_reloadent sent_omg1
    Unknown command: sent_omg2
    Unknown command: sent_omg3
    It would work if you put " around the arguments (lua_reloadent "sent_omg1; sent_omg2; sent_omg3")

  16. Post #16
    Grocel's Avatar
    October 2008
    1,279 Posts
    Do you make a SVN version?

  17. Post #17
    open.gl
    Overv's Avatar
    February 2007
    7,431 Posts
    ; would not work as seperator since it's the source seperator
    It would look like this:
    Code:
    ] lua_reloadent sent_omg1; sent_omg2; sent_omg3
    > lua_reloadent sent_omg1
    Unknown command: sent_omg2
    Unknown command: sent_omg3
    It would work if you put " around the arguments (lua_reloadent "sent_omg1; sent_omg2; sent_omg3")
    Or, simply lua_reloadent sent_omg1 sent_omg2 sent_omg3.

  18. Post #18
    TomyLobo's Avatar
    April 2009
    269 Posts
    lua_reloadent sent_omg1; lua_reloadent sent_omg2; lua_reloadent sent_omg3

    Edited:

    So far, when I do lua_reloadent on a weapon defined in gamemodes/[gamemode]/entities/weapons/, it gives me an error for being unable to find the file to load.
    then gmod set the "Folder" field wrong. I have no idea how to fix that though.

  19. Post #19
    Gold Member
    Lexic's Avatar
    March 2009
    5,782 Posts
    then gmod set the "Folder" field wrong. I have no idea how to fix that though.
    GAMEMODE.Folder is "gamemodes/[name]", rather than "[name]"

  20. Post #20
    TomyLobo's Avatar
    April 2009
    269 Posts
    thanks. never made a gamemode so far.
    I'll see if i can add this without complicating the code too much

    I meant ENT/SWEP.Folder is set wrong, btw

    Edited:

    I simply made it use file.FindInLua now. I hope that coincides with what can be include()d :)
    if it doesn't work, I'll need to check it manually

  21. Post #21
    Gold Member
    Entoros's Avatar
    October 2008
    2,318 Posts
    This is amazing. I love you.

  22. Post #22
    Mr_Roberto's Avatar
    October 2008
    133 Posts
    Your babies. Let me have them.
    Reply With Quote Edit / Delete Reply United States Show Events Dumb Dumb x 1 (list)

  23. Post #23
    TomyLobo's Avatar
    April 2009
    269 Posts
    domo arigato, mr roberto
    Reply With Quote Edit / Delete Reply Germany Show Events Funny Funny x 1 (list)

  24. Post #24
    jakejakke's Avatar
    August 2006
    206 Posts
    Have to admit it is very useful.
    It's stupid that you have to restart your server which takes billion years to see the results when you've teweaked your swep.

  25. Post #25
    TomyLobo's Avatar
    April 2009
    269 Posts
    1.4 - Added autocomplete for lua_reloadent* commands
    first post updated.

  26. Post #26
    Gold Member
    Bletotum's Avatar
    June 2008
    6,400 Posts
    Unknown command '_lua_reloadent' .

  27. Post #27
    TomyLobo's Avatar
    April 2009
    269 Posts
    Bletotum this is a server-side script.
    And its use is mainly development in single-player mode.

  28. Post #28
    Gold Member
    Bletotum's Avatar
    June 2008
    6,400 Posts
    I was developing in single-player.

    I got - the - error, when trying to use this addon for a script with alot of parenting offsets to get updated constantly... 'lua_reloadent flag_red' . And I got - the mentioned error.

    Lua_reloadent_cl does not update - the server's loaded code, I still have to reload the map... Lua_reloadent_sv gives the same - error. >.>...

  29. Post #29
    Gold Member
    Killer_Steel's Avatar
    October 2007
    1,362 Posts
    My god, PLEASE tell me this reloads gamemode without taking years, because if it does, I will love you. I will give you good ratings every post you make. This will help rocket my development of my gamemode to the nth degree.

  30. Post #30
    TomyLobo's Avatar
    April 2009
    269 Posts
    @Bletotum
    the server-side part of the script isn't initialized properly if that command is missing. there's probably a conflicting addon or something. Did you get any Lua errors on the server?
    Is the file "lua_reloadent.lua" in garrysmod\addons\lua_reloadent\lua\autorun\lua_rel oadent.lua?

    @Killer_Steel
    This will not reload the whole gamemode, but you can reload entities, weapons and tools within it.
    For autorun scripts use lua_openscript(_cl)

  31. Post #31
    Gold Member
    Bletotum's Avatar
    June 2008
    6,400 Posts
    Server?

    I told you, single-player-development...

    But no errors, just fucked up console commands.

    I don't see any of my addons messing this up...

  32. Post #32
    TomyLobo's Avatar
    April 2009
    269 Posts
    try entering this into your console:
    Code:
    lua_openscript autorun/lua_reloadent.lua
    btw: single-player mode also has client and server parts.
    Reply With Quote Edit / Delete Reply Germany Show Events Agree Agree x 2 (list)

  33. Post #33
    Gold Member
    Killer_Steel's Avatar
    October 2007
    1,362 Posts
    This'll make things way easier for me :D, thanks Tom!

  34. Post #34
    Gold Member
    -TB-'s Avatar
    August 2008
    1,364 Posts
    Ahh amazing addon. Saves me loads of time, and very easy to navigate too with the autocomplete.
    Reply With Quote Edit / Delete Reply United States Show Events Agree Agree x 1 (list)

  35. Post #35
    ASK ME ABOUT MY BACON FETISH
    Keelwar's Avatar
    September 2008
    852 Posts
    So, If i'm making a swep named... ah... Swep_good, I can say "lua_reloadent swep_good", and It would reload my swep? This is awesome! :D

  36. Post #36
    TomyLobo's Avatar
    April 2009
    269 Posts
    yep, that's how it works.

  37. Post #37
    MadDog986's Avatar
    March 2008
    304 Posts
    thanks so much for this... saves me tons of time!

  38. Post #38
    TomyLobo's Avatar
    April 2009
    269 Posts
    I made an SVN for all my stuff. lua_reloadent is available at:
    http://tldevtools.googlecode.com/svn.../lua_reloadent

    Not sure if I changed anything since the last release. Not much, if anything.

  39. Post #39
    Gold Member
    Lexic's Avatar
    March 2009
    5,782 Posts
    Code:
    ] lua_loadent sent_homingrpg
    Loading entity 'sent_homingrpg'...
    autorun/lua_reloadent.lua:338: attempt to call global 'build_ent_index' (a nil value)

  40. Post #40
    TomyLobo's Avatar
    April 2009
    269 Posts
    -snip-
    The SVN revision fixes this.
    I made a new release and updated the first post with it.