You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I must preface this by saying that I am new to modding and I have not written a Lua script before.
So, I wanted to make a mod that would connect game events and state to SteelSeries Game Engine. To be able to manipulate my keyboard lights, I have to send HTTP requests to the local server run by SteelSeries GG app.
I tried an example Lua code that seems to be working fine by itself when run with Lua.exe.
However, after I pack this mod with LSLib and import it with BG3MM, I can see that my script runs because the debug print line appears on BG3SE console, but then it throws this error:
Loading bootstrap script: Mods/SteelSeriesLights/ScriptExtender/Lua/BootstrapServer.lua
bg3se::ExtensionStateBase::LuaLoadGameFile(): Script file could not be opened: Mods/SteelSeriesLights/ScriptExtender/Lua/socket.http
bg3se::lua::State::LoadScript(): Failed to execute script: [string "SteelSeriesLights/Server/lights.lua"]:4: attempt to index a nil value (local 'http')
stack traceback:
SteelSeriesLights/Server/lights.lua:4: in main chunk
[C++ Code]: in field 'Include'
builtin://Libs/FileLoader.lua:34: in function <builtin://Libs/FileLoader.lua:6>
(...tail calls...)
SteelSeriesLights/BootstrapServer.lua:1: in main chunk
[C++ Code]: in field 'Include'
builtin://Libs/ModLoader.lua:68: in method 'LoadBootstrap'
builtin://BuiltinLibrary.lua:26: in function <builtin://BuiltinLibrary.lua:25>
Indications
BG3SE treats a default library (socket.http) as a custom mod script when calling LuaLoadGameFile: bg3se::ExtensionStateBase::LuaLoadGameFile()
Diagnostic Files
No response
Steps to Reproduce
Create a bootstrap script for the mod: Mods\SteelSeriesLights\ScriptExtender\Lua\BootstrapServer.lua
Create custom script that will be imported by BootstrapServer.lua:
localhttp=require("socket.http")
-- Perform the GET requestlocalresponse_body, status_code, response_headers=http.request("https://jsonplaceholder.typicode.com/todos/1")
-- Print the responseprint("Status Code:", status_code) -- Similar to `response.status`print("Response Body:", response_body) -- Similar to `response.text()`localfunctionparse_json(json_str)
localresult= {}
forkey, valueinjson_str:gmatch('"([^"]+)":%s*("?.-["}]?)%s*[,%}]') do-- Remove quotes from keys and values if presentkey=key:gsub('"', '')
ifvalue:match('^".*"$') thenvalue=value:sub(2, -2) -- Remove quotes for stringselseifvalue=="true" thenvalue=trueelseifvalue=="false" thenvalue=falseelseiftonumber(value) thenvalue=tonumber(value)
endresult[key] =valueendreturnresultend-- Parse the JSON responselocaldata=parse_json(response_body)
-- Access the parsed dataprint("Title:", data.title)
print("Completed:", data.completed)
Pack your mod with LSLib
Import mod with BG3MM
Load into the game and check BG3SE console for print statements
Expected Behavior
require should be able to import default libraries like socket.http
Actual Behavior
BG3SE tries to import socket.http as if it was another custom script within the same directory: Mods/SteelSeriesLights/ScriptExtender/Lua/socket.http
The text was updated successfully, but these errors were encountered:
I have attempted solutions to common problems
Yes
I have checked that my game version is supported
Yes
OS
Windows 10
Platform
Steam
Description
I must preface this by saying that I am new to modding and I have not written a Lua script before.
So, I wanted to make a mod that would connect game events and state to SteelSeries Game Engine. To be able to manipulate my keyboard lights, I have to send HTTP requests to the local server run by SteelSeries GG app.
I tried an example Lua code that seems to be working fine by itself when run with
Lua.exe
.However, after I pack this mod with LSLib and import it with BG3MM, I can see that my script runs because the debug print line appears on BG3SE console, but then it throws this error:
Indications
BG3SE treats a default library (socket.http) as a custom mod script when calling LuaLoadGameFile:
bg3se::ExtensionStateBase::LuaLoadGameFile()
Diagnostic Files
No response
Steps to Reproduce
Mods\SteelSeriesLights\ScriptExtender\Lua\BootstrapServer.lua
Expected Behavior
require
should be able to import default libraries likesocket.http
Actual Behavior
BG3SE tries to import
socket.http
as if it was another custom script within the same directory: Mods/SteelSeriesLights/ScriptExtender/Lua/socket.httpThe text was updated successfully, but these errors were encountered: