Lua VFS: Difference between revisions

From Spring
Jump to navigationJump to search
Lurker (talk | contribs)
Lurker (talk | contribs)
Line 8: Line 8:
'''VFS.ZIP_FIRST'''<br>
'''VFS.ZIP_FIRST'''<br>
'''VFS.RAW_ONLY'''<br>
'''VFS.RAW_ONLY'''<br>
'''VFS.ZIP_ONLY'''
'''VFS.ZIP_ONLY'''<br>
 
Note that RAW_ONLY and ZIP_ONLY are merely backwards-compatible names for RAW and ZIP.
Note that RAW_ONLY and ZIP_ONLY are merely backwards-compatible names for RAW and ZIP.



Revision as of 23:54, 30 May 2008

Modes

VFS.RAW
VFS.MOD
VFS.MAP
VFS.BASE
VFS.ZIP
VFS.RAW_FIRST
VFS.ZIP_FIRST
VFS.RAW_ONLY
VFS.ZIP_ONLY

Note that RAW_ONLY and ZIP_ONLY are merely backwards-compatible names for RAW and ZIP.

Currently, MOD, MAP, and BASE are unimplemented, and all act like ZIP.

Files

VFS.Include

 ( 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,.. }