Ordush 185 Posted November 19, 2017 Share Posted November 19, 2017 Hey yall Anyone knows if there is a link to the global lua api for any wow versions? A document where all the global functions are in. i.e. The game has the function UnitRace() or the function IsSpellKnown Reason i want to find this is because i want to add some of these functions added to the gamer after 2.4.3 into my fight class. I have already added some of those that i could figure out how were made like: print, UnitBuffName, cdRemains, IsSpellUsable etc. But i can not for the life of me guess what the code is for IsSpellKnown. I need to have this function in order to be able to use spell id's instead of spell names (thereby making it possible to make my fightclass multi-language supported). Does the WRobot api have a way to determine spell by ID instead of name? Would be easy if i only needed to be level 70 spells. But if i want to make it available for leveling, i'd need a way to check if a spell is known. Example: public Spell SerpentSting = new Spell("Serpent Sting"); If i wanted to add this as a spell ID then i could do this in Lua: SerpentSting = "false" if SpellIsKnown(27016) then -- Rank 10 SerpentSting = 27016 elseif SpellIsKnown(25295) then -- Rank 9 SerpentSting = 25295 end if not SerpentSting == "false" then CastSpellByName (GetSpellInfo(SerpentSting) end With this i can define spellname id based on what rank you have available. :) Link to comment https://wrobot.eu/forums/topic/7729-global-lua-api/ Share on other sites More sharing options...
Matenia 629 Posted November 19, 2017 Share Posted November 19, 2017 IsSpellKnown is super easy. Just call GetSpellInfo("spellName") It will only give you shit from your spell book. Or here's my vanilla implementation: public bool IsKnown() { //not a great runtime solution, but spellbook should get updated on newly learned spells //this SHOULD check if we have the rank available string luaString = @" local i = 1 while true do local spellName, spellRank = GetSpellName(i, BOOKTYPE_SPELL); if not spellName then break; end -- use spellName and spellRank here if(spellName == ""{0}"" and spellRank == ""Rank {1}"") then --DEFAULT_CHAT_FRAME:AddMessage( spellName .. '(' .. spellRank .. ')' ); return true; end i = i + 1; end return false;"; return Lua.LuaDoString<bool>(string.Format(luaString, Name, GetRank())); } Link to comment https://wrobot.eu/forums/topic/7729-global-lua-api/#findComment-35330 Share on other sites More sharing options...
Ordush 185 Posted November 19, 2017 Author Share Posted November 19, 2017 (edited) 14 minutes ago, Matenia said: IsSpellKnown is super easy. Just call GetSpellInfo("spellName") It will only give you shit from your spell book. Or here's my vanilla implementation: public bool IsKnown() { //not a great runtime solution, but spellbook should get updated on newly learned spells //this SHOULD check if we have the rank available string luaString = @" local i = 1 while true do local spellName, spellRank = GetSpellName(i, BOOKTYPE_SPELL); if not spellName then break; end -- use spellName and spellRank here if(spellName == ""{0}"" and spellRank == ""Rank {1}"") then --DEFAULT_CHAT_FRAME:AddMessage( spellName .. '(' .. spellRank .. ')' ); return true; end i = i + 1; end return false;"; return Lua.LuaDoString<bool>(string.Format(luaString, Name, GetRank())); } Yeah, but the problem is that you can do GetSpellInfo and get the info on a spell even if you don't know the spell. Edited November 19, 2017 by Ordush Link to comment https://wrobot.eu/forums/topic/7729-global-lua-api/#findComment-35332 Share on other sites More sharing options...
Matenia 629 Posted November 19, 2017 Share Posted November 19, 2017 Not in TBC it doesn't. If you use the name, NOT THE ID, then it will ONLY return info if you have it in your spell book. I've been using this for months... Link to comment https://wrobot.eu/forums/topic/7729-global-lua-api/#findComment-35337 Share on other sites More sharing options...
Ordush 185 Posted November 19, 2017 Author Share Posted November 19, 2017 (edited) 7 minutes ago, Matenia said: Not in TBC it doesn't. If you use the name, NOT THE ID, then it will ONLY return info if you have it in your spell book. I've been using this for months... Yeah, and that takes me nowhere, when i want to make my fightclase multi-language. :) My point was exactly that i wanted to use ID instead of name, so that example french players don't have to use English client. :) try and check id 1234, just an example. :) But thank you for the tip mate! :) Edited November 19, 2017 by Ordush Link to comment https://wrobot.eu/forums/topic/7729-global-lua-api/#findComment-35338 Share on other sites More sharing options...
Matenia 629 Posted November 19, 2017 Share Posted November 19, 2017 6 minutes ago, Ordush said: Yeah, and that takes me nowhere, when i want to make my fightclase multi-language. :) My point was exactly that i wanted to use ID instead of name, so that example french players don't have to use English client. :) try and check id 1234, just an example. :) But thank you for the tip mate! :) So basically: return GetSpellInfo(GetSpelInfo(1234)) ~= nil; get name by id, then use name to check if it's in spell book... Ordush 1 Link to comment https://wrobot.eu/forums/topic/7729-global-lua-api/#findComment-35340 Share on other sites More sharing options...
Ordush 185 Posted November 19, 2017 Author Share Posted November 19, 2017 4 minutes ago, Matenia said: So basically: return GetSpellInfo(GetSpelInfo(1234)) ~= nil; get name by id, then use name to check if it's in spell book... LOL Doh... Why did i not think of that? Thank you mate! much appreciated! <3 Link to comment https://wrobot.eu/forums/topic/7729-global-lua-api/#findComment-35341 Share on other sites More sharing options...
Ordush 185 Posted November 20, 2017 Author Share Posted November 20, 2017 @Matenia I figured why this method doesn't work well. It sure does work cross language, but you won't be able to rank check with this. If you have rank 1 of an ability, it will never do nil no matter what ID you use, be it rank 1 or rank 5 of a spell. Reason this has a consequence: Say i want it to buy mats for buffs. Then i won't be able to specify what mats to buy based on what rank is available. I could go the long way and check what rank the player has as max (which this will always post if it's not nil). Then set to nil if the known rank (google) for a spell does not mach the rank of the players spell. However, it would be a lot easier if i had the wow api function from wotlk+. So if anyone knows a way to get the functions from the wow api. (the whole code) please let me know. :) Link to comment https://wrobot.eu/forums/topic/7729-global-lua-api/#findComment-35401 Share on other sites More sharing options...
Icesythe7 0 Posted November 20, 2017 Share Posted November 20, 2017 So you are wanting to input a spell id and return the max rank of that spell if it isknown or nil if it is not known...am i understanding correctly? Link to comment https://wrobot.eu/forums/topic/7729-global-lua-api/#findComment-35404 Share on other sites More sharing options...
Ordush 185 Posted November 20, 2017 Author Share Posted November 20, 2017 (edited) 5 minutes ago, Icesythe7 said: So you are wanting to input a spell id and return the max rank of that spell if it isknown or nil if it is not known...am i understanding correctly? I want to input spell id, then i want it to return true if the player has that spell and nil if the player doesn't. If you do GetSpellInfo("AnyID") it will always just post the info in that table no matter if you know the spell or not. If you do GetSpellInfo(GetSpellInfo("AnyID")) then IF you know the spell (no matter what rank you have) it will post the table for the highest rank of the spell that spell in your spellbook. (Because you basicly search for name instead of ID). What is to check SpellID if player has that spell WITH the rank that follows with the ID then return true else return nil, even if it has the Spell but in a lower rank. Hope it makes sense. :) So in short, not the max rank the player has, that's easy just do GetSpellInfo(GetSpellInfo("AnyID")) I want to check for the rank that comes with the ID. Edited November 20, 2017 by Ordush Link to comment https://wrobot.eu/forums/topic/7729-global-lua-api/#findComment-35407 Share on other sites More sharing options...
Icesythe7 0 Posted November 20, 2017 Share Posted November 20, 2017 So you simply want a function like this if (HasSpell(56342)) { //dosomething Link to comment https://wrobot.eu/forums/topic/7729-global-lua-api/#findComment-35410 Share on other sites More sharing options...
Ordush 185 Posted November 20, 2017 Author Share Posted November 20, 2017 Just now, Icesythe7 said: So you simply want a function like this if (HasSpell(56342)) { //dosomething Here is EXACTLY what i want to do using my old PQR shadow priest (WOTLK) example. :) -- Prayer of Fortitude local POFortitude = false local POFMat = false -- Rank 4 if IsSpellKnown(48162) then POFortitude = 48162 POFMat = "DevoutCandles" -- Rank 3 elseif IsSpellKnown(25392) then POFortitude = 25392 POFMat = "SacredCandles" -- Rank 2 elseif IsSpellKnown(21564) then POFortitude = 21564 POFMat = "SacredCandles" -- Rank 1 elseif IsSpellKnown(21562) then POFortitude = 21562 POFMat = "HolyCandles" end So i want to check if the player has a spell in a certain rank by ID As you can see here: If the player doesn't have Prayer of Fortitude at all, it will make POFortitude false If the player does have Prayer of Fortitude rank 2 it will make POFortitude that rank Then later when i tell it to cast spell by ID (I cast by ID to make it multi-lang). It will check the bag if it has mat based on POFMat >5 (So it only casts prayer if it has more than 5 mats). Link to comment https://wrobot.eu/forums/topic/7729-global-lua-api/#findComment-35412 Share on other sites More sharing options...
Icesythe7 0 Posted November 20, 2017 Share Posted November 20, 2017 now i understand give me a second Link to comment https://wrobot.eu/forums/topic/7729-global-lua-api/#findComment-35413 Share on other sites More sharing options...
Icesythe7 0 Posted November 20, 2017 Share Posted November 20, 2017 9 minutes ago, Ordush said: Here is EXACTLY what i want to do using my old PQR shadow priest (WOTLK) example. :) -- Prayer of Fortitude local POFortitude = false local POFMat = false -- Rank 4 if IsSpellKnown(48162) then POFortitude = 48162 POFMat = "DevoutCandles" -- Rank 3 elseif IsSpellKnown(25392) then POFortitude = 25392 POFMat = "SacredCandles" -- Rank 2 elseif IsSpellKnown(21564) then POFortitude = 21564 POFMat = "SacredCandles" -- Rank 1 elseif IsSpellKnown(21562) then POFortitude = 21562 POFMat = "HolyCandles" end So i want to check if the player has a spell in a certain rank by ID As you can see here: If the player doesn't have Prayer of Fortitude at all, it will make POFortitude false If the player does have Prayer of Fortitude rank 2 it will make POFortitude that rank Then later when i tell it to cast spell by ID (I cast by ID to make it multi-lang). It will check the bag if it has mat based on POFMat >5 (So it only casts prayer if it has more than 5 mats). public bool HasSpellId(int spellId) { return SpellManager.SpellBook().Any(spell => spell.Id == spellId); } The smart way to do this is make an array of the shit u wanna check and checkit onload and whatever is to add it to a new array and use that new array for what u need to do to minimize the loop thi does, then register an lua event ontrained spell(w/e the name is) and anytime it called update ur local array Link to comment https://wrobot.eu/forums/topic/7729-global-lua-api/#findComment-35414 Share on other sites More sharing options...
Ordush 185 Posted November 20, 2017 Author Share Posted November 20, 2017 1 minute ago, Icesythe7 said: public bool HasSpellId(int spellId) { return SpellManager.SpellBook().Any(spell => spell.Id == spellId); } Awesome mate, so it checks the spellbook if it has a spell with given spellid. But this is in C#. Is there any way to do this in Lua? (My druid is not made in CS): =/ I know it can be done in Lua, because blizzard themselves implemented it in WOTLK with the IsSpellKnown Function Which is the one i'm trying to get. :) Link to comment https://wrobot.eu/forums/topic/7729-global-lua-api/#findComment-35415 Share on other sites More sharing options...
iMod 99 Posted November 20, 2017 Share Posted November 20, 2017 (edited) Spell spellName = new Spell(NameOrID); if(spellName.KnownSpell()) { // Do something.... } Edited November 20, 2017 by iMod Link to comment https://wrobot.eu/forums/topic/7729-global-lua-api/#findComment-35416 Share on other sites More sharing options...
Icesythe7 0 Posted November 20, 2017 Share Posted November 20, 2017 1 minute ago, Ordush said: Awesome mate, so it checks the spellbook if it has a spell with given spellid. But this is in C#. Is there any way to do this in Lua? (My druid is not made in CS): =/ I know it can be done in Lua, because blizzard themselves implemented it in WOTLK with the IsSpellKnown Function Which is the one i'm trying to get. :) Oh didnt know u needed it in lua um let me lookup the api on that if i can do it in vanilla i can do it in tbc im sure Link to comment https://wrobot.eu/forums/topic/7729-global-lua-api/#findComment-35417 Share on other sites More sharing options...
Icesythe7 0 Posted November 20, 2017 Share Posted November 20, 2017 would it help u any if i could return the name and rank of only known spells? Link to comment https://wrobot.eu/forums/topic/7729-global-lua-api/#findComment-35428 Share on other sites More sharing options...
Ordush 185 Posted November 20, 2017 Author Share Posted November 20, 2017 5 minutes ago, Icesythe7 said: would it help u any if i could return the name and rank of only known spells? Hehe, that's what i wrote above. Also easy local name, rank = GetSpellInfo("spellID") The thing is, i'm a pretty advanced Lua programmer, but the IsSpellKnown is function is what is tricking me. I could make it myself and manually add every spellid, then compare the given rank by ID with rank from GetSpellInfo. This will take ages, which is why i'm trying to find out how Blizz did it. :) Link to comment https://wrobot.eu/forums/topic/7729-global-lua-api/#findComment-35429 Share on other sites More sharing options...
Icesythe7 0 Posted November 20, 2017 Share Posted November 20, 2017 No i mean i can simply return u a table containing only "known" spell ranks and names but not the id Link to comment https://wrobot.eu/forums/topic/7729-global-lua-api/#findComment-35430 Share on other sites More sharing options...
Ordush 185 Posted November 20, 2017 Author Share Posted November 20, 2017 Hmm, i guess i could do that to compare the content with the spell id with a foreach, but that would mean i'd have to assign a rank to all id's which is the same problem as before :/ Link to comment https://wrobot.eu/forums/topic/7729-global-lua-api/#findComment-35432 Share on other sites More sharing options...
Icesythe7 0 Posted November 20, 2017 Share Posted November 20, 2017 What are u doing by the way executing an entire lua script in c# in a loop? Link to comment https://wrobot.eu/forums/topic/7729-global-lua-api/#findComment-35445 Share on other sites More sharing options...
Ordush 185 Posted November 20, 2017 Author Share Posted November 20, 2017 54 minutes ago, Icesythe7 said: What are u doing by the way executing an entire lua script in c# in a loop? Well, not exactly. :) Some of it is looped, if it needs to be. Where others aren't. :) Link to comment https://wrobot.eu/forums/topic/7729-global-lua-api/#findComment-35451 Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now