For any feature requests to either the Skyline Engine or the websites and forums please leave your suggestion here.

Lua File System or Equivalent

Lua File System or Equivalent

Postby Shando » 22 May 2015, 09:51

Hi All,

Just a quick request for an easy way to access files/folders on the Hard Drive.

I know that you already have some accessors, as I have seen
Code: Select all
sky.getDir_Models()
in the Scatter Plugin ;)

Basically, I would like:

1) a way to access a directory in the final .exe directory (my own, or the "Script" directory)
2) a way to get all files in a specified directory that contain a specific suffix (such as .lua)

Thanks

Shando

EDIT: I think I've found a way to handle 2) above:

Code: Select all
function get_files ( path, prepend_path_to_filenames )
   if path:sub(-1) ~= '\\' then
      path = path .. '\\';
   end

   local pipe = io.popen ( 'dir /b/a-d "' .. path .. '*.*" 2> nul' );
   local output = pipe:read'*a';

   pipe:close();

   -- If your file names contain national characters
   -- output = convert_OEM_to_ANSI(output)
   local files = { };

   for filename in output:gmatch'[^\r\n]+' do
      if prepend_path_to_filenames then
         filename = path .. filename;
      end

      -- ONLY SAVE ".cha" FILES
      if ( string.sub ( filename, -4, -1 ) == ".cha" ) then
         table.insert ( files, filename );
      end
   end

   return files;
end


To use, you need something like:

Code: Select all
-- need to change this next line depending on how we access folders in Skyline:
local array_of_files = get_files ( 'D:\\Aurasoft\\SkylineSDK', false )

for _, fn in ipairs ( array_of_files ) do
   sky.lprint ( fn );
end


I found this on Stack Overflow (http://stackoverflow.com/questions/13665333/extracting-file-data-with-lua - in a response by Egor Skriptunoff), just not sure if it will work in a final game??
Ryzen 7 4800H 16GB GTX1650 Win 11 64
Love, Hope, Strength http://www.lovehopestrength.co.uk
User avatar
Shando
Skyline Moderator
Skyline Moderator
 
Posts: 560
Joined: 06 Mar 2013, 22:35
Location: Moffat Beach, Queensland
Skill: Programmer
Skill: Scripter
Skill: Level Designer

Re: Lua File System or Equivalent

Postby SolarPortal » 19 Jun 2015, 16:52

Nice workarounds m8.

It would not be too diffuicult to add all the directory finding and file finding tools.
We have a lot of written out code in the main skyline codebase anyway.
If i remember, i will try and get this up and running. :)
Skyline Game Engine - Lead Dev.
Please provide as much info as possible when asking for help.


Specs: OS: Win 10 64bit, CPU: Intel i7 4770 3.4ghz x 4 core(8 threads), GPU: Nvidia GTX 1060 6GB, Ram: 16gig DDR3, Windows on 250gb Samsung Evo 860

Twitter: @SolarPortal
Instagram: @SolarPortal
User avatar
SolarPortal
Skyline Founder
Skyline Founder
 
Posts: 3631
Joined: 29 Jul 2012, 15:56
Location: UK
Skill: 3D Modeller
Skill: 2D Artist
Skill: Programmer
Skill: Level Designer


Return to Feature Requests

Who is online

Users browsing this forum: No registered users and 6 guests

cron