Version

Python

When writing a Python program the API must be imported by import harfang as hg before it can be accessed.

Accessing global symbols

Global symbols are defined in the API root object hg and can be directly accessed from there. Here is an example on how to create a new object of Vector3 type in Python...

import harfang as hg
v = hg.Vector3()  # v now holds a Vector3 object

Accessing a symbol defined in a class

Symbols defined in a class are accessible through the class object itself. Here is an example on how to access the LightModel enumeration in Python...

l = hg.Light()
l.SetModel(hg.LightModelSpot)  # set the light component model to spot

Lua

The API is imported to Lua programs via hg = require("harfang")

Accessing global symbols

hg = require("harfang")
v = hg.Vector3() -- v now holds a Vector3 object

Accessing a symbol defined in a class

hg = require("harfang")
l = hg.Light()
l:SetModel(hg.LightModelSpot) -- set the light component model to spot