New R93 Lua Functions!

Discussion in 'Lua Discussions' started by DavidDC, Aug 26, 2021.

Thread Status:
Not open for further replies.
  1. DavidDC

    DavidDC Programmer Moderator SOTA Developer

    Messages:
    1,532
    Likes Received:
    3,236
    Trophy Points:
    113
    Gender:
    Male
    R93 has some more function for you to use!

    I decided to make a script so you guys can figure out how to use the new objects added.

    Code:
    function ShroudOnStart()
        ShroudConsoleLog("Scene: " .. ShroudGetCurrentSceneNameRaw()); -- Display raw scene name
        ShroudConsoleLog("--- Pet Info:");
        DisplayPetInfo(); -- Display pet info
        ShroudConsoleLog("--- Pet Buff:");
        DisplayBuff(true); -- Display pet buff
        ShroudConsoleLog("--- Player Buff:");
        DisplayBuff(); -- Display player buff
    end
    
    function DisplayPetInfo()
        --Display pet informations, wont show anything if there is no pet
        local _petInfo = ShroudGetPetInfo();
        if _petInfo then
            ShroudConsoleLog("Name: " .. _petInfo.name);
            ShroudConsoleLog("Level: " .. _petInfo.level);
            ShroudConsoleLog("Strength: " .. round(_petInfo.strength,0));
            ShroudConsoleLog("Dexterity: " .. round(_petInfo.dexterity,0));
            ShroudConsoleLog("Intelligence: " .. round(_petInfo.intelligence,0));
            ShroudConsoleLog("Health: " .. _petInfo.currentHealth .. "/" .. _petInfo.maxHealth);
            ShroudConsoleLog("Health Regen: " .. (round(_petInfo.healthRegen,2)*100) .. "% Combat: " .. (round(_petInfo.healthRegenCombat,2) * 100) .. "%");
            ShroudConsoleLog("Attack Speed: " .. (round(_petInfo.attackSpeed,2) * 100) .. "%");
            ShroudConsoleLog("Resistance: " .. _petInfo.resist);
            
            ShroudConsoleLog("Magic Resistance: " .. _petInfo.magicResist);
            ShroudConsoleLog("Absorption: " .. (round(_petInfo.absorb,2) * 100) .. "%");
            ShroudConsoleLog("Move Speed: " .. _petInfo.moveSpeed .. " Rate: " .. (round(_petInfo.moveRate,2)*100) .. "%");
            ShroudConsoleLog("Strength Power: " .. _petInfo.strengthPower);
            ShroudConsoleLog("Taunt Power: " .. _petInfo.tauntPower);
            ShroudConsoleLog("Critical Hit Chance: " .. round(_petInfo.criticalHit,2) .. "%");
        end
    end
    
    function DisplayBuff(isPet)
        local _buffs;
        
        if isPet then
            _buffs = ShroudGetPetBuff();
        else
            _buffs = ShroudGetPlayerBuff();
        end   
        
        --Display pet buff and their effects, wont show anything if there is no buff
        if _buffs then
            for i,v in pairs(_buffs) do
                ShroudConsoleLog(v.runeName);
                for x,y in pairs(v.effects) do
                    ShroudConsoleLog(y.value .. " " .. y.description .. " Duration: " .. y.currentDuration .. "/" .. y.totalDuration .. " Ticks: " .. y.totalTick);
                end           
            end
        end
    end
    
    --helper function to round numbers to X decimal
    
    function round(num, numDecimalPlaces)
        local mult = 10^(numDecimalPlaces or 0)
        return math.floor(num * mult + 0.5) / mult
    end

    If you need help we have a channel on discord where we can discuss this stuff real time with pinned link to useful website to learn Lua!

    For a complete list of our functionality with lua you can look at this Link
     
    Wilfred, Winfield, Katu and 4 others like this.
  2. Tirrag

    Tirrag Avatar

    Messages:
    854
    Likes Received:
    1,823
    Trophy Points:
    93
    Location:
    Iowa, USA
    thank you @DavidDC! please keep the Lua love coming :) love the updated reference document and the new style of functions. was able to convert easily from the old player buff functions and it allowed me to standardize the code for both pet and player. great stuff :)
     
    Wilfred and DavidDC like this.
Thread Status:
Not open for further replies.