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

DS架构下DS和客户端怎么同时使用LuaActor #199

Closed
pilaoda opened this issue Sep 11, 2019 · 5 comments
Closed

DS架构下DS和客户端怎么同时使用LuaActor #199

pilaoda opened this issue Sep 11, 2019 · 5 comments

Comments

@pilaoda
Copy link

pilaoda commented Sep 11, 2019

我在ds以及客户端各自的GameInstance中创建了动态的slua的LuaState之后,发现在LuaBas.h里面:
bool init(T* ptrT, const char* typeName, const FString& stateName, const FString& luaPath)
{
if (luaPath.IsEmpty())
return false;

auto ls = LuaState::get();
...

}

发现ls在编辑器下竟然会返回一个静态的虚拟机地址,导致客户端和ds共享lua虚拟机。这里要怎么改才能使用各自的LuaState啊?没有考虑到支持这种架构吗?

@pilaoda pilaoda changed the title DS架构下客户端怎么使用LuaActor区分服务器和客户端 DS架构下DS和客户端怎么使用LuaActor Sep 11, 2019
@pilaoda pilaoda changed the title DS架构下DS和客户端怎么使用LuaActor DS架构下DS和客户端怎么同时使用LuaActor Sep 11, 2019
@pangweiwei
Copy link
Collaborator

LuaState::get() 返回的是第一个创建的state,他可以加参数,参数包括index,或者name

比如

LuaState::get("client");

LuaState::get("ds);

@pangweiwei
Copy link
Collaborator

理论上,ds和client分别都只会在各自的gameinstance创建属于自己的state,LuaState::get()不会产生问题,如果你确实创建个2个state,直接get分不清楚,可以考虑命名。

@pilaoda
Copy link
Author

pilaoda commented Sep 16, 2019

理论上,ds和client分别都只会在各自的gameinstance创建属于自己的state,LuaState::get()不会产生问题,如果你确实创建个2个state,直接get分不清楚,可以考虑命名。

如果真机就不会有问题,但是编辑器开多玩家调试就会有问题,因为他们都是引用同一个静态变量。如果按你这样命名,多个client都叫client也分不清,他们也没办法提前知道自己该叫什么和别人区分开来。

@pangweiwei
Copy link
Collaborator

可以考虑从gameinstance拿到对应的luastate

@pangweiwei
Copy link
Collaborator

我增加了基于GameInstance来getLuaState的支持,这样可以区分多开的的LuaState实例。

hbqzq pushed a commit to hbqzq/sluaunreal that referenced this issue Sep 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants