Page 1 of 2
1
2
LastLast
  1. #1

    [HowTo] Make a code snippet into an addon in twelve easy steps

    Most people that have requested a certain thing made have probably experienced this. Somebody that has coding skills has provided you with a snippet of LUA code that does something automatically (for example code that says something every time you successfully cast a spell). One possibility of getting this to run every time you reload your UI or log on would be, of course, to make a macro with /run and press that manually.
    What I am going to show you here are twelve easy steps that every computer newbie can execute and that will cause the code to be executed automatically.

    • Open Windows Explorer or an equivalent program.
    • Browse to your AddOns directory. Its path is <Your WoW Install Directory>\Interface\AddOns (ex.: C:\Games\World of Warcraft\Interface\AddOns).
    • Create a new folder. For the sake of recognizing it later, give it a name related to what the code should do (ex.: InnervateSay). This name needs to be unique within your WoW directory and may not contain spaces (at least I think so).
    • Open Notepad or a similar editor that uses plain text. Do not use Microsoft Word!
    • Copy the .TOC file contents from the bottom of this post into notepad. Replace YourFolderName with whatever your addon is called.
    • Open the File menu and choose Save As... .
    • Set the file format to "All Files (*.*)"
    • Save the file as YourFolderName.toc - this needs to match the name you gave your folder above or the addon will not load.
    • Create another new text document in notepad.
    • Paste the code you want to run into this file
    • Save the file as YourFolderName.lua - the name needs to match what you entered in your TOC file above. Don't forget to set file format to "All Files (*.*)"!
    • Done! Restart WoW and your new addon should show in the AddOns list on your character select screen.

    TOC file for copy+paste:
    Code:
    ## Interface: 60000
    ## Title: MyAddonTitle
    YourFolderName.lua
    If you provide a code snippet that you want the user to execute, please feel free to link to this thread.

    Update 13-10-10: Toc changed to 40000.
    Update 38-04-11: Toc changed to 40100.
    Update 30-06-11: Toc changed to 40200.
    Update 05-12-11: Toc changed to 40300.
    Update 28-08-12: Toc changed to 50001.
    Update 05-02-14: Toc changed to 50400.
    Update 05-11-14: Toc changed to 60000
    Last edited by Treeston; 2014-11-05 at 03:10 PM.
    UI & AddOns expert | Interface & Macros moderator - My work

  2. #2

    Re: [HowTo] Make a code snippet into an addon in twelve easy steps

    thanks this will work

  3. #3
    The Patient Smartie's Avatar
    Join Date
    Feb 2008
    Location
    Devon, UK
    Posts
    223
    Works well

    Although I didn't think it worked when I first ran it as I was looking for an addon called what I named the folder, not an addon called "MyAddonTitle". My bad.

  4. #4
    Just discovered this, very cool. Thanks!!!

  5. #5
    A old Thread, but ty.
    Quote Originally Posted by Larynx View Post
    For more overused and misunderstood terminology in MMOs, see: Pay to Win, Casual, Hardcore, Carrot on a Stick, Ganking, Trolling

  6. #6
    Hello,

    in your updates of the OP, I see you change the TOC number for 'Interface'.

    Am I correct when I notice that these numbers are the patch numbers, with extra zeros?

    4.0 becomes 40000
    4.1 becomes 40100
    4.2 becomes 40200
    so if you say 4.2 = X.Y, u get:
    X0Y00

    Would be nice to know this if I want to update my own mini addon

  7. #7
    Scarab Lord Taryble's Avatar
    Join Date
    Aug 2008
    Location
    Texas
    Posts
    4,038
    Correct, Pathemeus.

    Patches like "4.2.2" generally use the major patch number for Interface Version, but in the past they've also used the minor numbers (back in BC was the last time I saw this, though).
    We have done the impossible, and that makes us mighty. - Sgt. Malcolm "Mal" Reynolds, Battle of Serenity Valley

  8. #8
    Generally, any change to the API will prompt an update in the Interface version - as most major patches change something in the API, they can be generally assumed to have a new a UI version, too.

    The API number is made up of XYYZZ for patch X.Y.Z (as it hasn't been unheard of for the second patch number to be >= 10, see patch 1.12 for example).
    UI & AddOns expert | Interface & Macros moderator - My work

  9. #9
    Dreadlord
    Join Date
    May 2009
    Location
    Helsinki, Finland
    Posts
    772
    Alright well my request is simple, I want an addon that removes the Gryphons on the default UI.
    I have my scripts for it, I've made a .toc file and the only thing I think I'm missing is the luascript.

    Here's the code I'm using on the .toc;
    Code:
    ## Interface: 40200
    ## Title : HideGryphons
    ## Notes: This AddOn does nothing but remove gryphons when you log on.
    ## Author: Trixzy
    HideGryphons.lua
    And here is the script to remove them ingame;
    /run MainMenuBarLeftEndCap:Hide(); MainMenuBarRightEndCap:Hide()

    So basically all I need now is a luascript that executes that /run command after each log-in and reload of ui.

  10. #10
    Quote Originally Posted by Trixzy View Post
    /run MainMenuBarLeftEndCap:Hide(); MainMenuBarRightEndCap:Hide()

    So basically all I need now is a luascript that executes that /run command after each log-in and reload of ui.
    Cut off the /run and you're done. Oh hey, that rhymes.
    Constantly owns Treeston with unpredictability.

  11. #11
    Dreadlord
    Join Date
    May 2009
    Location
    Helsinki, Finland
    Posts
    772
    Quote Originally Posted by Meorawr View Post
    Cut off the /run and you're done. Oh hey, that rhymes.
    so the lua will be empty but say "MainMenuBarLeftEndCap:Hide(); MainMenuBarRightEndCap:Hide()" on line1?
    Or do I have to

    Function
    MainMenuBarLeftEndCap:Hide(); MainMenuBarRightEndCap:Hide()
    end
    ?

  12. #12
    Code:
    MainMenuBarLeftEndCap:Hide(); MainMenuBarRightEndCap:Hide()
    That.
    Constantly owns Treeston with unpredictability.

  13. #13
    Dreadlord
    Join Date
    May 2009
    Location
    Helsinki, Finland
    Posts
    772
    Quote Originally Posted by Meorawr View Post
    Code:
    MainMenuBarLeftEndCap:Hide(); MainMenuBarRightEndCap:Hide()
    That.
    Well that was simple lol, thanks

  14. #14
    The Patient Hoopajoo's Avatar
    Join Date
    Jan 2011
    Location
    The Boonies!
    Posts
    299
    I was hoping someone could help me out. A forum member was kind enough to link me to this page and I followed the list to the letter. It sort of worked. Here's what I used for the lua:

    Code:
    PlayerFrame:SetScript("OnEvent", nil)
    PlayerFrame:Hide()
    TargetFrame:SetScript("OnEvent", nil)
    TargetFrame:Hide()
    The goal was to hide the default blizz player and target frames because for some reason, they were hanging around despite using a UI that doesn't need them. At first I used that script in a macro in-game, I'd hit it upon logging in to get rid of them or just hit it whenever an event triggered them. What happens now is that upon logging in, the default target frame is gone, but the player frame still persists. So I was hoping someone could help me figure that out.

  15. #15
    Code:
    PlayerFrame:SetScript("OnShow",PlayerFrame.Hide)
    PlayerFrame:Hide()
    TargetFrame:SetScript("OnShow",TargetFrame.Hide)
    TargetFrame:Hide()
    UI & AddOns expert | Interface & Macros moderator - My work

  16. #16
    The Patient Hoopajoo's Avatar
    Join Date
    Jan 2011
    Location
    The Boonies!
    Posts
    299
    Quote Originally Posted by Treeston View Post
    Code:
    PlayerFrame:SetScript("OnShow",PlayerFrame.Hide)
    PlayerFrame:Hide()
    TargetFrame:SetScript("OnShow",TargetFrame.Hide)
    TargetFrame:Hide()
    Works perfectly, thank you so much!

  17. #17
    Scarab Lord Taryble's Avatar
    Join Date
    Aug 2008
    Location
    Texas
    Posts
    4,038
    An addon author over at WoWInterface recently developed a web site to automate this - http://addon.ziuo.net/

    You can just type what you want to name your addon into the first box, paste the code into the second box, and click the button that says "Create my addon and give me my files!" - it'll make the addon, zip it all up, and your browser will download it like any other addon. :>
    We have done the impossible, and that makes us mighty. - Sgt. Malcolm "Mal" Reynolds, Battle of Serenity Valley

  18. #18
    The Patient Hoopajoo's Avatar
    Join Date
    Jan 2011
    Location
    The Boonies!
    Posts
    299
    Quote Originally Posted by Taryble View Post
    An addon author over at WoWInterface recently developed a web site to automate this - http://addon.ziuo.net/

    You can just type what you want to name your addon into the first box, paste the code into the second box, and click the button that says "Create my addon and give me my files!" - it'll make the addon, zip it all up, and your browser will download it like any other addon. :>
    This is also great to know! Thanks for the heads up, I'm bookmarking that thing right now lol

  19. #19
    New interface in the TOC file?

  20. #20
    Nope, only major patches (4.1, 4.2, 4.3) update the TOC tag.
    UI & AddOns expert | Interface & Macros moderator - My work

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •