GE Lua Documentation

Press F to search!

require_optional

Definition


-- @/lua/common/luaCore.lua:8
-- This Source Code Form is subject to the terms of the bCDDL, v. 1.1.
-- If a copy of the bCDDL was not distributed with this
-- file, You can obtain one at http://beamng.com/bCDDL-1.1.txt

-- this file adds core language features we use everywhere

-- this function can load an optional module
function require_optional(module)
  local ok, m = pcall(require, module)
  if ok then return m end
  return nil
end

Callers

@/lua/ge/extensions/core/remoteController.lua

local ffi = require_optional('ffi')
if ffi then
@/lua/common/jbeam/loader.lua
local jbeamMirrors = require('jbeam/sections/mirror')
local jbeamPartColors =  require_optional('jbeam/sections/partColors') or { process=nop }
local jbeamCondition = require_optional('jbeam/sections/condition') or { process=nop }
local jbeamPartColors =  require_optional('jbeam/sections/partColors') or { process=nop }
local jbeamCondition = require_optional('jbeam/sections/condition') or { process=nop }
local jbeamMaterials = require('jbeam/materials')
@/lua/common/luaCore.lua
-- use luajit extension table.clear and new if they exist, otherwise fallback to lua implementations
ffi = require_optional('ffi') -- this sets the global ffi variable