中文 | English

RocketDriver Pro

Logo

RocketDriver Pro is a game framework for Unity engine


9. Lua Interpreter

9.1 Library Description

9.1.1 Information Description

9.1.2 Modification Description

  1. Removed WinFrom related code logic.
  2. Function extension of LuaTable class.
  3. Added several functions related to LuaValue.
  4. Add Unity to use the packaging class Lua, which is also a common function entry.

9.2 Use

9.2.1 Execute Lua script in C#

  1. Call the Lua.RunLuaRaw function, or directly execute the Lua script. If there is a return value, get the return value.
    image
  2. Call the Lua.RunLua function to execute Lua scripts. And the wrapper class LuaResult is returned for the return value.
    image
  3. Call the Lua.IsTrue function to directly judge the Lua logical expression and obtain the resulting Boolean value.
    image

9.2.2 Call C# function in Lua

  1. First, the C# function needs to be registered in the Lua interpreter environment. We can use the Lua.RegisterFunction function to execute the registration logic.
    image
  2. In the Lua script, use the registered funcName to call the registered function.
  3. If the same funcName is used repeatedly for registration, it will be overwritten.
  4. Use the Lua.UnregisterFunction function to unregister the behavior.
    image

9.2.3 Restart Lua Interpreter

  1. Use the Lua.Restart function to reset the Lua interpreter, which will clear all contexts.
    image

9.3 Examples

JLGames/RocketDriver/Samples/LuaDemo
image