Introduction to Serverside LUA programming 3.3.5a menu

These ads disappear when you log in.

Results 1 to 1 of 1
  1. #1
    Method's Avatar Contributor Modding Enthusiast CoreCoins User
    Reputation
    98
    Join Date
    Jul 2014
    Posts
    86
    Thanks G/R
    2/20
    Trade Feedback
    0 (0%)

    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:

    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?:
    - 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:
    - The AIO being used. (Rochet2)

    Setup being used:

    TrinityCore:
    - Core that most other cores inherit from.

    Eluna:
    - A cross-core LUA engine API.

    MySQL/SQLworkbench
    - Database and Manager

    Rochet2:
    - AIO

    If you're confused about what these things are, in the beginning players only had Client files, there was no access to serverside code, no core existed. The core was built from scratch using 3.3.5 gameplay as an example for more than a decade and is still currently in development. A core is an emulation of what a 3.3.5 should look, play and feel like and allows players to connect with the 3.3.5 client as if it was an official Blizzard server.

    The Lua engine




    Installation of [TrinityCore + Eluna]

    What we want to do:
    - Clone the [Eluna + TrinityCore 3.3.5a] Source
    - Build the [Eluna + TrinityCore 3.3.5a] Source to make a server.
    - Install the Rochet2 AIO
    - Code some basic things in LUA.

    assuming you've never built a WoW server from source:
    - programs/vars/libraries require to be setup.
    - Go to this Tutorial
    - Make sure you install all of the required programs/prerequisites mentioned before you continue with this guide.

    When you have the required programs/prerequisites installed:
    - 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]
    - Follow the regular TrinityCore tutorial from This point.
    - Follow from: "Configuring and generating Visual C++ solutions with CMake" onwards
    - Come back to this guide when you are able to login.

    Here is a step-by-step guide of my own reinstallation:

    Please consider using TrinityCore setup instead, this is only intended to help you out if you get confused!

    - 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.
    - "Eluna" should be on the the red list.
    - If you have errors refer to TrinityCore setup.
    - Else press "Generate"
    - 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 this:
    Code:
    ========== Build: 23 succeeded, 0 failed, 0 up-to-date, 2 skipped ==========
    - If you have >0 failed refer to TrinityCore setup.
    - Else Close Visual Studio.

    - Navigate to C:\Server\Build\bin\
    - \Release contains your built Server files.
    - Move \Release to C:\Release
    - Can now safely delete C:\Server and all contents
    - Go back to C:\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".
    - This process for creating mmaps can take a long time.
    - 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:
    Code:
      https://github.com/TrinityCore/TrinityCore/releases
    - Go here and download the SQL creation script:
    Code:
     https://github.com/TrinityCore/TrinityCore/blob/3.3.5/sql/create/create_mysql.sql
    - Extract the TDB_Full_World to your C:/Release Folder
    - Run the SQL query in MySQL by opening up a new query tab and copy/pasting.
    - This will create our empty database.


    - 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:\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.

    - Go to your Client Data/EnUS and change edit realmlist.wtf to:
    Code:
     set realmlist 127.0.0.1
    - In Worldserver.exe type:
    Code:
     account create NAME PASSWORD
    - Start "Authserver.exe" and Restart "Worldserver.exe" Keep these open.
    - I reccomend pinning them to your start menu for faster server startup.
    - You should now be able to login with that Account name and Password.

    Testing that Eluna is functional

    Here is a simple "Hello world" example script. 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)
    - 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/

    - Edit your "Hello World.lua" and add the following lines to make sure AIO is functional:
    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

    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; 4 Weeks Ago at 12:56 PM.

  2. Thanks Ziggeh (1 members gave Thanks to Method for this useful post)

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:37 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved. Digital Point modules: Sphinx-based search