Welcome to AC Web.
Results 1 to 2 of 2
  1. #1

    FIXED [lua Script] Learn spell on level up


    REGISTER! (FREE)
    Registered members see less ads
    and also gain access to other great features.
    Hello All,

    I have been trying for hours to get this correct. Looking over Eluna documentation, reading through other lua scripts for clues, running the code through Lua Demo, but I'm just stumped. It errors out on the last line of code when calling the function. I have tried various changes but no luck. I will post a partial of the code as it is too long to paste the entire thing, but the last part is the most important. Thanks for any light that can be shed on this. Before the function it repeats for each class, level and spells as show for warrior.

    local Classes = {
    ["Warrior"] = {
    [2] = {6673},
    [4] = {772},
    [6] = {6343, 34428},
    [8] = {1715, 284},
    [10] = {6546, 2687},
    [12] = {7384, 5242, 72},
    [14] = {1160, 6572},
    [16] = {285, 694, 2565},
    [18] = {8198, 676},
    [20] = {6547, 20230, 845, 12678},
    [22] = {6192, 5246},
    [24] = {1608, 6190, 5308, 6574},
    [26] = {6178, 1161},
    [28] = {8204, 871},
    [30] = {6548, 7369, 20252, 1464},
    [32] = {11564, 11549, 18499, 20658},
    [34] = {11554, 7379},
    [36] = {1680},
    [38] = {8205, 6552, 8820},
    [40] = {11565, 11572, 11608, 20660, 23922},
    [42] = {11550},
    [44] = {11555, 11600},
    [46] = {11578, 11604},
    [48] = {11566, 11580, 20661, 23923},
    [50] = {11573, 11609, 1719},
    [52] = {11551},
    [54] = {11556, 11605, 11601, 23924},
    [56] = {11567, 20662},
    [58] = {11581},
    [60] = {25286, 11574, 25289, 20569, 25288, 23925},
    [61] = {25241},
    [62] = {25202},
    [63] = {25269},
    [64] = {23920},
    [65] = {25234},
    [66] = {29707, 25258},
    [67] = {25264},
    [68] = {25208, 25231, 469},
    [69] = {2048, 25242},
    [70] = {30324, 25203, 25236, 3411, 30357},
    [71] = {46845, 64382},
    [72] = {47449, 47519},
    [73] = {47501, 47470},
    [74] = {47439, 47474},
    [75] = {55694, 47487},
    [76] = {47450, 47465},
    [77] = {47520},
    [78] = {47502, 47436},
    [79] = {47437, 47475},
    [80] = {57755, 47440, 47471, 57823, 47488},
    }
    }
    function LearnSpellOnLevelUp(event, player)
    local spells = Classes[player:GetClassAsString()] and Classes[player:GetClassAsString()][player:GetLevel()] or {}
    for k, v in ipairs(spells) do
    player:LearnSpell(v)
    end
    end

    RegisterPlayerLevelEvent(13, LearnSpellOnLevelUp)

    - - - Updated - - -

    Quote Originally Posted by kbt0y5 View Post
    Hello All,

    I have been trying for hours to get this correct. Looking over Eluna documentation, reading through other lua scripts for clues, running the code through Lua Demo, but I'm just stumped. It errors out on the last line of code when calling the function. I have tried various changes but no luck. I will post a partial of the code as it is too long to paste the entire thing, but the last part is the most important. Thanks for any light that can be shed on this. Before the function it repeats for each class, level and spells as show for warrior.

    local Classes = {
    ["Warrior"] = {
    [2] = {6673},
    [4] = {772},
    [6] = {6343, 34428},
    [8] = {1715, 284},
    [10] = {6546, 2687},
    [12] = {7384, 5242, 72},
    [14] = {1160, 6572},
    [16] = {285, 694, 2565},
    [18] = {8198, 676},
    [20] = {6547, 20230, 845, 12678},
    [22] = {6192, 5246},
    [24] = {1608, 6190, 5308, 6574},
    [26] = {6178, 1161},
    [28] = {8204, 871},
    [30] = {6548, 7369, 20252, 1464},
    [32] = {11564, 11549, 18499, 20658},
    [34] = {11554, 7379},
    [36] = {1680},
    [38] = {8205, 6552, 8820},
    [40] = {11565, 11572, 11608, 20660, 23922},
    [42] = {11550},
    [44] = {11555, 11600},
    [46] = {11578, 11604},
    [48] = {11566, 11580, 20661, 23923},
    [50] = {11573, 11609, 1719},
    [52] = {11551},
    [54] = {11556, 11605, 11601, 23924},
    [56] = {11567, 20662},
    [58] = {11581},
    [60] = {25286, 11574, 25289, 20569, 25288, 23925},
    [61] = {25241},
    [62] = {25202},
    [63] = {25269},
    [64] = {23920},
    [65] = {25234},
    [66] = {29707, 25258},
    [67] = {25264},
    [68] = {25208, 25231, 469},
    [69] = {2048, 25242},
    [70] = {30324, 25203, 25236, 3411, 30357},
    [71] = {46845, 64382},
    [72] = {47449, 47519},
    [73] = {47501, 47470},
    [74] = {47439, 47474},
    [75] = {55694, 47487},
    [76] = {47450, 47465},
    [77] = {47520},
    [78] = {47502, 47436},
    [79] = {47437, 47475},
    [80] = {57755, 47440, 47471, 57823, 47488},
    }
    }
    function LearnSpellOnLevelUp(event, player)
    local spells = Classes[player:GetClassAsString()] and Classes[player:GetClassAsString()][player:GetLevel()] or {}
    for k, v in ipairs(spells) do
    player:LearnSpell(v)
    end
    end

    RegisterPlayerLevelEvent(13, LearnSpellOnLevelUp)
    Fixed it. It was due to old lua function calling and a typo by me. Last line should read, RegisterPlayerEvent(13, LearnSpellOnLevelUp)

    I found this code on another site, I take zero credit for this.
    Last edited by kbt0y5; 02-16-2020 at 06:39 AM. Reason: fixed

  2. #2
    Innovation & Emulation

    Join Date
    Feb 2008
    Location
    Great Britain
    Posts
    1,856

    REGISTER! (FREE)
    Registered members see less ads
    and also gain access to other great features.
    So if you want to learn more, I did something similar for Eluna 3.3.5a TrinityCore. On level up show a interface where the player can select the reward and learn the spell / receive the item. It would be trivial to modify this to support multiple classes, this was on classless project.

    Server side: https://github.com/stoneharry/Zombie...tionSystem.lua
    Client side: https://github.com/stoneharry/Zombie...tionSystem.lua
    Video: https://youtu.be/VMB_TnqlnDo?t=156

    Alternatively, I did downport the Cataclysm+ level up interface to 3.3.5 using ArcEmu Lua a long time ago.

    Server side: https://github.com/stoneharry/Misc-W...lingSystem.lua
    Client side: https://github.com/stoneharry/Misc-W...splay.lua#L900
    Video: https://youtu.be/dJqRns42Hkc?t=5

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •