mirror of
https://github.com/KoboldAI/KoboldAI-Client.git
synced 2025-06-05 21:59:24 +02:00
Use local variables as much as possible in bridge.lua
This commit is contained in:
10
bridge.lua
10
bridge.lua
@@ -42,7 +42,7 @@ return function(_python, _bridged)
|
|||||||
|
|
||||||
---@param path string
|
---@param path string
|
||||||
---@return nil
|
---@return nil
|
||||||
function set_require_path(path)
|
local function set_require_path(path)
|
||||||
local config = {}
|
local config = {}
|
||||||
local i = 1
|
local i = 1
|
||||||
for substring in string.gmatch(package.config, "[^\n]+") do
|
for substring in string.gmatch(package.config, "[^\n]+") do
|
||||||
@@ -56,7 +56,7 @@ return function(_python, _bridged)
|
|||||||
---@param path string
|
---@param path string
|
||||||
---@param filename string
|
---@param filename string
|
||||||
---@return string
|
---@return string
|
||||||
function join_folder_and_filename(path, filename)
|
local function join_folder_and_filename(path, filename)
|
||||||
return path .. string.match(package.config, "[^\n]+") .. filename
|
return path .. string.match(package.config, "[^\n]+") .. filename
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -67,7 +67,7 @@ return function(_python, _bridged)
|
|||||||
|
|
||||||
local bridged = {}
|
local bridged = {}
|
||||||
for k in _python.iter(_bridged) do
|
for k in _python.iter(_bridged) do
|
||||||
v = _bridged[k]
|
local v = _bridged[k]
|
||||||
bridged[k] = type(v) == "userdata" and _python.as_attrgetter(v) or v
|
bridged[k] = type(v) == "userdata" and _python.as_attrgetter(v) or v
|
||||||
end
|
end
|
||||||
set_require_path(bridged.lib_path)
|
set_require_path(bridged.lib_path)
|
||||||
@@ -766,7 +766,7 @@ return function(_python, _bridged)
|
|||||||
local actions = koboldbridge.userstate == "genmod" and bridged.vars._actions or bridged.vars.actions
|
local actions = koboldbridge.userstate == "genmod" and bridged.vars._actions or bridged.vars.actions
|
||||||
local nxt, iterator = _python.iter(actions)
|
local nxt, iterator = _python.iter(actions)
|
||||||
local run_once = false
|
local run_once = false
|
||||||
local f = function()
|
local function f()
|
||||||
if not bridged.vars.gamestarted then
|
if not bridged.vars.gamestarted then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@@ -794,7 +794,7 @@ return function(_python, _bridged)
|
|||||||
local actions = koboldbridge.userstate == "genmod" and bridged.vars._actions or bridged.vars.actions
|
local actions = koboldbridge.userstate == "genmod" and bridged.vars._actions or bridged.vars.actions
|
||||||
local nxt, iterator = _python.iter(_python.builtins.reversed(actions))
|
local nxt, iterator = _python.iter(_python.builtins.reversed(actions))
|
||||||
local last_run = false
|
local last_run = false
|
||||||
local f = function()
|
local function f()
|
||||||
if not bridged.vars.gamestarted or last_run then
|
if not bridged.vars.gamestarted or last_run then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user