Lua VFS: Difference between revisions

From Spring
Jump to navigationJump to search
Jk (talk | contribs)
Jk (talk | contribs)
82+
Line 1: Line 1:
[[Engine_Development|Development]] < [[Lua_Scripting|Lua Scripting]] < {{FULLPAGENAME}}
[[Engine_Development|Development]] < [[Lua_Scripting|Lua Scripting]] < {{FULLPAGENAME}}


== Modes ==
= Modes =
'''VFS.RAW'''<br>
'''VFS.RAW'''<br>
'''VFS.MOD''' <font color=red>(unimplemented, acts like VFS.ZIP)</font><br>
'''VFS.MOD''' <font color=red>(unimplemented, acts like VFS.ZIP)</font><br>
Line 12: Line 12:
'''VFS.ZIP_ONLY''' <font color=#55ee99>(same as VFS.ZIP)</font><br>
'''VFS.ZIP_ONLY''' <font color=#55ee99>(same as VFS.ZIP)</font><br>


== Files ==
= Files =
'''VFS.Include''' <font color=#55ee99>(if enviroment=nil then use current one)</font>
'''VFS.Include''' <span class=note>(if enviroment=nil then use current one)</span>
   ( string "filename" [, table enviroment = nil [, number mode ] ] ) ->
   ( string "filename" [, table enviroment = nil [, number mode ] ] ) ->
'''VFS.LoadFile'''
'''VFS.LoadFile'''
Line 25: Line 25:
   ( string "directory", [, string "pattern" = "*"  [, number mode ] ] )
   ( string "directory", [, string "pattern" = "*"  [, number mode ] ] )
     -> { [1] = string subdir1, ... }
     -> { [1] = string subdir1, ... }
'''VFS.UseArchive''' <font color="#55ee99">unsynced only!</font>
 
'''VFS.UseArchive''' <span class=warning>unsynced only!</span>
   ( string "filename" [, number mode ], lua_function [, arg1 [,arg2 ]] )
   ( string "filename" [, number mode ], lua_function [, arg1 [,arg2 ]] )
     -> result1,result2,... of the given lua_function
     -> result1,result2,... of the given lua_function
'''VFS.MapArchive''' <font color="#55ee99">unsynced only!</font>
  <span class=note>Loads an archive '''temporarely''' in the VFS and then runs the given lua_function,<br>which can make usage of the files in the archive.</span>
 
'''VFS.MapArchive''' <span class=warning>unsynced only!</span>
   ( string "filename/modname of archive", [string checksum of archive] )
   ( string "filename/modname of archive", [string checksum of archive] )
     -> bool
     -> bool
<font color="#55ee99">Permanently loads an archive into the VFS (to load zipped music collections etc.). If checksum is given it checks if the to be loaded file is correct, if not then it won't load it and return false.</font>
  <span class=note>Permanently loads an archive into the VFS (to load zipped music collections etc.).<br>If checksum is given it checks if the to be loaded file is correct,<br>if not then it won't load it and return false.</span>


== Packing ==
= Packing =
<font color="#55ee99" style="font-size:110%">The Pack- and Unpack-functions are used to convert numbers->strings and strings->numbers.
<span class="note" style="font-size:110%">The Pack- and Unpack-functions are used to convert numbers->strings and strings->numbers.
So you can read a binary file and then convert the received strings back to numbers and the other way around. Also you can use it in combination with the SendLuaXYZMsg-functions.</font>
So you can read a binary file and then convert the received strings back to numbers and the other way around. Also you can use it in combination with the SendLuaXYZMsg-functions.</span>




Line 52: Line 55:
'''VFS.PackF32'''
'''VFS.PackF32'''


<font color="#55ee99">arguments are:</font>
<span class=note>arguments are:</span>


'''VFS.PackX( number arg1, number arg2, number arg3, ... )''' -> string
'''VFS.PackX( number arg1, number arg2, number arg3, ... )''' -> string
Line 73: Line 76:
'''VFS.UnpackF32'''
'''VFS.UnpackF32'''


<font color="#55ee99">arguments are:</font>
<span class=note>arguments are:</span>


'''VFS.UnpackX( string "binary" [, number position = 1] [, number count] )'''
'''VFS.UnpackX( string "binary" [, number position = 1] [, number count] )'''
   -> number | table { [1]=number,[2]=number,.. }
   -> number | table { [1]=number,[2]=number,.. }
= Zlib =
'''VFS.ZlibCompress''' <span class=warning>unsynced only!</span>
  ( string "uncompressedStr" )
    -> nil | string "compressedStr"
'''VFS.ZlibDecompress''' <span class=note>available in synced, too!</span>
  ( string "compressedStr" )
    -> nil | string "uncompressedStr"


[[category: Lua]]
[[category: Lua]]

Revision as of 06:33, 30 June 2010

Development < Lua Scripting < Lua VFS

Modes

VFS.RAW
VFS.MOD (unimplemented, acts like VFS.ZIP)
VFS.MAP (unimplemented, acts like VFS.ZIP)
VFS.BASE (unimplemented, acts like VFS.ZIP)
VFS.ZIP
VFS.RAW_FIRST
VFS.ZIP_FIRST
VFS.RAW_ONLY (same as VFS.RAW)
VFS.ZIP_ONLY (same as VFS.ZIP)

Files

VFS.Include (if enviroment=nil then use current one)

 ( string "filename" [, table enviroment = nil [, number mode ] ] ) ->

VFS.LoadFile

 ( string "filename" [, number mode ] ) -> nil | string data

VFS.FileExists

 ( string "filename" [, number mode ] ) -> boolean

VFS.DirList

 ( string "directory" [, string "pattern" = "*"  [, number mode ] ] )
   -> { [1] = string filename, ... }

VFS.SubDirs

 ( string "directory", [, string "pattern" = "*"  [, number mode ] ] )
   -> { [1] = string subdir1, ... }

VFS.UseArchive unsynced only!

 ( string "filename" [, number mode ], lua_function [, arg1 [,arg2 ]] )
   -> result1,result2,... of the given lua_function
 Loads an archive temporarely in the VFS and then runs the given lua_function,
which can make usage of the files in the archive.

VFS.MapArchive unsynced only!

 ( string "filename/modname of archive", [string checksum of archive] )
   -> bool
 Permanently loads an archive into the VFS (to load zipped music collections etc.).
If checksum is given it checks if the to be loaded file is correct,
if not then it won't load it and return false.

Packing

The Pack- and Unpack-functions are used to convert numbers->strings and strings->numbers. So you can read a binary file and then convert the received strings back to numbers and the other way around. Also you can use it in combination with the SendLuaXYZMsg-functions.


VFS.PackU8

VFS.PackU16

VFS.PackU32

VFS.PackS8

VFS.PackS16

VFS.PackS32

VFS.PackF32

arguments are:

VFS.PackX( number arg1, number arg2, number arg3, ... ) -> string

VFS.PackX( {[1]=number,[2]=number,..} ) -> string


VFS.UnpackU8

VFS.UnpackU16

VFS.UnpackU32

VFS.UnpackS8

VFS.UnpackS16

VFS.UnpackS32

VFS.UnpackF32

arguments are:

VFS.UnpackX( string "binary" [, number position = 1] [, number count] )

 -> number | table { [1]=number,[2]=number,.. }

Zlib

VFS.ZlibCompress unsynced only!

 ( string "uncompressedStr" )
   -> nil | string "compressedStr"

VFS.ZlibDecompress available in synced, too!

 ( string "compressedStr" )
   -> nil | string "uncompressedStr"