Progetto H — Riferimento API Documentazione & Scripting
Funzione statica Condiviso Lento

Package.LoadFile

Compiles a .lua file and returns a function to run it. To be used for loading files in a sandboxed environment.<br/><br/>Supports the same searchers as <a href="#static-function-require">Package.Require</a>.

Non ancora tradotto

Sintassi

Lua
Package.LoadFile(file_path)

Parametri

Nome Tipo Predefinito Descrizione
file_path string Path to the script file to compile

Valore restituito

  • function the compiled function to run the script, allowing you to pass a environment env table for the script

Esempi

Loading a .lua file sandboxed
local func = Package.LoadFile("MyScript.lua"),,-- Only allows this file to access Console,local my_env = { Console = Console },,local content = func(my_env),,-- Access all global variables set by the script in my_env,my_env.GlobalVariableFromFile...