# Magic Methods to interact with the magic gametab. - - - ## TRSMagic Main record reponsible for handling the magic gametab. - - - ## Magic.IsOpen ```pascal function TRSMagic.IsOpen(): Boolean; ``` Returns true if the Magic tab is open. Example: ```pascal WriteLn Magic.IsOpen(); ``` - - - ## Magic.Open ```pascal function TRSMagic.Open(): Boolean; ``` Attempts to open the magic tab. Example: ```pascal Magic.Open(); ``` - - - ## Magic.IsSpellBook ```pascal function TRSMagic.IsSpellBook(book: ERSSpellBook): Boolean; ``` Returns true if we are using the specified spell book. Example: ```pascal WriteLn Magic.IsSpellBook(ERSSpellBook.LUNAR); ``` - - - ## Magic.GetSpellBook ```pascal function TRSMagic.GetSpellBook(): ERSSpellBook; ``` Returns the current spell book. Example: ```pascal WriteLn Magic.GetSpellBook(); ``` - - - ## Magic.InfoIsOpen ```pascal function TRSMagic.InfoIsOpen(): Boolean; ``` Returns true if the info black box about a spell is open. Example: ```pascal WriteLn Magic.IsSpellBook(ERSSpellBook.LUNAR); ``` - - - ## Magic.CloseInfo ```pascal function TRSMagic.CloseInfo(): Boolean; function TRSMagic.CloseInfo(spell: ERSSpell): Boolean; overload; ``` Returns true if the info black box about a spell is open. Example: ```pascal WriteLn Magic.CloseInfo(); ``` - - - ## Magic.FindSpell ```pascal function TRSMagic.FindSpell(spell: ERSSpell; out box: TBox): Boolean; ``` Return true or false wether we found a spell or not and return it's bounds if found. - - - ## Magic.ContainsSpell ```pascal function TRSMagic.ContainsSpell(spell: ERSSpell): Boolean; ``` Return true or false wether we found a spell or not. - - - ## Magic.Hover ```pascal function TRSMagic.Hover(spell: ERSSpell): Boolean; ``` Used to move the mouse to the specified spell. Example: ```pascal Magic.Hover(ERSSpell.HIGH_LEVEL_ALCHEMY); ``` - - - ## Magic.Click ```pascal function TRSMagic.Click(spell: ERSSpell; button: EMouseButton = EMouseButton.LEFT): Boolean; ``` Used to Click on a specified spell. Example: ```pascal Magic.Click(ERSSpell.HIGH_LEVEL_ALCHEMY); ``` - - - ## Magic.Interact ```pascal function TRSMagic.Interact(spell: ERSSpell; option: String = ''): Boolean; ``` Used to interact with the specified spell. You can just click it or choose an option on it. Example: ```pascal Magic.Interact(ERSSpell.HIGH_LEVEL_ALCHEMY); ``` - - - ## Magic.FindSelected ```pascal function TRSMagic.FindSelected(out tpa: TPointArray): Boolean; ``` Returns the true if we have a selected spell and returns it's tpa. Example: ```pascal if Magic.FindSelected(tpa) then Debug(tpa); ``` - - - ## Magic.ContainsSelected ```pascal function TRSMagic.ContainsSelected(): Boolean; ``` Returns the true if we have a selected spell. Example: ```pascal WriteLn Magic.ContainsSelected(); ``` - - - ## Magic.IsSelected ```pascal function TRSMagic.IsSelected(spell: ERSSpell): Boolean; function TRSMagic.IsSelected(spell: ERSSpell; selected: TPointArray): Boolean; overload; ``` Returns true if the specified spell is currently active (with white outline). Example: ```pascal WriteLn Magic.IsSpellSelected(ERSSpell.ICE_BARRAGE); ``` - - - ## Magic.CanActivate ```pascal function TRSMagic.CanActivate(spell: ERSSpell): Boolean; ``` Returns true if we can activate the spell (we have runes, level and the spell unlocked). Example: ```pascal Magic.CanActivate(ERSSpell.HIGH_LEVEL_ALCHEMY); ``` - - - ## Magic.SpellWasCast ```pascal function TRSMagic.SpellWasCast(spell: ERSSpell): Boolean; ``` Returns true if we are in a state that casting a spell would leave you. Example: ```pascal Magic.SpellWasCast(ERSSpell.ICE_BARRAGE); ``` - - - ## Magic.CastSpell ```pascal function TRSMagic.CastSpell(spell: ERSSpell): Boolean; ``` Attempts to cast the specified spell. Example: ```pascal Magic.CastSpell(ERSSpell.LOW_LEVEL_ALCHEMY); ``` - - - ## Magic.GetBookSpellCount ```pascal function TRSMagic.GetBookSpellCount(): Int32; ``` Returns the number of spells declared in SRL for the current spellbook. Example: ```pascal WriteLn Magic.GetBookSpellCount(); ``` - - - ## Magic variable Global {ref}`TRSMagic` variable.