2023-07-24 05:11:58 +03:00
..
2023-07-22 23:59:21 +03:00
2023-07-24 05:11:58 +03:00

Providing Backward Compatibility for BeamMP Lua

KiuToi provides almost full support for lua plugins with BeamMP. All necessary methods have been created, and testing has revealed the following nuances:

KiuToi does not support: MP.Set()

Economic Rework V2.0 (Paid, Discord (RU): Hlebushek)

  1. To obtain pluginPath, use: debug.getinfo(1).source:gsub("\\","/") => debug.getinfo(1).source:gsub("\\","/"):gsub("@", "") as the path returns with @, which broke the plugin.

Cobalt Essentials V1.7.5 (Free, github)

  1. To obtain pluginPath, use: debug.getinfo(1).source:gsub("\\","/") => debug.getinfo(1).source:gsub("\\","/"):gsub("@", "") as the path returns with @, which broke the plugin.

A Little About How it Works

Plugin loading goes through several stages:

  1. The plugins/ folder is scanned.
  2. If the folder is not in PyPlugins and there are *.lua files in the folder, then it is added as a plugin folder, let's say it will be plugins/LuaPlugin
  3. Next, lua.loadfile({filename}) is performed from this folder (this is the standard method in lua).
  4. Finally, the onInit() function is called, and an event is triggered.
  5. If no errors occur during the execution of onInit(), you can see the message Lua plugins: LuaPlugin:ok through the lua_plugins command.