We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
如题,现在Room中的用于发动GameEvent的函数已经分了个mixin出来(并且注释中认为Room继承它),类似的也可以给askForXXX也分一个mixin出来。
我的看法是server/下新建一个文件夹,把network.lua(定义Request类的那个)放进来,再在里面定义多个文件放置各种askForXXX,文件组织或可比照requestHandler
network.lua
Request
和神杀一脉相承的使用参数超多的askForXXX,代价就是用起来也像神杀那样难受,为此最好作出修改;可是怎么改呢?如果Lua有python那种按名字传参就好了可惜没有,所以传表吧?
联想一下request用法:
local request = Request:new(command, {player}) request.accept_cancel = true request:setData(player, data) request:ask() return request.result[player.id]
可见只需要维护data就行了,那直接askForXXX(player, data)?
askForXXX(player, data)
又或者,手动创建Request并且填data,其实代码量比以前少好多了,但我需要插件给提示啊。。怎么办呢怎么让插件根据Command的不同而给出不同的setData提示呢。。。emmmmmmmmmmmmmmmmmmmmmm
The text was updated successfully, but these errors were encountered:
理论上吧,你真的可以学py那种按名字传参: function a(method, table) 需要什么参数直接事前在table[名字] = 参数就完事了 不过……这些东西终究还是“为了照顾modder而生”,毕竟大多数askForXXX真正做的就是在里面拼出那个要传给request的table……
Sorry, something went wrong.
No branches or pull requests
如题,现在Room中的用于发动GameEvent的函数已经分了个mixin出来(并且注释中认为Room继承它),类似的也可以给askForXXX也分一个mixin出来。
如何组织文件?
我的看法是server/下新建一个文件夹,把
network.lua
(定义Request
类的那个)放进来,再在里面定义多个文件放置各种askForXXX,文件组织或可比照requestHandler如何造出更好用的askForXXX?
和神杀一脉相承的使用参数超多的askForXXX,代价就是用起来也像神杀那样难受,为此最好作出修改;可是怎么改呢?如果Lua有python那种按名字传参就好了可惜没有,所以传表吧?
联想一下request用法:
可见只需要维护data就行了,那直接
askForXXX(player, data)
?又或者,手动创建Request并且填data,其实代码量比以前少好多了,但我需要插件给提示啊。。怎么办呢怎么让插件根据Command的不同而给出不同的setData提示呢。。。emmmmmmmmmmmmmmmmmmmmmm
The text was updated successfully, but these errors were encountered: