EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Quests::Custom (https://www.eqemulator.org/forums/forumdisplay.php?f=671)
-   -   auto-train on level for the extra lazy (https://www.eqemulator.org/forums/showthread.php?t=36263)

Rakkoraz05 11-23-2020 09:31 PM

Quote:

Originally Posted by macdaddy02 (Post 265569)
I'm not sure if this is old or I should post here anymore, however I got a .lua code that works and thought I'd share it with everyone.

Code:

function event_level_up(e)
                e.self:Message(15, "You have gained the knowledge of learning new skills, spells and discs!!");
        local skills = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 48, 49, 50, 51, 52, 53, 54, 56, 62, 66, 67, 70, 71, 72, 73, 74 };
        for i, curskill in ipairs(skills) do
                local maxskill = e.self:MaxSkill(curskill);
                if (e.self:CanHaveSkill(curskill) == false) then
                        --Do nothing...
                elseif (maxskill <= e.self:GetRawSkill(curskill)) then
                        --Do nothing...
                else
                    -- Scribe all spells up to current level
                  eq.scribe_spells(e.self:GetLevel());
                  -- Train all disciplines up to current level
                  eq.train_discs(e.self:GetLevel());
                  --Train all skills for current level
                  e.self:SetSkill(curskill, maxskill);
                end
        end
end


To use this would you just replace the current Event_Level_Up that's in the global_player.lua or just add it below?

jsr 11-23-2020 10:42 PM

You could add it to the existing function.

It would probably be better to put it in a separate function like grantsSkills(), and then call it.

That code can be simplified a bit, the negative checks are not needed (if false then do nothing + if false then do nothing + if true then do something == if true then do something).

Rakkoraz05 11-23-2020 11:35 PM

If there are two function calls for the same event, would that cause issue?

Edit: I did add this into the lua file. Seems to work just fine id the skill isn't 1 or greater.

jsr 11-24-2020 07:40 PM

I'm not quite sure how it will handle the same function twice, but it's not a good idea. Most languages won't allow it. If it does allow it, then its a bad idea from a maintenance perspective.


All times are GMT -4. The time now is 05:31 AM.

Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.