General questions

RedSwordRedSword Join Date: 2006-12-07 Member: 58947Members, Reinforced - Shadow, WC 2013 - Supporter
edited June 2013 in Modding
Hi,

I have a certain interest towards doing modding in NS2. But before starting, I have questions regarding it :
  • Is there a "plugin" approach to NS2 ? Rather than overwriting ("modding") files ? If not, is it planned ?
  • What if 2 plugins modify the same file ? Is it impossible to have both then ?
  • How far can we do mod stuff ? Can we run a DLL using LUA code (didn't check a lot of LUA)
  • Is everything in LUA avaible to use ?
  • Are server pluginsmods downloaded by clients (I read there are server and non-server mod; I take for granted server aren't DL'ed by client... right ?) ? And if they're not downloadable; is there a way for them to see it ? (i.e. is private code possible ?)
  • Do NS2 devs have a public ToDo list ? (If so where is it ?; and I mean beside what is being advertised in forum/BT discussion)
  • What is the fastest way to see a mod's code ? (i.e. without subscribing; when only the workshop link is availaible; do we HAVE TO subscribe ?)

Thank you,

Red

Comments

  • Person8880Person8880 Join Date: 2013-01-02 Member: 177167Members, Squad Five Blue
    I'll answer what I can.

    1. Is there a "plugin" approach to NS2 ? Rather than overwriting ("modding") files ? If not, is it planned ?
    There's no set plugin approach, but it's pretty easy to make your own plugin system. NS2's Lua API is a bit bare and you have to setup your own framework in a lot of cases.

    2. What if 2 plugins modify the same file ? Is it impossible to have both then ?
    Generally it's a good idea not to copy and paste files from the main game into your mod. Make a folder for your mod (i.e lua/myawesomemod), put all your Lua files in there and use hooking to override parts of the game code. See below for what I mean by hooking.

    3. How far can we do mod stuff ? Can we run a DLL using LUA code (didn't check a lot of LUA)
    If you're referring to C extensions of Lua, they can't be loaded. Only pure Lua files can be loaded.

    4. Is everything in LUA avaible to use ?
    As far as I know, everything but the os library and coroutines is available.

    5. Are server mods downloaded by clients (I read there are server and non-server mod; I take for granted server aren't DL'ed by client... right ?) ? And if they're not downloadable; is there a way for them to see it ? (i.e. is private code possible ?)
    Mods are downloaded by clients, you can control which files clients execute using a few methods. Private code is not possible, anyone can open workshop mod's files and read them, and the mods include all the Lua files, not just files for the client.

    6. Do NS2 devs have a public ToDo list ? (If so where is it ?; and I mean beside what is being advertised in forum/BT discussion)
    I can't answer this one.

    7. What is the fastest way to see a mod's code ? (i.e. without subscribing; when only the workshop link is availaible; do we HAVE TO subscribe ?)
    Some modders, such as myself, put their code on GitHub to read without needing to subscribe. Not all mod authors do though, so the guaranteed way to read it is to subscribe and download it.

    Regarding hooking, this is what I mean:
    local OldChangeMap = MapCycle_ChangeMap
    
    function MapCycle_ChangeMap( Map )
        --Do your stuff here before the map changes...
    
        --Run the old function after your code, so you can block it/alter it.
        return OldChangeMap( Map )
    end
    
    Using methods like this, you can safely override any function and still allow other mods to also override that function.

    As for loading methods, there's a few available.

    Firstly is the GameSetup.xml file. You ought to use this only if your mod is a new gamemode, as it will block all other mods that use GameSetup.xml from loading, or they may block your mod instead. An example of a GameSetup.xml, which goes in the root of your mod folder, above the lua/ folder and other folders:
    <game>
        <name>myawesomemod</name>
        <client>lua/myawesomemod/client.lua</client>
        <server>lua/myawesomemod/server.lua</server>
        <predict>lua/myawesomemod/predict.lua</predict>
        <loading>lua/myawesomemod/loading.lua</loading>
    </game>
    
    This will load the given Lua files for each of the Lua states available. From these files you can load the rest of your mod's files with the Script.Load function.

    The second method available is the entry point system, which is better for minor mods as lots of mods can load using this system without getting in each other's way. However, this system loads your mod after the default files/GameSetup.xml files have been loaded, so you can't override network messages with this method.

    This mod is an example of how the entry point system works:
    http://steamcommunity.com/sharedfiles/filedetails/?id=137123467

    Hopefully this helps answer your questions.
  • RedSwordRedSword Join Date: 2006-12-07 Member: 58947Members, Reinforced - Shadow, WC 2013 - Supporter
    Hi,

    Thanks for your answers.

    I checked your forum's messages and I see you made Shine administration. Interesting. I saw on github that you tell its advantages on DAK.

    I also see SparkMod and I'm considering doing something under one or the other (or a "standalone" mod; still considering). May I have your thought on yours versus SparkMod ? SM seems more generic (seeing it can hook any function; while yours seem to be hooking only SH functions). His also seems more Sourcemod-users-friendly. Yours seems more complete from an admin perspective...

    And would there be conflicts between the two ? (I think not; since paths seems to be different; "lua/SparkMod" versus "lua/core", "lua/extension", "lua/lib". Just asking to be sure. (I'm asking about code conflict; there might be indirectly with in-game commands, which is not what I'm asking)

    Do you accept any pull requests (that adds something) ? Or do those have to be solely be regarding plugin administration ? (i.e. doing a function that gives life)

    And is there any plugins "hub" for SM or SH I might be missing ? (Beside the github I mean; like Sourcemod... for Sourcemod plugins)

    Another question; which LUA version is NS2 using ? It is not even written in the wiki http://wiki.unknownworlds.com/ns2/Lua :/

    Thank you,

    RedSword
  • Person8880Person8880 Join Date: 2013-01-02 Member: 177167Members, Squad Five Blue
    edited June 2013
    There shouldn't be conflicts in the code, I haven't looked over the SparkMod code much, but I assume it's using hooking like I am.

    I'm not sure what you mean by "hook any function, while yours seem to be hooking only SH functions". Shine can hook any function, I've only hooked into the ones I have use for, but it's easy to add more.

    As for accepting pull requests, it depends on the content. The mod's primarily an admin mod, so the main files should only be administration related. However, you can do what HBZ do and create a mod based on Shine and/or other mods in one and add all the plugins you want to in it. The code's on GitHub and free for you to create a derivative mod using it.

    There's no "hub" for plugins for them, as I don't think anyone's written any public plugins for them yet. I know HBZ have a custom ranking/stats plugin for Shine that they use, but that's about it. NS2's modding community is rather small, nowhere near the scale of Sourcemod.

    For your last question, build 248 is running Lua 5.1. The new build 249 beta is running LuaJIT, not sure which version but I assume it's the latest. Edit: Just checked the final version of 249 and it's running LuaJIT 2.0.1.
Sign In or Register to comment.