Now learn to sell Intellij+emmylua development and debugging unity in Xlua

Source: Internet
Author: User
Tags lua





Sun Guangdong 2017.8.23



http://blog.csdn.NET/u010019717






Recommend this country to make the plug-in Emmylua based on the IntelliJ IDE. His QQ group: 29850775






Github:https://github.com/tangzx/intellij-emmylua



Oschina:http://git.oschina.net/tangzx/intellij-lua



Idea Plugins:https://plugins.jetbrains.com/plugin/9768-emmylua



Documents: https://tangzx.github.io/emmydoc/









You may have an error while running: program [Lua.exe] is not found.  What to do.  The shortcomings of the plugin do not have a built-in LUA environment and need to be installed themselves, such as the Lua for window.  You want the plug-in to be built into the environment later.   According to the author's reply to consider the volume of the larger "at least two platforms 32 64, plus the Luasocket module, but also to consider platform and version problems" built-in is impossible. Transmission door:



Way one, Lua for Windows downloads (compared to the source code will be a bit behind the version)



Https://github.com/rjpcomputing/luaforwindows/releases



And with the editor SciTE,



At the same time, tools help us Configure the environment variables (Plug-ins are found through this environment variable Lua.exe)



Mode two, download bin file http://luabinaries.sourceforge.net/download.html,




Unzip to the location where the software is installed, and then configure the environment variables. (Note that Lua.exe is a copy of my lua53.exe and then renamed)












First, install the plugin. Note that there is a requirement for idea version not to be less than 2017.1



Theoretically, if you install any one of the products, as long as the version is high enough, you can install the plugin



"IntelliJ idea, Phpstorm, Webstorm, Pycharm, RubyMine, Appcode, Clion, Gogland, Datagrip, Rider, Android Studio"






Take Rider 2017.1.1 as an example (but it is still recommended to use idea, otherwise you may not be able to create a LUA project)



File-> Settings and then




You can download the plugin locally and choose to install it from disk, or you can search for the installation within the Idea tool (I am this).






Then on the right click on the Install installation, restart on the line.






Note:  There may be problems with downloading , which is related to the use of network operators. Only another way to install ...






When you restart, create a new project (or open the folder that contains the project selection Lua file). )







In the SRC directory, create a new Main.lua file, enter



Print ("Test main")



Run, normal output, do not complain on OK!



Try the debug mode to run, and setting breakpoints is normal.















To import the Unity project into the line:



Idea in the File-> New-> Module from Existing Sources Select the Unity Project assets on the line.









How do you debug the LUA code in your project?



File-> Project Structure (this source itself can be added multiple.) )










The problem I'm having is setting up Sources Root, for example, I'm going to debug the LuaTestScript.lua.txt script for the Xlua project.



Solution for administrators in a group: "Root is the root directory of the LUA files accessed in your code,"



For example, your code is ' Test/1.lua ' in the Src/lua/test/1.lua inside your code, and your LUA directory is root. What does this visit mean in Xlua?



For example, the second parameter of luaenv.dostring in the following LuaBehaviour.cs.










Try Attachto pid:39556 with x64 debugger.



Found allnecessary Lua functions [M:xlua.dll, v:530]



debuggerattached to process.



Attachfinish.



[✘] File not Found:init



[✘] File not Found:luabehaviour






Hint that these two things were not found.



There is an error in the instance code, and LuaBehaviour.cs the second parameter of luaenv.dostring to LuaTestScript.lua.txt can be found. That Init didn't know what it was.



Try attach to pid:39556 with x64 debugger.



Found all necessary Lua functions [M:xlua.dll, v:530]



Debugger attached to process.



Attach finish.



[✘] File not Found:init



[√] File was loaded:LuaTestScript.lua.txt






VS within the global search "Init", Lua is as a string in CS, is the LuaEnv.cs file.   Change the parameter to "LuaEnv.cs" in his Xlua\src folder, to add this source. The result is not good.



"If the LUA code is not a separate file, but a string in CS can be debugged by breakpoints."    "The answer is that the follow-up may be supported, and now is not possible."  But without affecting normal debugging, the Lua script you want to debug is loaded properly. Whatever it is.


















Xlua The default Lua file name is . Lua.txt is actually a. txt How to make this idea associate . txt to Emmy Lua Insert on the piece.















Code hints Ignore case:












His code hints how to do it .



The so-called annotation. The Emmylua annotation feature is simply a helper editor code hint and other features that have nothing to do with the actual running logic of the LUA code, as they are ordinary LUA annotations.





Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.