2011-12-05 19:27:07 +01:00
|
|
|
Module
|
2012-06-20 02:15:56 +02:00
|
|
|
name: corelib
|
2011-12-05 19:27:07 +01:00
|
|
|
description: Contains core lua classes, functions and constants used by other modules
|
|
|
|
author: OTClient team
|
2012-05-01 15:06:38 +02:00
|
|
|
website: www.otclient.info
|
2012-03-23 14:48:05 +01:00
|
|
|
reloadable: false
|
2011-12-05 19:27:07 +01:00
|
|
|
|
2012-02-20 03:27:08 +01:00
|
|
|
@onLoad: |
|
2012-06-26 00:13:30 +02:00
|
|
|
dofile 'math'
|
|
|
|
dofile 'string'
|
|
|
|
dofile 'table'
|
2012-07-23 17:11:53 +02:00
|
|
|
dofile 'bitwise'
|
Add binary operations for lua
This is something I was always missing - posibbility to operate on
binary files or streams in pure lua. In most cases we do only need to
read simple variables from files such as integers with different amount
of bytes. This "class" will provide that ability.
It's a simple implementation of following C module for lua:
http://www.inf.puc-rio.br/~roberto/struct/
It has much less, though. Following elements have been implemented:
">" flag to set mode to big endian.
"<" flag to set mode to little endian.
"b" a signed char.
"B" an unsigned char.
"h" a signed short (2 bytes).
"H" an unsigned short (2 bytes).
"i" a signed int (4 bytes).
"I" an unsigned int (4 bytes).
"l" a signed long (8 bytes).
"L" an unsigned long (8 bytes).
"s" a zero-terminated string.
An example how to use it:
```lua
local packed = Struct.pack('<LIhBsb', 123456789123456789, 123456789,
-3200, 255, 'Test message', -1)
-- packed is now a lua string we can save to file as binary data
local L, I, h, B, s, b = Struct.unpack('<LIhBsb', packed)
print(L, I, h, B, s, b)
```
You can use g_resources.readFileContents as function to read binary
files and parse them via this class.
2015-05-18 21:31:16 +02:00
|
|
|
dofile 'struct'
|
2012-03-18 14:34:39 +01:00
|
|
|
|
2012-02-06 05:39:52 +01:00
|
|
|
dofile 'const'
|
|
|
|
dofile 'util'
|
|
|
|
dofile 'globals'
|
2014-04-01 05:27:33 +02:00
|
|
|
dofile 'config'
|
2012-02-06 05:39:52 +01:00
|
|
|
dofile 'settings'
|
|
|
|
dofile 'keyboard'
|
|
|
|
dofile 'mouse'
|
2013-02-27 20:24:32 +01:00
|
|
|
dofile 'net'
|
2012-02-05 23:42:35 +01:00
|
|
|
|
2014-06-06 18:10:14 +02:00
|
|
|
dofiles 'classes'
|
2012-04-26 17:11:03 +02:00
|
|
|
dofiles 'ui'
|
2012-08-30 07:59:10 +02:00
|
|
|
|
|
|
|
dofile 'inputmessage'
|
2014-04-01 18:20:18 +02:00
|
|
|
dofile 'outputmessage'
|