Working with Classes

From Frictional Wiki
< HPL3
Revision as of 19:14, 16 August 2020 by TiMan (talk | contribs)
Jump to navigation Jump to search

HPL3 Supports class usage

Icon tip.png Tip: As a general rule of thumb: Use HPL3 classes only when you cannot find what you are looking for in the helper files or the scripting api. They merely offer some extended functionality which may not be found in the helper files.

Example

Let's say you want to change the position of an entity through script. Usually, in order to perform something on entities, you would use a function that starts with Entity_. However, some things cannot be done through helper functions. The class iLuxEntity provides additional useful functionalities for entities. In order to retrieve a class object of an entity, you need to use Map_GetEntity:

void MoveEntityPosition()
{
	// Create a 3D Vector and save the position data into it
    // X: 55, Y: 5, Z: 25
	cVector3f positionData = cVector3f(55, 5, 25);
		
	iLuxEntity@ entity = Map_GetEntity("MyEntity"); // Get the iLuxEntity object of our entity in the map
	entity.SetPosition(positionData); // Set the new position of the entity
}

Every technical feature in HPL3 has a corresponding class to it (Lights, Billboards, Materials, GUI, etc), which makes scripting in HPL3 very flexible and allows you do modify anything through script.

See Also


Enums