Introduction to Serverside LUA programming 3.3.5a menu

User Tag List

Results 1 to 2 of 2
  1. #1
    Method's Avatar Contributor Modding Enthusiast CoreCoins Purchaser
    Reputation
    115
    Join Date
    Jul 2014
    Posts
    89
    Thanks G/R
    2/29
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Introduction to Serverside LUA programming 3.3.5a

    Introduction

    I had difficulties when I was figuring out where to begin with serverside LUA, so I decided that I would write this simple guide:

    In short, Serverside LUA is how you can make scripted encounters, complicated quests or events happen in WoW.
    Unless you want to perform all storytelling through a quest-log rather than visually, LUA is a requirement for greater designs.

    Goals of this guide:
    - make the learning process less intimidating for beginners.
    - Breaking down the process.
    - recompiling/rediscovering of old/outdated or recreation of now non-existent information.
    - LUA in practice.

    LUA?:
    - a programming language.
    - Clientside: it is most commonly used to write addons for the WoW interface.
    - Serverside: It is used to script events, make complex quests, introduce complex new features. (Ascension WoW)

    Basic Server Components:

    4 core components:
    - Core (TrinityCore, AzerothCore, ElysiumCore)
    - LUA engine (API) (Eluna, ArcEmu)
    - Database (MySQL)
    - Database Manager (HeidiSQL, SQL Workbench)
    additional components:
    - AIO being used. (Rochet2)

    Our setup:

    TrinityCore:
    - Core that most other cores inherit from.

    Eluna:
    - A cross-core LUA engine API.

    MySQL/SQLworkbench
    - Database and Manager

    Rochet2:
    - AIO



    Get your prerequisites

    assuming that you have never built a WoW server from source on your current system you are required to download supporting tools. Without these programs you will not be able to continue with this guide.

    You will also need a 3.3.5 client downloaded.

    - Go to this Tutorial
    - Make sure you install all of the required programs/prerequisites mentioned before you continue with this guide.

    Let's get started

    When you are certain you have installed and confined the requirements correctly we are good to go.

    - Make a folder called "Server" in your C:/ Drive.
    - Inside that folder, make 2 new folders "Source" and "Build"
    - Open "Source" and do "Git Bash here"
    - Copy and paste the following code:

    Code:
    git clone https://github.com/ElunaLuaEngine/ElunaTrinityWotlk --recurse
    - You now have the Source of [Eluna + TrinityCore]

    - Open CMake
    - Build Path = C:\Server\Build
    - Source Path = C:\Server\Source\ElunaTrinityWotlk
    - Press "Configure"
    - Select Visual Studio 17 (Install 17 if you have 19)
    - Optional Platform = x64
    - Use default native compilers = selected.
    - Finish
    - Should perform checks then everything should be red. This is normal
    - "Eluna" should be on the the red list.

    - If you have ANY error pop-ups you are most likely missing a requirement or haven't configured a requirement correctly.
    Common errors are things like Boost not being installed correctly.

    - for multiple errors you will need to resolve these individually
    - press "configure" until no errors appear.
    - Finally press "Generate" when no errors are appearing.
    - Close CMake

    - Open "Build" Folder
    - Open "TrinityCore.sln" with Visual Studio 17.
    - Change "Debug" at top to "Release"
    - In Solution Explorer right click Solution 'TrinityCore' (25 of 25 projects)
    - Select "Clean Solution"
    - Then select "Build Solution"
    - This will take 10-60 minutes depending on your CPU.
    - When finished should say something like this, the "succeeded" number is unimportant.
    Code:
    ========== Build: 23 succeeded, 0 failed, 0 up-to-date, 2 skipped ==========
    - If you have any >0 "failed" refer to TrinityCore setup.
    - Else Close Visual Studio.

    - Navigate to C:\Server\Build\bin\
    - \Release contains your
    - Move \Release to C:\Server\Release
    - Go back to C:\Server\Release
    - You'll notice a folder called "lua_scripts" if you've done things correctly.
    - Copy "vmap4extractor.exe", "vmap4assembler.exe", "mmaps_generator.exe" and "mapextractor.exe"
    - Paste to a 3.3.5 WoW directory. containing a Wow.exe (Example: C:\World of Warcraft)
    - Run each .exe in following order (make sure you press enter): "mapextractor.exe", "vmap4extractor.exe", "vmap4assembler.exe", "mmaps_generator.exe".
    - generating mmaps can take a very long time. (10-60 minutes with a good processor)
    - Put the newly created "vmaps", "dbc", "maps", "mmaps" and "Cameras" back into C:\Release
    - can now safely delete these files in your C:\World of Warcraft directory and remove the .exe's
    - You can safely delete the .exe tools from C:\Release

    - Remove ".dist" from the end of the "Worldserver.conf" and "Authserver.conf" files.

    - Go here and download the latest "335.xxxxx" TDB_Full_World 7z archive:
    Code:
      https://github.com/TrinityCore/TrinityCore/releases
    - Extract the TDB_Full_World to your C:/Release Folder

    - go to the bottom right of your screen (next to clock)
    - click on show hidden icons.
    - right click on MySQL notifier
    - Manage instance
    - you should see your instance.
    - Open it.
    - Select all existing schemas and drop them.
    - Go here and copy the SQL creation script:
    Code:
     https://github.com/TrinityCore/TrinityCore/blob/3.3.5/sql/create/create_mysql.sql
    - paste it and click on the lightning bolt to execute the code.
    - close SQL workbench and reopen in the same way.
    - You should now have "auth", "characters" and "world" schemas.
    - This will create our empty database that we can populate.


    - There are 3 DLL files that need to be manually copy/pasted to your C:/Release folder:
    MySQL → C:\Program Files\MySQL\MySQL Server 5.x\lib\
    - libmysql.dll
    OpenSSL → C:\Program Files\OpenSSL-Win64\bin
    - libssl-1_1-x64.dll
    - libcrypto-1_1-x64.dll

    - Run Worldserver.exe
    - If you did everything correctly Worldserver should populate the empty database using the TDB_World file and stay open.
    - if not it will crash and generate any errors in Server.log
    - Worldserver will tell you if it has found SSL, Boost and if the .conf file is accessible.
    - If Worldserver stays open it is working correctly.
    - Close worldserver
    - you can now move C:/Server/Release to C:/Release
    - You can now safely delete C:/Server
    - Go back to C:/Release.
    - You should now only have C:/Release and your WoW client.

    - Go to your Client Data/EnUS and change edit realmlist.wtf to:
    Code:
     set realmlist 127.0.0.1
    - Start "Authserver.exe" and Restart "Worldserver.exe" Keep these open.
    - I recommend pinning them to your start menu for faster server startup.

    - In Worldserver.exe type:
    Code:
     account create NAME PASSWORD
    - You should now be able to login with that Account name and Password.

    Testing that Eluna is functional

    Create a file named "hello world.lua" that contains the following code and place the file inside the "lua_scripts" folder in C:/Release.

    Code:
    local PLAYER_EVENT_ON_LOGIN = 3
    
    local function OnLogin(event, player)
        player:SendBroadcastMessage("Hello world")
    end
    
    RegisterPlayerEvent(PLAYER_EVENT_ON_LOGIN, OnLogin)
    - Restart Worldserver and Authserver
    - Under "Welcome to a Trinity Server" should be the line "Hello World".
    - If this is true, you have successfully set up Trinity and Eluna

    Rochet2 AIO Setup

    - AIO is built on top of Eluna so this is why we are doing this now.
    - Go here and download the latest version of AIO.
    Code:
     https://github.com/Rochet2/AIO
    - Copy the AIO_Client to your WoW_installation_folder/Interface/AddOns/
    - Copy the AIO_Server to your C:/Release/lua_scripts/

    Create a file named "aio test.lua" that contains the following code and place the file inside the "lua_scripts" folder in C:/Release.
    Code:
    local AIO = AIO or require("AIO")
    
    if AIO.AddAddon() then
        -- we are on server
        print("Hello Server")
    else
        -- we are on client
        print("Hello Client")
    end
    - Restart Worldserver and Authserver
    - Under "Welcome to a Trinity Server" should be the line "Hello World".
    - If this is true, you have successfully set up Trinity, Eluna and Rochet.

    Mcx2WcL.png

    We're ready to go!



    Now we can begin:


    Obviously you will need to create a creature first by adding it to your database. If you are unsure how to do this:

    - Go to SQLWorkbench
    - Double-click "World" to select it as the default database.
    - Open a new query tab.
    - Enter and run the following script which will find "Sildanair" from the Creatures table.

    Code:
      SELECT * FROM creature_template
    WHERE name LIKE '%Sildanair%'
    LIMIT 0, 1000
    - Should return 1 row, Sildanair.
    - Go to "Form Editor" tab.
    - All I really wanted here was the "Display ID" or "2198"

    Here is a Creature Script that makes a hostile NPC:

    Code:
    INSERT INTO creature_template (entry, name, subname, minlevel, maxlevel, faction, npcflag, speed_walk, speed_run, scale, rank, dmgschool, BaseAttackTime, RangeAttackTime, unit_class, unit_flags, unit_flags2, dynamicflags, family, type, type_flags, lootid, pickpocketloot, skinloot, PetSpellDataId, VehicleId, mingold, maxgold, AIName, MovementType, HoverHeight, HealthModifier, ManaModifier, ArmorModifier, DamageModifier, ExperienceModifier, RacialLeader, RegenHealth, mechanic_immune_mask, flags_extra, exp, modelid1, modelid2, modelid3, modelid4, difficulty_entry_1, difficulty_entry_2, difficulty_entry_3) VALUES (80001, 'Eluna', '', 80, 80, 168, 0, 1.1, 1.17, 1, 0, 0, 1500, 2000, 1, 67108864, 0, 1, 0, 1, 65, 0, 0, 0, 0, 0, 0, 0, 'NullAI', 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 2, 2198, 0, 0, 0, 0, 0, 0);
    INSERT INTO creature_template_addon (entry, mount, bytes1, emote, auras) VALUES (80001, 0, 0, 0, '');
    This script will add a new mob called "Eluna" with EntryID 80001.








    Create a new lua file, I reccomend naming it after the creature ID, for example "80001.lua"

    A creature has 0 events when it is created, and therefore does nothing.

    If we make an event we can add it to the List:
    Code:
     creature:RegisterEvent(Phase, 3200, 1)
    Here I am adding a single action to the list: "Phase". this action takes 3200ms or 3.2 seconds to perform (This will be relevant soon)

    Now, we need to actually make Phase, so let's do that:

    function FirstPhase(event, delay, pCall, creature)

    creature:SendUnitSay(Dialogue[2], 0)
    creature:CastSpell(creature:GetVictim(), Spell[1])

    end

    If you are familiar with other languages, this will look very familiar to you.




    We could do this instead:

    creature:RegisterEvent(Phase, 3200, 1)

    Instead of repeating infinitely every 3.2 seconds, Phase will only happen once,
    Last edited by Method; 12-03-2019 at 03:29 PM.

    Introduction to Serverside LUA programming 3.3.5a
  2. Thanks Ziggeh, zaicopx, Mercedes, Fufavu, EverJunior, 6thsense (6 members gave Thanks to Method for this useful post)
  3. #2
    EverJunior's Avatar Member
    Reputation
    1
    Join Date
    Oct 2022
    Posts
    1
    Thanks G/R
    1/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for guide! Im curios, is there a part 2 of the guide? Because this one ends on the very beginning of eluna part

Similar Threads

  1. [Lua] A small introduction to tables
    By Dynashock in forum WoW EMU Guides & Tutorials
    Replies: 10
    Last Post: 07-12-2009, 06:31 PM
  2. Replies: 2
    Last Post: 08-17-2007, 07:53 AM
  3. need help to find some programs
    By Drakee in forum Community Chat
    Replies: 4
    Last Post: 05-01-2007, 07:58 AM
  4. Introduction to Professions [n00b Guide]
    By Squirllz in forum World of Warcraft Guides
    Replies: 1
    Last Post: 10-12-2006, 07:32 PM
All times are GMT -5. The time now is 04:36 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search