Skip to content
Li, Xizhi edited this page Mar 13, 2016 · 10 revisions

Hello World in NPL

This tutorial demonstrates

  • how to setup a simple development environment
  • write a program that output hello world
  • explains the basic concept behind the scene

This article is an aggregates of information you will find in this wiki guide. Skip this tutorial, if you have already read all related pages.

Setup Development Environment

For more information, see Install Guide.

git clone https://github.com/LiXizhi/ParaCraftSDK.git
  • Make sure you have updated to the latest version, by running ./redist/paracraft.exe at least once
  • Run ./NPLRuntime/install.bat
    • The NPL Runtime will be copied from ./redist folder to ./NPLRuntime/win/bin
    • The above path will be added to your %path% variable, so that you can run npl script from any folder.

To write NPL code, we recommend using either or both of following editors (and plugins):

Hello World Program

Run in command line npl helloworld.lua. The content of helloworld.lua is like this:

print("hello world");

If npl command is not found, make sure ./NPLRuntime/win/bin is added to your search %path%; or you can simply use the full path to run your script (see below).

__YourSDKPath__/NPLRuntime/win/bin/npl helloworld.lua

Behind the Scenes

ParacraftSDK's redist folder contains an installer of Paracraft. Running Paracraft.exe from redist directory will install the latest version of Paracraft, which ships with NPLRuntime. ./NPLRuntime/install.bat copies only NPL runtime related files from redist folder to ./NPLRuntime/win/bin and ./NPLRuntime/win/packages

./NPLRuntime/win/packages contains pre-compiled source code of NPL libraries.

To deploy your application, you need to deploy both bin and packages folders together with your own script and resource files, such as

./bin/       :npl runtime 32bits 
./bin64/     :npl runtime 64bits
./packages/  :npl precompiled source code
./script/    :your own script
./           :the working (root) directory of your application

In NPL script, you can reference any file using path relative to the working directory. So you need to make sure you start your app from the root directory.

Further Readings

ParacraftSDK contains many example projects written in NPL.

Clone this wiki locally