Skip to content
Jérôme Leclercq edited this page Dec 8, 2020 · 2 revisions

API: include

Description:

Loads and execute a file from its path.

An error occurring during loading will trigger an error in the script executing include.

Prototype:

include(path: string)

Parameters:

  1. asset: Path to the file (relative to the current file).

Remarks:

  1. Only scripts registered using RegisterClientScript server-side can be included client-side. If a client script tries to include a non-registered script file it will not be found by the game (independently of the file existence on the dive).

Example code

A simple shared.lua entity using a custom asset

-- Registers the script client-side
RegisterClientScript()
-- Registers box.png as a client-side asset
RegisterClientAssets("box.png")

if (CLIENT) then
	entity:On("init", function (self)
		self:AddSprite({
			-- Using the asset
			TexturePath = "box.png"
		})
	end)
end
Clone this wiki locally