Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Although the example you provided last time can be debugged. But I still can't debug it myself. #10

Open
brinkqiang opened this issue Mar 24, 2021 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@brinkqiang
Copy link

brinkqiang commented Mar 24, 2021

Case address: https://github.com/brinkqiang/dmlua

This example is more complicated and should be able to cover many usage conditions. If this example can be debugged, many examples will be debugged.

More special points.

  1. Directory problem, the debug directory structure is as follows.
    path

The compiled exe is in the Debug directory, and the script is loaded as the upper-level directory of the exe.

  1. Calling method
    The calling method in C++ is as follows.
    CRole* poRole = CRoleMgr::Instance()->CreateRole();
    poRole->SetName("andy");
    poRole->SetHp(9999);
    poRole->SetMp(9999);
    unsigned int dwTaskID = 100;
    LResultINT oResult(-1);
    oDMLuaEngine.Call("script.task.task.AcceptTask", poRole, dwTaskID, &oResult);

  2. seeall
    The seeall attribute is set in the script. I don't know if it will affect it.

module (..., package.seeall)

dmlua_debug

Your help is very much needed.

@brinkqiang
Copy link
Author

-- lua script
module (..., package.seeall)

function AcceptTask(role, taskid, ret)
print("==================================")
print("Player Name = " .. role:GetName())
print("PlayerID = " .. role:GetObjID())
print("AcceptTask taskid = " .. taskid)

if role:AcceptTask(taskid) then
    ret.value = 0
	print("AcceptTask ret = " .. math.ceil(ret.value))
else
    ret.value = -1
	print("AcceptTask ret = " .. math.ceil(ret.value))
end

print("###################################")

end

function FinishTask(role, taskid)
print("==================================")
print("Player Name = " .. role:GetName())
print("FinishTask taskid = " .. taskid)
print("==================================")
role:FinishTask(taskid)
end

@WheretIB
Copy link
Owner

I will try to debug your example project to find the issue.

@WheretIB WheretIB self-assigned this Mar 24, 2021
@WheretIB WheretIB added the bug Something isn't working label Mar 24, 2021
@WheretIB
Copy link
Owner

WheretIB commented Apr 6, 2021

I've improved file path search in the extension, but script names in your application (for example, .\script\task\task.lua) cannot be found relative the the executable (in .\bin\Debug) or relative to the launch working directory (.\build)

In the upcoming v0.9.6 update, you can use 'Show Script list' menu item to see the issue:
image

You should add lua_dkm_debug.json file with additional search path, for example:

{
  "ScriptPaths": [
    "../bin/"
  ]
}

The debugger will then be able to link scripts to files:
image

@brinkqiang
Copy link
Author

brinkqiang commented Apr 9, 2021

Hello, the problem has been solved. Thank you very much.

I still have a small question here. Can this be customized globally for the search path? Just don’t use each Each project is to set the way to retrieve the path.

In addition, if the plug-in can obtain the search path of Lua, wouldn't it be more convenient. Because as long as it can be compiled and run, the Lua file can definitely be retrieved. Of course, I may not know the details of the implementation. It is for reference only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants