Lua VFS: Difference between revisions

From Spring
Jump to navigationJump to search
JK (talk | contribs)
Argh (talk | contribs)
m Font colors, 2 (used #55ee99)
Line 7: Line 7:
'''VFS.RAW_FIRST'''<br>
'''VFS.RAW_FIRST'''<br>
'''VFS.ZIP_FIRST'''<br>
'''VFS.ZIP_FIRST'''<br>
'''VFS.RAW_ONLY''' <font color=darkgreen>(same as VFS.RAW)</font><br>
'''VFS.RAW_ONLY''' <font color=#55ee99>(same as VFS.RAW)</font><br>
'''VFS.ZIP_ONLY''' <font color=darkgreen>(same as VFS.ZIP)</font><br>
'''VFS.ZIP_ONLY''' <font color=#55ee99>(same as VFS.ZIP)</font><br>


== Files ==
== Files ==
'''VFS.Include''' <font color=darkgreen>(if enviroment=nil then use current one)</font>
'''VFS.Include''' <font color=#55ee99>(if enviroment=nil then use current one)</font>
   ( string "filename" [, table enviroment [, number mode ] ] ) ->
   ( string "filename" [, table enviroment [, number mode ] ] ) ->
'''VFS.LoadFile'''
'''VFS.LoadFile'''
Line 20: Line 20:
   ( string "directory" [, string "pattern"  [, number mode [, string "optstr" ] ] ] )
   ( string "directory" [, string "pattern"  [, number mode [, string "optstr" ] ] ] )
     -> { [1] = string filename, ... }
     -> { [1] = string filename, ... }
   <font color="darkgreen">  optstr can contain:
   <font color="#55ee99">  optstr can contain:
       "r" = recursive
       "r" = recursive
       "d" = include dirs</font>
       "d" = include dirs</font>


== Packing ==
== Packing ==
<font color="darkgreen" style="font-size:110%">The Pack- and Unpack-functions are used to convert numbers->strings and strings->numbers.
<font color="#55ee99" 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.</font>


Line 43: Line 43:
'''VFS.PackF32'''
'''VFS.PackF32'''


<font color="darkgreen">arguments are:</font>
<font color="#55ee99">arguments are:</font>


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


<font color="darkgreen">arguments are:</font>
<font color="#55ee99">arguments are:</font>


'''VFS.UnpackX( string "binary" [, number offset ] [, number count] )'''
'''VFS.UnpackX( string "binary" [, number offset ] [, number count] )'''
   -> number | table { [1]=number,[2]=number,.. }
   -> number | table { [1]=number,[2]=number,.. }

Revision as of 20:54, 27 October 2008

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 [, number mode ] ] ) ->

VFS.LoadFile

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

VFS.FileExists

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

VFS.DirList

 ( string "directory" [, string "pattern"  [, number mode [, string "optstr" ] ] ] )
   -> { [1] = string filename, ... }
   optstr can contain:
     "r" = recursive
     "d" = include dirs

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 offset ] [, number count] )

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