LoTROInterface

LoTROInterface (https://www.lotrointerface.com/forums/index.php)
-   Lua Programming Help (L) (https://www.lotrointerface.com/forums/forumdisplay.php?f=50)
-   -   Starters guide to lua and lotro? (https://www.lotrointerface.com/forums/showthread.php?t=1658)

martin93 10-20-2011 08:37 AM

Starters guide to lua and lotro?
 
So I really want to get into making plugins, I have some great ideas that I'd like to implement as a plugin.

I have Visual Studio 2010 for free since I'm a student. I was excited to find this guide that uses Visual Studio. However, the links for the last 3 downloads are broken. I'm wondering and hoping you guys know of another guide I could use, or if the downloads are available somewhere else.

P.S. - I'm familiar with Visual Basic and am mid way through my first C++ class. Which language is LUA more like?

Thanks in advance! Kudos to all the devs here. You do amazing work. :rolleyes:

Gumble 10-20-2011 10:19 AM

From the extremely small amount of fiddling I've done with LUA plugins for the game (wrote an extremely basic context-sensitive quickslot bar during one of the first LUA betas) it's closer to C++ syntactically. I'm a VB.NET web dev myself, and if you're comfortable with Javascript or curly-braces in general and basic OOP design, LUA's not too difficult. I'd recommend taking a look at the source for some existing plugins and some of the wrapper/extension classes that others have made available here and on the Lotro forums (things for Ctrl-\ window positioning and the like).

Start with something basic. Just creating a windowless "listener" class that will listen for certain events (entering combat, leaving combat, dying, etc) and output some text to the chat window would be a good start. Once you're comfy with hooking into the event API you can then start playing with quickslots, equipment, and new UI elements a little more comfortably.

Good luck, and happy developing!

Hopefully some others can provide much more in-depth and sagely advice than I ;)

Garan 10-20-2011 10:21 AM

Those last three links were to beta samples that are no longer valid. The current Turbine samples can be found at: http://content.turbine.com/sites/lot..._LuaPlugins.7z
note that they are in a 7z compressed archive. You can download a free unzip program from http://www.7-zip.org/

The latest Turbine API documentation is on LoTROInterface at:
http://www.lotrointerface.com/downlo...mentation.html

As to the language, it is a scripting language, much like VBScript. The language guide I used to learn Lua comes from lua.org http://www.lua.org/manual/5.1/

One of the biggest pitfalls for inexperienced developers is depending too much on the Turbine samples. Those plugins should be treated strickly as a starting point, not as a required foundation - if you use any of the source files from the samples such as class.lua, create a copy and include it in your own project, don't just reference it from the Turbine folder. That way you won't have any issues if the person who wants to use your finished project either doesn't have the Turbine samples or has a different version (they changed in some significant ways from beta and original live versions to the current versions).

As with many other languages, the best way to learn Lua is to take a simple working sample and dissect it. Learn how objects are created and how to manipulate them to do what you want. Once you are comfortable playing with existing plugins, you should really read as much of the http://forums.lotro.com/forumdisplay...amp-Discussion forum as possible as this is where authors have documented issues that they have spent time (in some cases many hours) exploring as well as some interesting and useful undocumented features such as missing enumeration values, undocumented fonts, and undocumented methods such as my favorite, the elusive but incredibly useful :SetStretchMode() method.

As to tools, there's nothing wrong with using Visual Studio, but it's a bit like using a hand grenade to kill a mosquito. Notepad and Paint.Net will suffice. No complex tools are really needed. I have found that in-game debugging can be useful at times so I developed my debug.lua class that can be added to plugins and when displayed will allow you to interactively examine all of the objects and values (a good way to find those previously mentioned undocumented methods) as well as interactively entering code and modifying your plugin on the fly.

There are two fairly important issues that you should be aware of, the first deals with how to implement event handlers without stomping on other plugins and is at: http://forums.lotro.com/showthread.p...nce-and-events
The second deals with handling international character sets in saved data and has a couple of different solutions, I implement a slightly altered version of a patch originally published here by Vindar: http://www.lotrointerface.com/downloads/info456.html

Dwamur 04-06-2012 06:36 AM

Necro'ing this thread.

"Writing LotRO LUA plugins for noobs" at http://forums.lotro.com/showthread.p...gins-for-Noobs has a lot of "good citizen" type advice:

- How to register events and callbacks safely, and unregister them again in your unload method
- How to get the unload method to take in the first place, reliably that is. You use an Update handler in the main window's constructor to register your unload method once the plugin has fully loaded.
- A note to please use RemoveCommand in unload, should you have added a shell command

I am going through some of the plugins I love using, and not all follow this good citizen model. How critical is it that all plugins in an apartment are good citizens? Will a plugin that did not manage to register an unload (because it doesn't use the Update trick) or does not release everything in an unload increase the likelihood of LotRO crashing when repeatedly unloading and loading?


All times are GMT -5. The time now is 03:36 PM.

vBulletin® - Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
© MMOUI