-
Notifications
You must be signed in to change notification settings - Fork 192
System API
This library is the core of the operating system and allows you to manage it at a basic level. Below are only the most necessary methods due to my laziness to create documentation, however, those that are available will be quite enough for most developers.
Returns real world Unix timestamp of current system using timezone defined in user properties.
os.date("%d %b %Y %H:%M:%S" system.getTime())> 13 Jan 2019 05:10:32Returns currently logged in user name.
system.getUser()> Herobrine1488Returns path to currently running script. For example, if you create file named /MineOS/Scripts/Test.lua and call this function from it, the following string will be returned:
> /MineOS/Scripts/Test.luaSearches for files with .lang extension in directory by given path and returns an deserialized table. Priority is given to the language that is set in currently logged in user properties. If required language is not found, this function tries to load English.lang file. If it is not found, function tries to load the first available file. If the directory by given path is empty, an error occurs.
system.getLocalization("/Robot.app/Localizations/")> {
greeting = "Hello",
robot = "This is my robot"
}Works the same way as system.getLocalization() does, but automatically searches for appropriate localization file in Localizations/ directory located near currently running script:
Sample.app/
Main.lua
Localizations/
English.lang
Russian.lang
Auxiliary method for programs to parse their arguments. Returns two tables, the first one containing all incoming parameters, the second containing “options”. Options must be indicated by a leading -, and all options must only be a single character, since multiple characters following a single - will be interpreted as multiple options. Options specified with 2 dashes are not split and can have multiple letters. Also, 2-dash options can be given values by using an equal sign. The following examples will show how this function works:
system.parseArguments("meow", "-purr", "--purr", "--meow=purr", "-meow=purr")> {
"meow"
},
{
"p"
"u"
"r"
"purrr"
meow = "purr",
"m"
"e"
"o"
"w"
"="
}Every MineOS application is a directory with .app extension, which has the following contents:

The Main.lua file is launched on application start, and Icon.pic is used to display application icon. Application directory is very convenient to store some resources: localization files, images, configs, etc.
You can click on the corresponding option in the context menu to create sample application:

When application directory is created, it's a good time to read wiki of how to use system APIs. You can instantly edit Main.lua file to do some source code changes:


