-
-
Notifications
You must be signed in to change notification settings - Fork 10
RegisterClientScript
Jérôme Leclercq edited this page Dec 8, 2020
·
1 revision
API: RegisterClientScript
Registers a script file that will be downloaded and used client-side.
Calling this function is required for every client script.
If no parameter is set, this function registers the script file from where it's called.
RegisterClientScript([filepath: string])
-
filepath: Path to the script (relative to the scripts directory).
- All calls to RegisterClientScript should be done at initialization, before any player joins.
- Only server-registered scripts 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).
The server and map editor don't have this restriction. - This function exists client-side only for convenience and does nothing when called, as it's commonly called in shared element scripts.
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