Page 1 of 2
1
2
LastLast
  1. #1
    Deleted

    [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: 60200
    ## 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.
    Update 18-10-15: Toc changed to 60200.
    Last edited by lawomous; 2015-10-18 at 02:54 PM.

  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
    15+ Year Old Account
    Join Date
    Feb 2008
    Location
    Devon, UK
    Posts
    238
    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
    Deleted
    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

  6. #6
    Scarab Lord
    15+ Year Old Account
    Join Date
    Aug 2008
    Location
    Texas
    Posts
    4,040
    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).

  7. #7
    Deleted
    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).

  8. #8
    Dreadlord
    10+ Year Old Account
    Join Date
    May 2009
    Location
    Helsinki, Finland
    Posts
    812
    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.

  9. #9
    Dreadlord
    10+ Year Old Account
    Join Date
    May 2009
    Location
    Helsinki, Finland
    Posts
    812
    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
    ?

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

  11. #11
    The Patient Hoopajoo's Avatar
    10+ Year Old Account
    Join Date
    Jan 2011
    Location
    The Boonies!
    Posts
    305
    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.

  12. #12
    Deleted
    Code:
    PlayerFrame:SetScript("OnShow",PlayerFrame.Hide)
    PlayerFrame:Hide()
    TargetFrame:SetScript("OnShow",TargetFrame.Hide)
    TargetFrame:Hide()

  13. #13
    The Patient Hoopajoo's Avatar
    10+ Year Old Account
    Join Date
    Jan 2011
    Location
    The Boonies!
    Posts
    305
    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!

  14. #14
    Scarab Lord
    15+ Year Old Account
    Join Date
    Aug 2008
    Location
    Texas
    Posts
    4,040
    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. :>

  15. #15
    The Patient Hoopajoo's Avatar
    10+ Year Old Account
    Join Date
    Jan 2011
    Location
    The Boonies!
    Posts
    305
    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

  16. #16
    New interface in the TOC file?

  17. #17
    Deleted
    Nope, only major patches (4.1, 4.2, 4.3) update the TOC tag.

  18. #18
    Is there any where to learn more about addon making this interests me and I would like to further my skills in this area any advice is greatly appreciated

  19. #19
    Deleted
    Would love some help here, can't get my camera distance macro working in an addon.
    Code:
    /console CameraDistanceMaxfactor 3
    That's the macro I use. Would be great if this could be included in the same addon.
    Code:
    /run CompactRaidFrameManager:UnregisterAllEvents() CompactRaidFrameManager:Hide() CompactRaidFrameContainer:UnregisterAllEvents() CompactRaidFrameContainer:Hide()
    Would be awesome if someone could help me with this!

  20. #20
    Deleted
    Code:
    CompactRaidFrameManager:UnregisterAllEvents() CompactRaidFrameManager:Hide() CompactRaidFrameContainer:UnregisterAllEvents() CompactRaidFrameContainer:Hide()
    SetCVar("cameraDistanceMaxFactor",3)

Posting Permissions

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