You are not logged in.

Applications: [GameMaster: OPEN] | [Volunteer Testers: OPEN]


This forum will be permanently shut down on Friday 13.07.2018
Please copy or save all important information from old forum before they will be deactivated
We have moved to new board. https://forum.runesofmagic.gameforge.com/Come join us.

Noguai

Beginner

  • "Noguai" started this thread

Posts: 5

Location: Germany

  • Send private message

1

Thursday, January 3rd 2013, 4:55pm

[GUIDE] Setup a Lua IDE for RoM addon development

Notice: This is a translation of my original guide: https://forum.runesofmagic.com/showthread.php?t=499076
If any of you native speakers here has some stuff to make the guide easier to understand, I'll gladly include that.

Comments and feedback is greatly appreciated.

Introduction:
Multiple times the question for a IDE for addon development has been asked. But IDEs with good Lua support are rare. Because of this many addon developers use a more or less simple text editor with script highlighting like SciTE or Notepad++ as well as the Lua console for debugging of general stuff.

Some time ago I found a program called IntelliJ IDEA for which a very good functioning Plugin exists. At the first time my installation failed because the plugin and the IDE were incompatible at the moment. To help others with the procedure or even generate interest among experienced addon developers, this shall be a guide to setup a working Lua development environment, which is in my opinion more useful than an editor like Npad++, even with my autocompletion.

Downloads:

  1. Lua4Windows: http://code.google.com/p/luaforwindows/
    (Needed for SDK; V5.1.4-46; Contains binaries and SciTE Editor)
  2. IntelliJ IDEA:
    Version 12: http://www.jetbrains.com/idea/download/index.html
    Version 11.1.5:http://devnet.jetbrains.net/docs/DOC-1228
    (The IDE; Our basis; Download version 11.1.5 Com Edition)
  3. Lua For IDEA: https://bitbucket.org/sylvanaar2/lua-for-idea/wiki/Home
    (Das Lua Plugin; No manual Download needed)
  4. FDB-Extractor 2: https://forum.runesofmagic.com/showthread.php?t=456472
    (Optional; Needed to add RoM-Interface to the standard libraries in the SDK)


Step 1: Installation of Lua binaries
Bevor actual installation of the IDE can start, Lua should be installed on your Computer. I used Lua4Windows for that. It contains the Windows Binaries and the SciTE editor, which is very good for quickly doing some tests, because it has support for the lua console. But SciTE is not really necessary. Download the installer from the previouly listed website (Google Code) and go through the installation process. After that you shoud be able to find Lua at: "C:\Program Files (x86)\Lua\5.1"

Step 2: Installation and configuration of IntelliJ IDEA
After that IntelliJ IDEA can be installed. But before you do that, you should inform yourself which versions of IDEA is compatible with the current build of the plugin. At the moment (01-03-2013) this is Version 11.1. IDEA 12 is currently incompatible as it is very new and it could take a while till this changes.
Update 18-03-2013: In the meantime I installed Windows 8 and tied IDEA 12. I noticed that Lua for IDEA has become compatible with the new version. Feel free to use that one. The installation instructions are just the same, but you have a new, nicer skin called "Darcula".

There are 2 different editions of IntelliJ IDEA: Ultimate and Community Edition. CE is the free variant. But apart from that there's nothing else you need to mind. Just let the installer run through.
index.php?page=Attachment&attachmentID=5374
Through the installation of an old version of IDEA a update notification might popup on the start. Update your IDE IN NO CASE and select "Ignore this Update" instead. The update checks can be disabled in the settings...
index.php?page=Attachment&attachmentID=5375
This is also the place that has to be visited next. Most configuration is nice, but some changes are qute useful though. The settings are located under File -> Settings:
index.php?page=Attachment&attachmentID=5376
The following list is ordered by windows and fields. Just go through it from top to bottom:
IDE Settings

  • Appearance
    1. Look and Feel -> Windows (Version 12: Darcula); Close the settings window and reopen it


  • Editor
    1. Zoom with Ctrl + Mouse Wheel -> on


    • Appearance
      1. Show line numbers -> on
      2. Show method separators -> on
      3. Show whitespaces -> on


    • Editor Tabs
      1. Show sirectory in tabs for non-unique filenames -> on
      2. Mark modified tabs with asterik -> on


    • Code folding
      1. Collapse documentation comments -> on



With that the basic configration and installation of IntelliJ IDEA is complete

Step 3: Installation and configuration of the Lua For IDEA plugin
After that you're ready to install the Lua Plugin and fun can start. The whole thing also works from the settings window:

  • IDE Settings
    • Plugins



[LIST=1|INDENT=3]
[*]Browse Repositories
  1. Lua suchen
  2. Doppelklick
  3. Yes (Installiert das Plugin)
  4. OK


[*]OK
[*]Restart
[/LIST]
After the restart several Lua specific settings appear in the configuration dialog:
index.php?page=Attachment&attachmentID=5377

There are several things that should be configured to make the plugin run better:

  • Template Project Settings
    • Inspections
      (There were few things that caused problems, so that I disabled them)
      1. Data Flow Issues -> off


      • Probable Bugs
        1. Suspicious global creation -> off
        2. Variable not assigned -> off




  • IDE Settings
    • Lua
      1. Add additional completions -> on


    • Editor (Optional)
      • Colors & Fonts
        • Lua (Adjust syntax highlighting)



    • OK




This already was part one of the plugin configuration. Now you can create your first project and setup the Lua SDK. To do that click on File -> New Project and choose "Project from Scratch". You need to do that even if you have existing sources, because this is the only way to tell the IDE that you want to work with Lua. In the following window edit the following:

  1. Project files location: Open your existing Addon directory or create a new one at: "Runes of Magic\Interface\Addons\"
  2. Project name: Changes according to the selected folder, but it may be changed after that.
  3. Project file format: .idea (directory based)
  4. Select type: Lua Module

After that you need to select an SDK. At the first time Kahlua is already available, but it isn't configured. To have RoM variables, etc. available you need to create your own SDK:
index.php?page=Attachment&attachmentID=5378

Click on "Configure" and the plus symbol in the upper left hand corner. Choose "Lua SDK" to add one to the list. After that you are asked to select the path to your previously installed Lua binaries ("C:\Program Files (x86)\Lua\5.1") and call your SDK for example "RoM Lua". To make RoM variables available you need FDB-Extractor 2 by TellTod. Extract the Interface.fdb to a directory you like, but please don't change the path after setting up the SDK. Add this extraction path to the "Classpaths" in IDEA. Don't just select the "interface" folder but the "worldxml" directory in it. Apply everything with OK and click on Finish. The project is created and after loading you will see something like this:
index.php?page=Attachment&attachmentID=5379

Notice the red warning. This is triggered because IDEA is able to handle GIT or SVN repositories and it has found one on my computer, that isn't configured in the project. You can change that by configuring the VCS system or ignore "VCS root errors".

Congrulations the configuration of IntelliJ IDEA with Lua For IDEA is completed! Have fun developing addons in a more comfortable way. ;)
Here's a screen of what my development environment with GIT and everyting:
Noguai has attached the following image:
  • 07.jpg

Noguai

Beginner

  • "Noguai" started this thread

Posts: 5

Location: Germany

  • Send private message

2

Thursday, January 3rd 2013, 4:56pm

IDEA Lua SDK Extension for Runes of Magic
(based on sylvanaar2's IDLua SDK for World of Warcraft)


IntelliJ IDEA is configured and works. Nice and handy, but one thing is still missing... You're right: A function documentation and a autocompletion with all functions! Okay, IDEA creates it's autocompletion by itself and we already have initiated that with the integration of the RoM interface to the sdk, but there's even more.

The following package has been created to solve that: Completely based on sylvanaar2's design for the WoW API this is on the one hand a dump of all RoM functions for a as complete as possible autocompletion, and on the other hand a direct connection to theromwiki.com. This is not achieved with a previously created database with all information, but with a download of the newest documentation directly through the web. This data is read, parsed and shown. Only disadvantage: There was no list of function signatures available on theromwiki.com like it was on wowprogramming.com and I wasn't able to read them through lua in game, so that everything is just shown as "someFunction()" instead of "return = someFunction(param)"

How do I use this?
That's simple:
Autocompletion: Start to type, just as usual
Quick Documentation: Ctrl + Q
RoMWiki page for function: Shift + F1
Signature: Ctrl + Mouseover

Do you have any screenshots?
Of course:


All right, where's the download?
Here: IDEA Lua SDK for Runes of Magic (v2).zip (Extract and add it to your SDK classfiles)
Old version: IDEA Lua SDK for Runes of Magic.zip
Noguai has attached the following images:
  • SDK_ext_01.jpg
  • SDK_ext_02.jpg

Noguai

Beginner

  • "Noguai" started this thread

Posts: 5

Location: Germany

  • Send private message

3

Thursday, January 3rd 2013, 4:57pm

~~ A last one... ~~

Peryl

Intermediate

Posts: 313

Location: Elsewhere

  • Send private message

4

Friday, January 4th 2013, 2:42pm

Minor changes for installing/configuring Lua IDE on Linux

Getting the Lua Binaries:[INDENT]Use your package manager for downloading and installing the Lua binaries. You'll want Lua version 5.1.4. You probably don't want Lua 5.2 as that version has some changes that aren't compatible with the version of Lua in RoM.[/INDENT]


Getting and installing IntelliJ IDEA:[INDENT]Use the same link but download the Linux version. Use an archive manager or just type the tar command as shown on the download link to decompress the tar ball to some place.[/INDENT]


Starting IntelliJ IDEA:[INDENT]Using a file manager or a terminal console, go to the folder where you decompressed IDEA and then go into the bin sub-folder. Double-click idea.sh shell script or launch the script with ./idea.sh to start IDEA.[/INDENT]


When configuring IntelliJ, you don't get the "Windows" appearance, so either use the default, or try the "Nimbus" look.

When configuring the Lua plugin, the changes for the inspections are under Template Project Settings > Inspections > Lua.

When creating a new Lua SDK, it will likely find the SDK folder itself and fill the entry for you. Typically it's in /usr/bin (Debian systems will likely find it in /usr/sbin).

To add the RoM SDK Extensions after finishing the first part of the guide, go to File > Other Settings > Template Project Structure. Select SDKs under Platform Settings and then select your SDK. Now you can add the new path to the RoM SDK extensions by clicking the plus sign [+] on the far right.
Peryl has attached the following image:
  • IDEA IDE on Linux.jpg
2013... The year from hell....

5

Friday, January 4th 2013, 4:49pm

I've followed Your instructions.
Now when i run this IDE there is 1 task running in background "Infering and Propagating Lua Types".
It runs for few minutes and takes almost 1GB of memmory.
Is is neccesary? If not then how can i turn it off?

Peryl

Intermediate

Posts: 313

Location: Elsewhere

  • Send private message

6

Friday, January 4th 2013, 5:11pm

Let it do its thing. When you first add that new paths, it has to scan and build all the data it needs from the extra folders. It won't be so bad once it is done.
2013... The year from hell....

Noguai

Beginner

  • "Noguai" started this thread

Posts: 5

Location: Germany

  • Send private message

7

Friday, January 4th 2013, 6:37pm

Thanks for your additions regarding Linux systems, Peryl.

@kkulesza: Yes it is, but as Peryl said, let it do that. It's mostly for the autocompletion which the program builds it on it's own. After that IDEA allocates nearly 0,5 GB and used around 250MB for me. You can force a cleanup by clicking on that bar.

Peryl

Intermediate

Posts: 313

Location: Elsewhere

  • Send private message

8

Thursday, January 10th 2013, 4:08am

More IDE setup stuff


Add Lua, XML and TOC file templates


To add a new Lua file template:

Go to File > Settings > IDE Settings > File Templates

Click the Templates tab and press the plus [+] button just above to add a new template. On the left side, Type a name for this template such as RoM Add-on Lua File and in the Extension box type lua. Make sure the Reformat according to style checkbox is checked. and in the box just below it, add the following:

Source code

1
#parse("RoM Add-on Header.lua")


Now click the Includes tab and press the plus [+] button again to add a new include file. Give this one a name of RoM Add-on Header and also an extension of lua (to match the name given in the parse command previously). Add the following (or something similar, as you like) to the code box:

Source code

1
2
3
4
5
6
7
8
9
10
--[[
    ${NAME}
    
    TODO: Add Description
    
    Version: TODO: Add Version number
    Author: TODO: Your Name Here!
    Date: ${DATE}
    License: TODO: Add-on license here
--]]


Click apply.


Adding a new XML file template:

There are some details that we'll fix in a bit, but for now...

Go back to the Templates tab and click the plus [+] button once again. Give this template an appropriate name such as RoM Add-on XML file and give it the extension xml. Make sure the Reformat according to style checkbox is not checked (well it can be if you really want, but I prefer it unchecked for the XML file). Now in the box below the checkbox, add the following:

Source code

1
2
3
4
5
6
7
8
<Ui xmlns="http://www.runewaker.com/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.runewaker.com/UI.xsd">






</Ui>



Click Apply.


Finally the TOC file entry:
(This one I can't get working right, but it is still useful).

Yet again, on the Templates tab, click plus [+] to add a third template and give it a name of RoM Add-on TOC and an extension of toc. Check or un-check the reformatting checkbox as you wish, and add the following if you wish (I can't get it to actually be used, so I'll leave it up to you if you want these details):

Source code

1
2
3
4
5
## Interface: TODO: Add RoM version 
## Title: ${PACKAGE_NAME}
## Version: TODO: Add Version
## Description: TODO: Add Description
## Author: TODO: Your Name Here


Click apply.

Now when you create a new file in a project folder, you'll get the option to create a RoM Add-on Lua File, RoM Add-on XML File, or RoM Add-on TOC. When you select these, you can give a filename without an extension and it will create the file with the correct extension and even add the appropriate header to it (except for the TOC which I still can't get to work).



There will be problems detected with the XML file, to get around some of these go to
File > Settings > Project Settings > Schemas and DTDs

In the Ignored Schemas and DTDs box, click the plus [+] button on the right and add the following URL to the ignored list:

Source code

1
http://www.runewaker.com/


Click Apply and then OK.

This should fix the issues with the XML header errors. It'll still give a few warnings, but they can mostly be ignored or at least looked at just in case.



Adding TOC files as a new file type:

Go to File > Settings > IDE Settings > File Types and click the Add button on the right.

In the pop-up dialog, Set the name to RoM TOC File and add an appropriate description. Set the Line Comment box to #.

In the Keywords box, add $language, $locale, and $root to one of the numbered tabs. Each numbered tab will give a different color for the highlighted keywords. Tab 1 keywords show up in dark blue, Tab 2 in a dark purple, Tab 3 in dark green, and Tab 4 in dark red. So use whichever tab you want for coloring. I put $root in tab 2 and the other two in tab 3. Click OK to when done with this dialog.

In the Registered Patterns box, add an entry via the plus [+] button on the right and register *.toc as the pattern. If it says that it is already registered with Text files, reassign it.

Click Apply, then OK. Now the TOC files will have the comments and special keywords highlighted.
2013... The year from hell....

Noguai

Beginner

  • "Noguai" started this thread

Posts: 5

Location: Germany

  • Send private message

9

Monday, March 18th 2013, 8:42pm

Just a little status update:
I've installed Windows 8 and tried IDEA 12. Lua for IDEA is now compatible with the new version. I have added corresponding notes and the link to the guide.

In the meantime the internet adress of theromwiki.com changed, as well as their page layout and with that the source code the extension parses did. I have added an update to that extension in the post directly under the guide. I have tested the changes only with IntelliJ IDEA 12 and the newest stable build of the lua plugin.

Regards
Noguai