zerobrane

project user.lua require statement only for project specific Modules


I have maintained my user.lua project folder specific. Is there anything in place where I can exclude Zerobrane's env path when I check a Module require statement with "Evaluate in Console"?

The reason for this is , i will ensure that everything is working within the plugin Engine himself.

This is what would be checked for a missing Module lualibs and bin is cerobrane specific, if I see it right

Output

local toast = require("toast")
[string "    local toast = require("toast")"]:1: module 'toast' not found:
    no field package.preload['toast']
    no file 'lualibs/toast.lua'
    no file 'lualibs/toast/toast.lua'
    no file 'lualibs/toast/init.lua'
    no file './toast.lua'
    no file '/usr/local/share/luajit-2.0.4/toast.lua'
    no file '/usr/local/share/lua/5.1/toast.lua'
    no file '/usr/local/share/lua/5.1/toast/init.lua'
    no file '/Volumes/SSD2go PKT/X-Plane 11 stable/Resources/plugins/FlyWithLua/Internals/toast.lua'
    no file '/Volumes/SSD2go PKT/X-Plane 11 stable/Resources/plugins/FlyWithLua/Internals/toast/init.lua'
    no file '/Volumes/SSD2go PKT/X-Plane 11 stable/Resources/plugins/FlyWithLua/Modules/toast.lua'
    no file '/Volumes/SSD2go PKT/X-Plane 11 stable/Resources/plugins/FlyWithLua/Modules/toast/init.lua'
    no file 'bin/clibs/libtoast.dylib'
    no file 'bin/clibs/toast.dylib'
    no file './toast.so'
    no file '/usr/local/lib/lua/5.1/toast.so'
    no file '/usr/local/lib/lua/5.1/loadall.so'
    no file '/Volumes/SSD2go PKT/X-Plane 11 stable/Resources/plugins/FlyWithLua/Internals/libtoast_64.so'

Here is my user.lua file at this time

--[[--
  Use this file to specify **User** preferences.
  Review [examples](+/Applications/ZeroBraneStudio.app/Contents/ZeroBraneStudio/cfg/user-sample.lua) or check [online documentation](http://studio.zerobrane.com/documentation.html) for details.
--]]--
--https://studio.zerobrane.com/doc-general-preferences#debugger

-- to automatically open files requested during debugging
editor.autoactivate = true

--enable verbose output
--debugger.verbose=true

--[[--
specify how print results should be redirected in the application being debugged (v0.39+). Use 'c' for ‘copying’ (appears in the application output and the Output panel), 'r' for ‘redirecting’ (only appears in the Output panel), or 'd' for ‘default’ (only appears in the application output). This is mostly useful for remote debugging to specify how the output should be redirected.
--]]--
debugger.redirect="c"

-- to force execution to continue immediately after starting debugging;
-- set to `false` to disable (the interpreter will stop on the first line or
-- when debugging starts); some interpreters may use `true` or `false`
-- by default, but can be still reconfigured with this setting.
debugger.runonstart = true

-- FlyWithLua.ini version 2.7.6 build 2018-10-24
-- Where to search for modules.

-- use this to evaluate your project folder , select the print function / right Mousebutton --> Evaluate in Console
--print(ide.filetree.projdir)

ZBSProjDir = "/Volumes/SSD2go PKT/X-Plane 11 stable/Resources/plugins/FlyWithLua"
INTERNALS_DIRECTORY = ZBSProjDir .. "/Internals/"
MODULES_DIRECTORY = ZBSProjDir .. "/Modules/"

package.path = table.concat({
    package.path,
    INTERNALS_DIRECTORY .. "?.lua",
    INTERNALS_DIRECTORY .. "?/init.lua",
    MODULES_DIRECTORY .. "?.lua",
    MODULES_DIRECTORY .. "?/init.lua",
}, ";")
package.cpath = table.concat({
    package.cpath,
    INTERNALS_DIRECTORY .. "?.ext",
    MODULES_DIRECTORY .. "?.ext",
}, ";")

-- Produce a correct name pattern for binary modules for OS and architecture.
-- This resolves clash between OS X and Linux binary modules by requiring "lib"
-- prefix for Linux ones.
local library_pattern = "?_64."

if SYSTEM == "IBM" then
    library_pattern = library_pattern .. "dll"
elseif SYSTEM == "APL" then
    library_pattern = library_pattern .. "so"
else
    library_pattern = "lib" .. library_pattern .. "so"
end

package.cpath = package.cpath:gsub("?.ext", library_pattern)

Version --> ZeroBrane Studio (1.90; MobDebug 0.706)

Greetings Lars


Solution

  • You should get the desired effect if toast module file is located in your project directory. When a command is executed in the Console, the current directory is set to the project directory, so even though lualibs folder from the IDE may be in the path, it should make no difference (unless you copied the module to lualibs).