Looking for definition of a function

Soul_RiderSoul_Rider Mod Bean Join Date: 2004-06-19 Member: 29388Members, Constellation, Squad Five Blue
Hey all,

Can anyone tell me where Shared.GetMatchingFileNames() is defined? I can't find it in the ns2 lua or the core lua files. By my reckoning, this has a fixed path definition to the ns2 directory. If it is not possible to amend that, would it work for me to create a new function which points to my mod folder in the players appdata folder and not use the pre-defined file?

I am looking specifically at adjusting the loading file to pick up my custom loading screens when running the mod from workshop.

Comments

  • SamusDroidSamusDroid Colorado Join Date: 2013-05-13 Member: 185219Members, Forum Moderators, NS2 Developer, NS2 Playtester, Squad Five Gold, Subnautica Playtester, NS2 Community Developer, Pistachionauts
    Shared.GetMatchingFileNames("path", "filename.ext", <true,false>, tableToInsertStringsInto)
    I think. Look in Loadng.lua
  • Soul_RiderSoul_Rider Mod Bean Join Date: 2004-06-19 Member: 29388Members, Constellation, Squad Five Blue
    edited April 2014
    No, using find in files in decoda, searching ns2 lua and core files together, there is no definiton of the function. It is called twice in loading, but not defined. It is also called in GatherEntry.lua, ModLader.lua, NS2Utility.lua, but it is not defined anywhere that can be found in lua.

    Maybe it's set in the API? I'll check that out.

    Here's the API entry, what does recursive mean in this context?
    "name": "Shared.GetMatchingFileNames",
                "arguments": [
                    {
                        "type": "string",
                        "name": "pattern"
                    },
                    {
                        "type": "boolean",
                        "name": "recursive"
                    },
                    {
                        "type": "table",
                        "name": "matchingFileTable"
                    }
                ]
            },
    
  • FehaFeha Join Date: 2006-11-16 Member: 58633Members
    edited April 2014
    Not sure in your case, but recursive when it comes to files are usually whether or not to search in subfolders I think.
    Now I dont know what each argument in your post is, but I am going to assume it is something like: stringPathWihoutFilename, boolRecursive and tableFilenamesToSearchFor

    So if you specify the file path "file/path/", recursive true and filenames {"apa.bepa", "foo.bar"} then files in "file/path/[foo.bar||apa.bepa]" or "file/path/subfolder_0/[...]/subfolder_n/[foo.bar||aba.bepa]" will match the search, but not any files "file/[foo.bar||apa.bepa]".
    With recursive false, only "file/path/[foo.bar||apa.bepa]" matches the search.


    EDIT:
    Reading the arguments samus suggests (although its one more), I would instead assume that the function only searches for one filename, putting the results in the table. But then I dont see how not using recursive would ever actually be useful, since there wont be matching filenames in the same folder. Or maybe it ignores file extensions so foo.txt and foo.exe are considered matching?
  • Soul_RiderSoul_Rider Mod Bean Join Date: 2004-06-19 Member: 29388Members, Constellation, Squad Five Blue
    I don't feel I have explained this clearly, or I just maybe haven't understood your responses. I'll try and clarify what I mean.

    In Loading.lua in the
    function InitBackgroundFileNames( out )
    

    There is the line
    Shared.GetMatchingFileNames( string.format("screens/%s/%d.jpg", mapname, i ), false, searchResult )
    

    As you can see, the path sent to the function is a sub-path of
    /"steam-path"/Natural Selection 2/ns2/
    

    What I need is a function that performs the GetMatchingFileName functionality, but enables me to specify a path which is not a sub path of ns2.

    For example: When I run my test version of GorgeCraft on my local PC I see my loading screens. The mod is running from
    /"steam-path"/Natural Selection 2/gc/
    
    with a desktop shortcut -game gc.

    When the mod is run from the workshop file, screens aren't in a sub-path of
    /"steam-path"/Natural Selection 2/game
    
    This means the loading screens are never displayed. I want to be able to specify a workshop path for the function to search in.

    I hope that makes sense. I am not the best at explaining things sometimes :D
  • FehaFeha Join Date: 2006-11-16 Member: 58633Members
    edited April 2014
    Ah sorry, seems like I misunderstood your question from lack of sleep. Thought you were asking for what a recursive flag in that function meant, because of lack of documentation of it.
    I think I would do better flying off to bed at this point before I confuse people even more, considering that I actually dont know the answer to the question you actually asked :)

    But try looking at the source code for loading-screen mods, wouldnt they have had to solve this as well?
  • Soul_RiderSoul_Rider Mod Bean Join Date: 2004-06-19 Member: 29388Members, Constellation, Squad Five Blue
    From what I can tell, it is only the
    function Shared.GetMatchingFileNames
    
    that uses the root path. General loading of files with the short path works fine; ie
    loadscreen:SetTexture( "screens/loadingscreen.jpg" )
    
  • xDragonxDragon Join Date: 2012-04-04 Member: 149948Members, NS2 Playtester, Squad Five Gold, NS2 Map Tester, Reinforced - Shadow
    If you see a function defined in the API docs, that generally means its engine level. That command is engine level so you wouldn't be able to modify its base functionality... I remember using game:// or user:// tags to change directories when using the IO libraries for lua, but I never did try to see if that was also exposed for SDK operations. I kind of expect that it wouldn't work, but its worth a shot I suppose. Otherwise its probably best to just hardcode some of the features.
  • McGlaspieMcGlaspie www.team156.com Join Date: 2010-07-26 Member: 73044Members, Super Administrators, Forum Admins, NS2 Developer, NS2 Playtester, Squad Five Blue, Squad Five Silver, Squad Five Gold, Reinforced - Onos, WC 2013 - Gold, Subnautica Playtester
    From what I understand of this, you cannot access non-mod directories manually (security reasons). Also, the screenshots from the loading folder won't be read until the mod is fully mounted. The issue with the current approach is said images won't be loaded when a player first joins a server, and on first load the vanilla images will be used. Once connected to a mod server and on the first map change (after mounting the mod), is when the mod's loading images will be used. The only way around it otherwise is if a client manually mounts a mod (activates it from the Mods menu). I'm pretty sure people have tried to solve this in the past to no avail. I hope you find a safe way arond this problem.
  • Soul_RiderSoul_Rider Mod Bean Join Date: 2004-06-19 Member: 29388Members, Constellation, Squad Five Blue
    Well, in general, activating the mod in the mod list is the only way players are going to play the mod. It is not as if it is designed to be a mod you have running on a server. It is mainly about single play. Although servers can run the game, it is mainly designed for local only use.

    Even so, setting up by activating the mod first and playing still doesn't allow the workshop method to display the loading images.
  • JimWestJimWest Join Date: 2010-01-03 Member: 69865Members, Reinforced - Silver
    You could use io api from lua for reading stuff.
  • Soul_RiderSoul_Rider Mod Bean Join Date: 2004-06-19 Member: 29388Members, Constellation, Squad Five Blue
    edited April 2014
    You are able to write and read from the %appdata% folder from games. I know because the BUS for GorgeCraft was a game save system. I hooked up @matso‌ scenario handler back in September 2012. I was able to save files out into the %appdata%/natural selection 2/ folder and record all entity data successfully, the bit I couldn't get working was loading the data back into the mod.

    Incidentally, I discovered that %appdata% is the ONLY folder you can write to. I tried saving to the mod folder in the ns2 directory, and documents and many other locations, and it was the only directory I was allowed to save in.

    hmm, I should go back and look at that code and see how I got the save path working and go from there!!
Sign In or Register to comment.