-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: issue with missing
avant
object in Lua script
Added a pre-mount execution to ensure that the `avant` object is correctly initialized before the Lua code runs. This prevents errors related to the `avant` object not being found.
- Loading branch information
Showing
3 changed files
with
33 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,70 @@ | ||
package.path = "./lua/?.lua;" .. package.path | ||
require("log") | ||
local Log = require("Log") | ||
|
||
function OnMainInit(isHot) | ||
Log("OnMainInit isHot %s", tostring(isHot)); | ||
Log:Error("OnMainInit isHot %s", tostring(isHot)); | ||
end | ||
|
||
function OnMainStop(isHot) | ||
local log = "OnMainStop isHot " .. tostring(isHot); | ||
Log(log); | ||
Log:Error(log); | ||
end | ||
|
||
function OnMainTick() | ||
-- local log = "OnMainTick"; | ||
-- Log(log); | ||
-- Log:Error(Log.data); | ||
end | ||
|
||
function OnWorkerInit(workerIdx, isHot) | ||
local log = "OnWorkerInit workerIdx " .. workerIdx .. " isHot " .. | ||
tostring(isHot); | ||
Log(log) | ||
local log = "OnWorkerInit workerIdx " .. workerIdx .. " isHot " .. tostring(isHot); | ||
Log:Error(log) | ||
end | ||
|
||
function OnWorkerStop(workerIdx, isHot) | ||
local log = "OnWorkerStop" .. workerIdx .. " isHot " .. tostring(isHot); | ||
Log(log) | ||
Log:Error(log) | ||
end | ||
|
||
function OnWorkerTick(workerIdx) | ||
-- Log("OnWorkerTick " .. workerIdx) | ||
-- Log:Error("OnWorkerTick " .. workerIdx) | ||
-- local t = { | ||
-- ["num"] = 2, | ||
-- ["int32array"] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, | ||
-- ["data"] = {["str"] = "hello world"} | ||
-- }; | ||
-- local res = avant.Lua2Protobuf(t, 8); | ||
-- if res == nil then | ||
-- Log("avant.Lua2Protobuf res nil " .. workerIdx); | ||
-- Log:Error("avant.Lua2Protobuf res nil " .. workerIdx); | ||
-- else | ||
-- Log("avant.Lua2Protobuf res " .. workerIdx .. " " .. res); | ||
-- Log:Error("avant.Lua2Protobuf res " .. workerIdx .. " " .. res); | ||
-- end | ||
end | ||
|
||
function OnWorkerRecvMessage(workerIdx, cmd, message) | ||
Log("avant.OnWorkerRecvMessage " .. workerIdx .. " " .. cmd .. " "); | ||
Log:Error("avant.OnWorkerRecvMessage " .. workerIdx .. " " .. cmd .. " "); | ||
if cmd == 8 then | ||
local num = message["num"]; | ||
local int32array = message["int32array"]; | ||
local int32array_str = table.concat(int32array, " ") | ||
local data = message["data"]; | ||
local data_str = data["str"]; | ||
Log("avant.OnWorkerRecvMessage num " .. num .. " " .. "int32array " .. | ||
int32array_str .. " " .. data_str); | ||
Log:Error("avant.OnWorkerRecvMessage num " .. num .. " " .. "int32array " .. int32array_str .. " " .. data_str); | ||
else | ||
Log("avant.OnWorkerRecvMessage cmd != 8"); | ||
Log:Error("avant.OnWorkerRecvMessage cmd != 8"); | ||
end | ||
end | ||
|
||
function OnOtherInit(isHot) | ||
local log = "OnOtherInit isHot " .. tostring(isHot); | ||
Log(log); | ||
Log:Error(log); | ||
end | ||
|
||
function OnOtherStop(isHot) | ||
local log = "OnOtherStop isHot " .. tostring(isHot); | ||
Log(log); | ||
Log:Error(log); | ||
end | ||
|
||
function OnOtherTick() | ||
-- local log = "OnOtherTick"; | ||
-- Log(log) | ||
-- Log:Error(log) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters