Package com.avrix.lua

Class LuaManager

java.lang.Object
com.avrix.lua.LuaManager

public class LuaManager extends Object
Provides utility methods for managing Lua scripts.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    addBlockLua(String luaFileName)
    Adds a Lua file name to the blocked list.
    static void
    Adds the specified folder to the active Lua path.
    static Set<String>
    Retrieves the set of blocked Lua file names.
    static boolean
    isLuaBlocked(String luaFileName)
    Checks if a Lua file name is blocked by performing a partial match against the blocked Lua file names.
    static void
    loadLuaFromFolder(String folderPath, boolean rewriteEvents)
    Searches for Lua files recursively in the specified folder and its subfolders, adds them to the paths collection, and then runs each Lua file.
    static void
    runLua(String path, boolean rewriteEvents)
    Executes a Lua script located at the specified path.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • LuaManager

      public LuaManager()
  • Method Details

    • addBlockLua

      public static void addBlockLua(String luaFileName)
      Adds a Lua file name to the blocked list.
      Parameters:
      luaFileName - the full (or partial) name of the Lua file to be blocked
    • getBlockedLua

      public static Set<String> getBlockedLua()
      Retrieves the set of blocked Lua file names.
      Returns:
      a Set containing the names of blocked Lua files
    • isLuaBlocked

      public static boolean isLuaBlocked(String luaFileName)
      Checks if a Lua file name is blocked by performing a partial match against the blocked Lua file names.
      Parameters:
      luaFileName - the name of the Lua file to check
      Returns:
      true if a partial match is found in the blocked list, otherwise false
    • runLua

      public static void runLua(String path, boolean rewriteEvents)
      Executes a Lua script located at the specified path.
      Parameters:
      path - The path to the Lua script.
      rewriteEvents - Determines whether to rewrite events in the Lua script.
    • loadLuaFromFolder

      public static void loadLuaFromFolder(String folderPath, boolean rewriteEvents)
      Searches for Lua files recursively in the specified folder and its subfolders, adds them to the paths collection, and then runs each Lua file. After all files are loaded, fires the `OnLuaFilesLoaded` event
      Parameters:
      folderPath - The path to the folder containing Lua files.
      rewriteEvents - A boolean indicating whether to rewrite events.
    • addLuaActiveFolder

      public static void addLuaActiveFolder(File folder)
      Adds the specified folder to the active Lua path. Adding a folder will allow lua files to access other lua files inside the folder via 'require'
      Parameters:
      folder - the folder to add to the Lua path