Skip to content
Li, Xizhi edited this page Jul 6, 2022 · 26 revisions

Build-in NPL CommandLine

Native Params

The following command line is built-in to NPL executable.

  • bootstrapper="myapp/main.lua": set bootstrapper file
  • [-d|D] [filename]: -d to run in background (daemon mode), -D to force run in fore ground.
  • dev="C:/MyDev/": set dev directory, if "" or "/", it means the current working directory. When this is specified, all disk search path has higher priority than pkg or zip file. If not specified, the reverse is true.
  • servermode="true": disable 3D rendering and force running in server mode.
  • writablepath="C:/temp/": this defaults to current working directory under win32 and linux. But one may set it to a different path.
  • logfile="log2016.5.20.txt": change default log.txt location
  • loglevel="INFO": log.txt's loglevel. it can be "FATAL, ERROR, WARN, INFO, DEBUG, TRACE". default to "TRACE".
  • assetlog_level="remote": default asset.log file's log level. it can be "all|remote|error". default to "error".
  • single="true": force only one instance of the executable can be running in the OS. The command line message will be sent to the running process via SYS_COMMANDLINE event in script.
  • loadpackage="folder1,folder1,...": commar separated list of packages to load before bootstrapping. Such as loadpackage="npl_packages/paracraft/" npl_packages/main is always loaded by default.
  • i="true" whether to enter interactive interpreter mode. Default is false.

NPL System Module Params

The following params are handled by the NPL system module

  • debug="main" : Enable IPC debugging to the main NPL thread. No performance penalties.
  • resolution="1020 680": force window size in case of client application

Paracraft Module Params

The following params are handled by the Paracraft Package

  • world="worlds/DesignHouse/myworld" : Load a given world at start up.
  • mc="true": force paracraft (in case of running from MagicHaqi directory)
  • httpdebug="true": enable npl http debugger console on http://127.0.0.1:8099 on startup
  • usertoken="keepwork_user_token_string": this will automatically signin with the user token
  • IsTouchDevice="true": force touch device for debugging touch device on PC
  • isSchool="true": haqi games are disabled. url protocol are not installed.
  • mod="modName": we will load this mod in mod/modName folder。

Get command line arguments from NPL script

To get a given command line parameter use following.

-- for example, if you started npl process with `npl param1="abc"`, param1 will be filled with "abc"
local param1 = ParaEngine.GetAppCommandLineByParam("param1", "default_value");
echo(ParaEngine.GetAppCommandLineByParam("bootstrapper", ""))

One can also get the full command line string with following function.

local cmdline = ParaEngine.GetAppCommandLine();
echo(cmdline)

Working Directory

The working directory is the default root directory to read/write file. By default, NPLRuntime does not modify working directory of the executable, but with one exception.

If the executable folder or its parent folders contain a file called ParaEngine.sig (the file content does not matter), then NPLRuntime will reset working directory to the folder that contains ParaEngine.sig file.

Some NPL application like Paracraft's redist folder contains ParaEngine.sig file, which means that you can start the paracraft executable from any folder, but the working directory is always reset to the redist folder. This behavior affects the very first IO operation, including the default log position.

Default Command Line Params in ./config.txt

When NPL starts, it will load all command line parameters defined in a file called config.txt in the current working directory. Please note, the real command line parameters may override params specified in this file. This is a place to specify default parameters that are shared by all applications started in the working directory. This is true for both PC and mobile version.

config.txt looks like below. (Please note, this is a different file from config/config.txt)

cmdline=dev="" httpdebug="true" bootstrapper="script/apps/Aries/main_loop.lua"

Just specify command line paramters with cmdline= on the first line.

Clone this wiki locally