[Guide]Addonerstellung

Wilkommen im Forum von Runes of Magic DE

Regeln und Richtlinien: Spielregeln - Community-Richtlinien - Allgemeine Nutzungsbedingungen - RoM Servers Status

Kontaktmöglichkeiten: Support System - Discord
  • Da ich davon ausgehe, dass die Meisten zumindest grundlegendes Englisch verstehen (und man ohne Englisch auch nicht allzu weit kommt beim Programmieren), ist der Guide in Englisch verfasst.

    Remark: This Guide requires some basic understanding of Programming and in special the Programming Language LUA.

    I'll only explain how to setup files to create an Addon. For that, you have to read the sources i'll link at the end of this Post.

    Step 1: Needed Files

    Every Addon needs several Files, which are used for different parts of it.

    1. .toc-File: Here you declare, which files Runes of Magic should load when it's started.
    2. .xml-File: Thie File is used to create GUIs and add functionality to it. Also you can use it to create timed Functions/Scripts.
    3. .lua-File: Used for function declarations.

    There is no need for all files depending on the usecase.

    Step 2: Content

    Let's assume we want to create an addon, which just writes someting into the chat when it's loaded.

    Code: ex1.lua, ex2.lua
    1. function ex1Frame_OnLoad()
    2. ChatFrame1:AddMessage("Example Frame loaded!")
    3. end
    4. ChatFrame1:AddMessage("Example loaded!")

    With only this file nothing would happen since the client doesn't know of this file. In order to change that we need the .toc-File with the path of the .lua file relative to the .toc-File.

    Code: ex1.toc
    1. ex1.lua

    Now the addon writes "Example loaded!" as soon as it is loaded.

    In the next example, we do the same with an XML file combined with lua.

    Code: ex2.xml
    1. <Ui xmlns="http://www.runewaker.com/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemalocation="http://www.runewaker.com/..\..\WorldXML\UI.xsd">
    2. <Script file="ex2.lua"/>
    3. <Scripts>
    4. <OnLoad>
    5. ex1Frame_OnLoad()
    6. </OnLoad>
    7. </Scripts>
    8. </Ui>

    This file looks way more complex than the .lua.
    One Basic rule in xml is, that every tag which is opened needs to be closed. Also for Runes of Magic everything needs to be encapsulated by an Ui-Tag.
    To execute a script in XML you have to bind it to an object. Objects can be Frames, Buttons and more. In this example we use the "Frame" ex1ScriptFrame.
    We add the Script ex1Frame_OnLoad which is called when the Frame is loaded (OnLoad-Tag inside the Scripts tag). Inside those Script tags we can write normal lua-Code.
    We only have to check, that there is no character sequence, which could be recognized as XML-Tag. It's always a good style to move all functionality to the .lua file and only call those functions from the xml.

    Again we have to include the xml file:

    Code: ex2.toc
    1. ex2.xml

    First the Script "ex2.lua" is loaded(line 2) which writes "Example loaded!" into the chat.
    After that the Frame "ex2ScriptFrame" is loaded and calls ex1Frame_OnLoad, which was declared in "ex2.lua". This function prints "Example Frame loaded!" into the chat.

    I also recommend to have a look at the following pages:

    Acknowledgements

    • ArcticXWolf (Original Guide)
    • TellTod (FDB-Extractor2)
    • Noguai, Yoman(Rom-Welten Database)

    Note:
    This Guide is far from complete and only gives a short example.
    If you want to program more complex addons you have to consider language support and more. It's quite helpful to check the interface.fdb to see, how the original functionality is implemented. To extract it, you can use the FDB-Extractor2.
    Also usage of IDs is more efficient and not as error prone as using the current texts for it.

    Pyrr

    Files

    • guide.txt

      (4.74 kB, downloaded 429 times, last: )
  • Diogenes

    Approved the thread.
  • Das Thema hatten wir schon einmal mit Pittiplatsch (The Pitt) !



    Es gibt hier tatsächlich Leute die älter als 14 sind und in der Schule russisch und kein englisch hatten.