Sol

From Runes of Magic Wiki - The Runes of Magic

Jump to: navigation, search

Contents

Intro

Sol is a library of useful functions and ways to get game data.

Sol Recommended usage:

  • Place the latest version of Sol.lua directly in your Addons folder
  • Add ../Sol.lua to your addon's TOC file

Download:


Currently working on

  • Data mining - no one
  • Communication - Alleris
  • YOUR idea - YOU =D

API

Packages

Sol.animation

Sol.chat

Sol.color

Sol.config

Sol.hooks

Sol.io

Sol.string

Sol.table

Sol.timers

Sol.tooltip

Sol.util


Sol.data

Sol.data.crafts

Sol.data.frames

Sol.data.items

Sol.data.skills

Sol.data.quests

Sol.constants

  • Sol.constants.VERSION
  • Sol.constants.SEARCH_POS_ANY = 0
  • Sol.constants.SEARCH_POS_START = 1
  • Sol.constants.SEARCH_POS_END = -1
  • Sol.constants.SEARCH_TYPE_ANY = "any"
  • Sol.constants.SEARCH_TYPE_TABLE = "table"
  • Sol.constants.SEARCH_TYPE_FUNCTION = "function"
  • Sol.constants.SEARCH_TYPE_STRING = "string"
  • Sol.constants.SEARCH_TYPE_NUMBER = "number"
  • Sol.constants.SEARCH_TYPE_BOOLEAN = "boolean"
  • Sol.constants.QUEST_ALL = 0
  • Sol.constants.QUEST_COMPLETE = 1
  • Sol.constants.QUEST_INCOMPLETE = 2
  • Sol.constants.QUEST_DAILY = 1
  • Sol.constants.QUEST_NORMAL = 2
  • Sol.constants.DEFAULT_ANIMATION_TIME = 1
  • Sol.constants.DEFAULT_FPS = 30
  • Sol.constants.FLOATING_PT_PRECISION = 0.001

Who uses Sol

  • AddonManager [1]
  • ChatSettings [2]
  • CombatLogMod [3]
  • Keep It Simple Damage Meter [4]
  • nkCooldown [5]
  • nkProfBar [6]
  • PartyHide [7]
  • SkillQueue [8]
  • SubSkills [9]
  • Streamline [10]
  • UIMeasure [11]
  • /Who [12]
  • Your addon! If you use Sol, add it to this list =D

Examples

See the API for details on how to properly set these up. Some need to have specific elements in your XML.


Adding a /slash command for your addon's configuration/settings screen

Sol.config.CreateSlashToHandleConfig("MyAddonName", MyConfigFrame, "myslashcmd")

When the user types /myslashcmd or /myaddonname, MyConfigFrame will be shown (or hidden if it's already showing)

Showing options on your config screen and saving them

Sol.config.LoadConfig("MyAddonName", MyConfigPagesSelectedTab)

Goes through MyAddonName_Settings and looks for certain frames that could match that setting. If one is found, sets its value to the setting's value (e.g., you have a boolean setting MyAddonName_Settings.ShowOnStartup; your config screen's xml defines MyAddonNameToggleShowOnStartup; after running this function, MyAddonNameToggleShowOnStartup:IsChecked() will be set to to MyAddonName_Settings.ShowOnStartup)

If MyConfigPagesSelectedTab is provided, will ChangeTab to that one.

Sol.config.SaveConfig("MyAddonName")

Goes through MyAddonName_Settings and looks for certain frames that could match that setting. If one is found, sets the *setting*'s value to be equal to the frame item's value (e.g., you have a boolean setting MyAddonName_Settings.ShowOnStartup; your config screen's xml defines MyAddonNameToggleShowOnStartup; after running this function, MyAddonName_Settings.ShowOnStartup will be set to MyAddonNameToggleShowOnStartup:IsChecked())

Change tabs in a multi-tabbed frame

Sol.config.ChangeTab("MyAddonName", TabToChangeTo)

Disables TabToChangeTo, enables currently selectedTab, hides the currently shown page frame, and shows the page from you want to switch to.

Make sure all settings for your addon exist and/or update to new version

Sol.config.CheckSettings("MyAddonName", MyDefaultSettings)

Checks all the variables in MyDefaultSettings against those in MyAddonName_Settings and if any don't exist, they will be loaded from MyDefaultSettings. Note that it requres your settings variable to be called MyDefault_Settings.

Hook and use

Sol.hooks.Hook("MyAddonName", "AddMessage", MyAddonAddMessage, DEFAULT_CHAT_FRAME)

function MyAFunctionName(...)
    Sol.hooks.GetOriginalFn("MyAddonName", "AddMessage", DEFAULT_CHAT_FRAME)(...)
    MyDoSomething()
end

Print some purple text to DEFAULT_CHAT_FRAME

Sol.io.Print(Sol.color.ColorText("Hello world", "FF00FF"))

Print global frames with a name that starts with "Player"

local results = Sol.util.FindInTable(_G, "Player", Sol.constants.SEARCH_TYPE_TABLE, 0, false, Sol.constants.SEARCH_POS_START)
Sol.io.PrintTable(results)

results = Sol.util.FindInTable(_G, "Player", Sol.constants.SEARCH_TYPE_TABLE, Sol.util.MaxSearchResults, false, Sol.constants.SEARCH_POS_START)
Sol.io.PrintTable(results)

The first call returns the first Sol.util.MaxSearchResults (default is 50) search results; the second returns the next batch, assuming there were enough matches.

Reload your addon's main file without a ReloadUI()

Sol.util.LoadFile2("MyAddonName")

This will attempt to load Interface/Addons/MyAddonName/MyAddonName.lua

Add some useful debugging slash commands

Sol.util.LoadCommands()

Go through the hierarchy of frames (aka the frame tree) and print each one's name to a debug chat frame

Sol.data.frames.SetupFrameHierarchy()

local callback = function(node, parentNode, nodeLevel)
    Sol.io.PrintToDebugFrame(node:GetName())
end
Sol.data.frames.TraverseFrameHierarchy(callback)

Note that this is already implemented in Sol.data.frames.PrintFrameHierarchy. It is included here for illustration purposes. Also note that calls to any function in the Sol.data.frames package require Sol.data.frames.SetupFrameHierarchy() to have been run once.


Make a frame slowly disappear

Sol.animation.Fade("MyAddon", frame) 
Sol.animation.Move("MyAddon", frame, -1*frame:GetWidth())

This will change the frame's alpha to 0 (assuming it's not already at 0) and move the frame off the left side of the screen.

Note that this requires MyAddon_OnUpdate to be defined and to be receiving OnUpdate events

Personal tools