Game Development Reference
In-Depth Information
local aryTable = {4,7,1,3,8,6,5,2}
print(table.concat(aryTable, ","))
table.sort(aryTable)
print(table.concat(aryTable, ","))
Note These functions can be used only with array-type tables and are available in the table namespace.
In order to use these functions, you need to prefix them with table .
OS Functions
There are a few functions that are available to interact with the OS; these can be found in the os
namespace and hence are prefixed with os . The following subsections describe how they're used.
os.clock ( )
This function returns the approximate CPU time used by the program, in seconds. Every time some
code is executed, this is incremented with the amount of CPU time used by the code.
print(os.clock())
-->0.030148 (could be different on your system)
print(os.clock())
-->0.030250 (could be different on your system)
Note
This does not return the time from the system clock; this is just the total CPU time used.
os.date ( [format [,time] ] )
This function returns a string or a table containing the date and time, formatted as specified by the
given string format. If no parameters are passed, it returns the string containing the current date and
time based on the host system and the current locale. If the format is "*t" , then the function returns
a table with the following fields:
year (four digits)
month (1-12)
day (1-31)
hour (0-23)
min (0-60)
sec (0-60)
wday (1-7, beginning with Sunday)
yday (day of the year; 1-366)
isdst (Boolean indicating if daylight saving time is in effect)
 
Search WWH ::




Custom Search