Coder Social home page Coder Social logo

Comments (13)

chexiongsheng avatar chexiongsheng commented on June 3, 2024

你为什么要放Resoures目录下呢,通过TextAsset直接引用的了。处理热更新的例子,全部例子都不用做任何事情,直接运行。
另外,你改了LuaBehaviour.cs?应该不会出现self为nil的情况呀?

from xlua.

lemon-li avatar lemon-li commented on June 3, 2024

你好,是这样的,我看到XLua教程.doc 文档开头说,DoString("require 'byfile'") ,更建议这种方式, 我尝试了一下。
我只修改了LuaBehaviour.cs那一行代码。然后移动lua文件到Resources目录里,与第7个例子,相同的目录结构。

from xlua.

chexiongsheng avatar chexiongsheng commented on June 3, 2024

你看看LuaBehaviour.cs,这几行都存在吗?
scriptEnv = luaEnv.NewTable();

    LuaTable meta = luaEnv.NewTable();
    meta.Set("__index", luaEnv.Global);
    scriptEnv.SetMetaTable(meta);
    meta.Dispose();

    scriptEnv.Set("self", this);

from xlua.

chexiongsheng avatar chexiongsheng commented on June 3, 2024

哦,我知道了
luaEnv.DoString(luaScript.text, "LuaBehaviour", scriptEnv);
没传scriptEnv参数

from xlua.

lemon-li avatar lemon-li commented on June 3, 2024

那几行代码都在的,我没有动其他代码,只换成了require方式。

from xlua.

chexiongsheng avatar chexiongsheng commented on June 3, 2024

要加后面两个参数
DoString("require 'byfile'","LuaBehaviour", scriptEnv )

from xlua.

chexiongsheng avatar chexiongsheng commented on June 3, 2024

scriptEnv不会自动设置给require的文件。。这个例子你不能通过require 方式,要require你得通过别的方式来传状态

from xlua.

lemon-li avatar lemon-li commented on June 3, 2024

DoString("require 'byfile'","LuaBehaviour", scriptEnv ) 我第一条留言里已经改过了。
恩,谢谢,我知道require的用法了。
有相关xlua的qq群吗?

from xlua.

chexiongsheng avatar chexiongsheng commented on June 3, 2024

QQ群暂时还没有,建群了通知你

from xlua.

lemon-li avatar lemon-li commented on June 3, 2024

好的,谢谢。

from xlua.

chexiongsheng avatar chexiongsheng commented on June 3, 2024

@lemon-li 刚建了QQ群:612705778

from xlua.

delguoqing avatar delguoqing commented on June 3, 2024

hi~方便问一下这个问题怎么解决么?
刚学lua,说得不对的话请见谅。

lua在加载一个新的模块的时候,其_ENV应该默认等于upvalue里面的_ENV。
那么在require一个模块的时候,这个模块的_ENV应该等于scriptEnv才对吧。
这算不算bug?

from xlua.

chexiongsheng avatar chexiongsheng commented on June 3, 2024

@delguoqing 算不算bug,你下载个原版的lua5.3试试就可以了,如果和原版的不一样,就是bug,否则不算。

from xlua.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.