6 Long Street, Bree-land Homesteads, Landroval, open to all
Posts
2,641
Getting Started with Visual Studio and LOTRO UI Plugins
Greetings!
I haven't seen any unified guide/tutorial for Lua scripting of LOTRO Plugins within Visual Studio. Scripting by definition doesn't need an IDE (integrated development environment) like Visual Studio, but it's certain nice for large scripting projects for error checking and syntax highlighting.
So I decided to try it myself and then post what I discovered to help others in getting started. I haven't created a single plugin (yet), as I'm just starting out and learning the preferred and/or required structure. I'm using Visual Studio 2008 for this tutorial, but this should work in Visual Studio 2010 as well. Before we begin, grab these downloads...
Download and install Lua for Visual Studio from the link above (for both VS 2008 and 2010). This will enable syntax highlighting and error checking for Lua.
.
Download and extract the example Visual Studio solution (created in VS 2008).
.
Double click on the "LOTROAddon.sln" solution file from within the extracted "LOTROAddon" folder. Now you're ready to start scripting!
--=[ Notes ]=--
Creating a plugin for LOTRO's UI is fairly simple, but getting started requires a little example browsing/running, experimentation, and reference of the API Turbine released. For programmers this may come fairly easily. For others it may be an uphill battle. The best advice I can give for new authors here is to first understand how the examples that Turbine provided work.
Once you make your first window you'll get the hang of things. I highly recommend using Turbine's UI.Extensions.Window and Utils.Class in your projects so you won't have to 'reinvent the wheel'. These are included with the LOTRO plugins example from the links above.
.
The __init__.lua file is used to help minimize the number of imports from a package. It's not necessary, but it is very helpful for larger projects with possibly dozens or hundreds of individual lua files to import to another package (thanks to Kryso for this information).
.
Images used in UI mods are all added to a folder named "Resources" in Turbine's example. I'm not sure if this is necessary, but it's a good recommendation to help you keep images separate from script files.
.
All images are in an extremely old, but widely-used Truevision TGA (aka: Targa) format. Many game developers use this format due to its good compression for simple images, small memory footprint to parse, and well-know use in DirectX textures. You'll need image editing software to work with these files such as Adobe Photoshop, GIMP, or Paint.Net.
.
All plugins for LOTRO's UI need to be copied to the Plugin director of the LOTRO user folder. Create this folder:
%USERPROFILE%\My Documents\The Lord of the Rings Online\Plugins
At the bare minimum a plugin needs an XML file with the ".plugin" extension to point to your first script file, a lua script file, the import calls within that lua file, and something to do. Example tree of a simple plugin...
Code:
The Lord of the Rings Online\Plugins
\MyPluginParentFolder
MyPlugin.plugin
\MyPlugin
__init__.lua
Main.lua
(...)
\Resources
MyImage.tga
(...)
Keep this in mind when using the files inside of Visual Studio. I preserved this structure for the solution file, but when making your plugin public, be sure not to include the two solution files, the project file, and the bin and obj folder.
.
This is intended to jump start programmers familiar with Visual Studio but not familiar with the structure of a simple LOTRO plugin. And certainly there's nothing wrong with using a simple text file editor like Notepad++ to edit lua script files for smaller plugin projects. I often skip VS and use regular text editors with some syntax highlighting for smaller projects.
Please let me know if you find any errors or oversights. I'm new to LOTRO UI plugin scripting myself, so I might have something wrong. Also, I'd love to throw in a simple "hello world" code sample (like a window with a label "hello world) right in the Main.lua file of this plugin project. If you'd like to write one, please add it to this thread and I'll include it. I'd prefer to avoid using the Turbine Extended and Util from the example plugins so that it's all self-contained in one script file.
Thanks!
Last edited by cipher_nemo; Oct 15 2010 at 09:50 AM.
┌──────────────────────────────────────────────────────────────────────────────────┐
│ Crimson Vanguard successor on Landroval .............................. ..........│
├──────────────────────────────────────────────────────────────────────────────────┤
│ Cipheron: .60 Lore-master, SM Historian . Ciphel: ......21 Minstrel, Explorer ...│
│ Ciphariel: 53 Champion, SM Explorer ..... Ciphoin: .....21 Runekeeper, Historian │
│ Ciph: .....44 Captain, Woodsman ......... Extrabank: ...02 (mule) ...............│
│ Ciphorin: .24 Guardian, Armourer ........ Extrastorage: 02 (mule) ...............│
│ Ciphara: ..23 Burglar, SM Tinker .............................. .................│
│..................................................................................│
│▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓│
└──────────────────────────────────────────────────────────────────────────────────┘
Re: Getting Started with Visual Studio and LOTRO UI Plugins
oh thanks thanks thanks!! i'm gonna use this files right now.
I'm having a problem that i can't fix and maybe there's the solution, if anyones knows can help too.
I have one window with a button, this button opens a Window:Constructor(), then if i click on the X to close the second window, the button on the first window don't work anymore.
After a Window:Closing() event i can't re-open that window, i mean i can't find any code like Window:OpenAgain() so i need to reload the plugin all the time.
Re: Getting Started with Visual Studio and LOTRO UI Plugins
Originally Posted by cipher_nemo
[*]All projects seem to have a __init__.lua file that points to your own plugin Lua file. I'm not sure if this is required, but it's in all of Turbine's examples, so I have included it in the VS solution.
__init__.lua is not neccessary - it is used for importing packages
And that is just silly.. in larger projects you could have longer import list than actual code
Lets try to put __init__.lua into every folder. It's content should be all files we want to import when importing that package. So for example content of Irien\Core\__init__lua would look like this:
6 Long Street, Bree-land Homesteads, Landroval, open to all
Posts
2,641
Re: Getting Started with Visual Studio and LOTRO UI Plugins
Originally Posted by Saelyth
oh thanks thanks thanks!! i'm gonna use this files right now.
I'm having a problem that i can't fix and maybe there's the solution, if anyones knows can help too.
No problem. And not sure about your plugin issue as I just started toying around with the LOTRO UI Plugins myself.
Originally Posted by kbw
Do you know if this will work in any of the VS Express editions?
I assume it would since it's a very, very simple solution with no advanced functions exclusive to the VS Pro line. But I'm not sure, never tried it.
I would check to see if the Lua for Visual Studio installer works with Express first. If it doesn't, then I would just use text editors like Notepad++ or a Lua IDE to work on Lua files.
Originally Posted by Kryso
__init__.lua is not neccessary - it is used for importing packages (...) and it will import all classes This behavior is taken from Python iirc.
Thanks! I'll update the OP.
┌──────────────────────────────────────────────────────────────────────────────────┐
│ Crimson Vanguard successor on Landroval .............................. ..........│
├──────────────────────────────────────────────────────────────────────────────────┤
│ Cipheron: .60 Lore-master, SM Historian . Ciphel: ......21 Minstrel, Explorer ...│
│ Ciphariel: 53 Champion, SM Explorer ..... Ciphoin: .....21 Runekeeper, Historian │
│ Ciph: .....44 Captain, Woodsman ......... Extrabank: ...02 (mule) ...............│
│ Ciphorin: .24 Guardian, Armourer ........ Extrastorage: 02 (mule) ...............│
│ Ciphara: ..23 Burglar, SM Tinker .............................. .................│
│..................................................................................│
│▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓│
└──────────────────────────────────────────────────────────────────────────────────┘
6 Long Street, Bree-land Homesteads, Landroval, open to all
Posts
2,641
Re: Getting Started with Visual Studio and LOTRO UI Plugins
Originally Posted by Calorion
@cipher_nemo: Any chance you could release a Visual Studio 2010 version? It tries to convert, but I don't know that it's working well.
It should convert fine for Visual Studio 2010. The project file itself is very simple and the Lua for Visual Studio plugin I linked to will work with VS 2010 as well. I don't use VS 2010, so I have no way of trying it myself, sorry.
On another note, I have been toying around with LuaEdit, a separate IDE for just Lua. But it's awkward and not nearly as feature-rich as Visual Studio.
┌──────────────────────────────────────────────────────────────────────────────────┐
│ Crimson Vanguard successor on Landroval .............................. ..........│
├──────────────────────────────────────────────────────────────────────────────────┤
│ Cipheron: .60 Lore-master, SM Historian . Ciphel: ......21 Minstrel, Explorer ...│
│ Ciphariel: 53 Champion, SM Explorer ..... Ciphoin: .....21 Runekeeper, Historian │
│ Ciph: .....44 Captain, Woodsman ......... Extrabank: ...02 (mule) ...............│
│ Ciphorin: .24 Guardian, Armourer ........ Extrastorage: 02 (mule) ...............│
│ Ciphara: ..23 Burglar, SM Tinker .............................. .................│
│..................................................................................│
│▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓│
└──────────────────────────────────────────────────────────────────────────────────┘
Re: Getting Started with Visual Studio and LOTRO UI Plugins
Originally Posted by cipher_nemo
Greetings!
I haven't seen any unified guide/tutorial for Lua scripting of LOTRO Plugins within Visual Studio. Scripting by definition doesn't need an IDE (integrated development environment) like Visual Studio, but it's certain nice for large scripting projects for error checking and syntax highlighting.
I downloaded and installed the VS Support installer and ran it with out errors. I use VS 2010 Pro via DreamSpark and get no plugin support after installing it. I have no syntax highlighting or error checking. When I open a LUA document it looks like a plain text file in VS.
I made sure in my installed programs list in Control Panel I had no mentions of VS Express. I reinstalled the LUA addon just in case. Opened the example project, Added References for Irony.dll, LuaGrammer.dll and LuaLanguage.dll. No syntax highlighting, no error reporting, no Intellisense.
In the VS Addon re-install I tried the Change, Repair, uninstall (with an new re-install after) and still no joy.
Any advice on how to fix this would be welcome.
(Note: I noticed in the VS Addon install it said "associate with VS 2008." This a problem?)
Re: Getting Started with Visual Studio and LOTRO UI Plugins
Did somebody try developing plugins with LuaEclipse, i.e. a Lua plugin for Eclipse? While this is nice I doubt that many people will spend lots of money (in Germany it's about 1000 $) on Visual Studio 2010 professional.
"Into the night
Soon he disappears
And in the back the attack of the black riders start" - Frodo's Dream, Van Canto
6 Long Street, Bree-land Homesteads, Landroval, open to all
Posts
2,641
Re: Getting Started with Visual Studio and LOTRO UI Plugins
Originally Posted by Adalas
Did somebody try developing plugins with LuaEclipse, i.e. a Lua plugin for Eclipse? While this is nice I doubt that many people will spend lots of money (in Germany it's about 1000 $) on Visual Studio 2010 professional.
I get Visual Studio 2008 with my job, so it doesn't cost a penny for me. Many developers in the US have Visual Studio, as there is no good comparison between Eclipse and VS. Eclipse can't handle .NET (due to restrictive licensing of Microsoft), but more importantly of all, both IDEs are going to be intuitive to one group of developers and completely awkward and frustrating to another.
Just try to open an existing project in each IDE and you'll see what I mean. Eclipse is very powerful, but for even simple tasks it's like using an grenade to kill an ant. In comparison, VS would probably hover somewhere between sledgehammer and hammer on that ant.
┌──────────────────────────────────────────────────────────────────────────────────┐
│ Crimson Vanguard successor on Landroval .............................. ..........│
├──────────────────────────────────────────────────────────────────────────────────┤
│ Cipheron: .60 Lore-master, SM Historian . Ciphel: ......21 Minstrel, Explorer ...│
│ Ciphariel: 53 Champion, SM Explorer ..... Ciphoin: .....21 Runekeeper, Historian │
│ Ciph: .....44 Captain, Woodsman ......... Extrabank: ...02 (mule) ...............│
│ Ciphorin: .24 Guardian, Armourer ........ Extrastorage: 02 (mule) ...............│
│ Ciphara: ..23 Burglar, SM Tinker .............................. .................│
│..................................................................................│
│▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓│
└──────────────────────────────────────────────────────────────────────────────────┘
Re: Getting Started with Visual Studio and LOTRO UI Plugins
Originally Posted by cipher_nemo
It should convert fine for Visual Studio 2010. The project file itself is very simple and the Lua for Visual Studio plugin I linked to will work with VS 2010 as well. I don't use VS 2010, so I have no way of trying it myself, sorry.
Yeah, it converted fine; I just hadn't installed the C# module, so it didn't' work before. Fixed now. Now waiting on a "Hello World" code example to be included in the project.
Re: Getting Started with Visual Studio and LOTRO UI Plugins
Cipher:
Thanks again for this; I'm just now getting around to actually using it. I have a couple of questions:
1) Do you know of a good quickstart guide to Visual Studio (2010)?
2) In your example, Main.lua says, in part, 'import "Turbine.Gameplay";'. There is no such file or folder. Is this legacy from beta (or pre-November)? Or does it serve some function of which I'm unaware?
Re: Getting Started with Visual Studio and LOTRO UI Plugins
I don't want to pester you with Visual Studio question, but I do have one:
How do I change the MyAddOn folder name? I can't see how to do it from within Visual Studio, and if I try to do it in Windows Explorer, Visual Studio complains it can no longer find it.