Thread Tools Display Modes
05-21-08, 02:53 PM   #1
Thunder12
An Aku'mai Servant
 
Thunder12's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 36
Slash Commands

Hi i'm new with coding, the small amount that i have learnt is just through trial and error and from looking at other people's addons. I have recently made my first ui mod, now before you flame me for the shoddy coding, does someone think they could help me. Is there anything that i am doing in the code that is not needed? Basically i want to clean it up abit, the addon does everything that i want but since i have released it to the public, i want to make it a little bit more user friendly, i.e have slash commands to enable and disable parts of the mod. I would like to have slash commands for enabling and disabling the movement of the minimap and party frames and i havent a clue where to start. TY for any help given. Addon link:

http://www.wowinterface.com/download...p?id=8964#info

Mafa/Thunder
  Reply With Quote
05-21-08, 03:46 PM   #2
hipjipp
A Cliff Giant
 
hipjipp's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 79
i tried to clean up the code, didn't manage with alot but it should clean atleast half the file.. as for slash commands, i'm to lazy to write those atm so i'll drop that to someone else..

code i fixed; (I left the minimap code as is)
Code:
--unitframes
PlayerFrame:ClearAllPoints()
PlayerFrame:SetPoint("CENTER", UIParent, "CENTER", -100, -200)

TargetFrame:ClearAllPoints()
TargetFrame:SetPoint("CENTER", UIParent, "CENTER", 100, -200)

-- Party
PartyMemberFrame1:ClearAllPoints()
PartyMemberFrame1:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", 0, 15)

PartyMemberFrame2:ClearAllPoints()
PartyMemberFrame2:SetPoint("BOTTOMLEFT", PartyMemberFrame1, "BOTTOMLEFT", 0, 15)

PartyMemberFrame3:ClearAllPoints()
PartyMemberFrame3:SetPoint("BOTTOMLEFT", PartyMemberFrame2, "BOTTOMLEFT", 0, 15)

PartyMemberFrame4:ClearAllPoints()
PartyMemberFrame4:SetPoint("BOTTOMLEFT", PartyMemberFrame3, "BOTTOMLEFT", 0, 15)

-- Pet
PetActionButton1:ClearAllPoints()
PetActionButton1:SetPoint("CENTER", MultiBarLeftButton3, "CENTER", 0, 45)
PetActionBarFrame:SetScale(0.9)

-- Horisontal bars.
local button, button2;

for i = 1, 12, 1 do
    button = _G["MultiBarRightButton"..i];
    button:ClearAllPoints();
    if ( i > 1 ) then
        button:SetPoint("LEFT",_G["MultiBarRightButton"..(i-1)],"RIGHT",5,0); -- following buttons
    else
        button:SetPoint("CENTER", MultiBarBottomRightButton1, "CENTER", 0, 5); -- Initial button
    end
end

for i = 1, 12, 1 do
    button2 = _G["MultiBarLeftButton"..i];
    button2:ClearAllPoints();
    if ( i > 1 ) then
        button2:SetPoint("LEFT",_G["MultiBarLeftButton"..(i-1)],"RIGHT",5,0); -- following buttons
    else
        button2:SetPoint("CENTER", MultiBarBottomLeftButton1, "CENTER", 0, 5); -- Initial button
    end
end
Edit: Forgot to credit Lolzen for the horisontal code. Thanks for your lolbars! (yes, i know the name is a bit random :P)

Last edited by hipjipp : 05-21-08 at 03:48 PM. Reason: Credits
  Reply With Quote
05-21-08, 03:59 PM   #3
Thunder12
An Aku'mai Servant
 
Thunder12's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 36
Thanks so much, as you could probably tell when looking at my code, i only know the bear essentials of LUA ty for ure help. This is certainly a start. Now those dreaded slash commands :P
  Reply With Quote
05-21-08, 04:08 PM   #4
hipjipp
A Cliff Giant
 
hipjipp's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 79
basically, so do i. but i bought the WoW Programming book and coming along nicely with it and reading other peoples code. Since it's very simple most people can learn it in a flash. Feel free to check out my addon HBarhide and see if it hides the right and left bars aswell since they are now hooked to the bottom left and right bars. I'm to lazy to do this myself atm so i'd be delighted if you did. =)
  Reply With Quote
05-21-08, 04:17 PM   #5
Thunder12
An Aku'mai Servant
 
Thunder12's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 36
ok i will check that out later, ty for ure help. Now i must sleep lol.

Mafa
  Reply With Quote
05-22-08, 11:42 AM   #6
Thunder12
An Aku'mai Servant
 
Thunder12's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 36
ure addon is good but what i am looking for is the ability to enable and disable parts of my mod, not hide or show them. ive added your code and added some more myself (buff bars now nudged to the right and tooltips located in top left) I managed to move buff bar but how would i move debuff bar? ty

Mafa
  Reply With Quote
05-22-08, 12:34 PM   #7
hipjipp
A Cliff Giant
 
hipjipp's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 79
ure addon is good but what i am looking for is the ability to enable and disable parts of my mod, not hide or show them.
I just meant for you to try to check if it hides the right and left bars aswell when moving the mainmenubar off the screen. Glad you could use the code anyway.. :P
  Reply With Quote
05-22-08, 12:38 PM   #8
Thunder12
An Aku'mai Servant
 
Thunder12's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 36
o ok ill check that for u
  Reply With Quote
05-22-08, 12:46 PM   #9
Thunder12
An Aku'mai Servant
 
Thunder12's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 36
well it works, it hides all the bars, everything. When i show bars again the whole main menu bar apears to be nudged up however :S, were u intending this?
  Reply With Quote
05-22-08, 01:18 PM   #10
hipjipp
A Cliff Giant
 
hipjipp's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 79
yes, this was intended since i use a remade verision of lolbars (screen) and it's a bit nudged up for pure estetic glamour. Just change the code in Hbarhide to zero (0) like i commented if you want to use it with a "reset" like function.
  Reply With Quote
05-22-08, 02:51 PM   #11
Thunder12
An Aku'mai Servant
 
Thunder12's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 36
so is there any1 here that can help me with slash commands? would be much appreciated.
  Reply With Quote
05-24-08, 02:03 AM   #12
Slakah
A Molten Giant
 
Slakah's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2007
Posts: 863
http://www.wowwiki.com/Creating_a_slash_command

sooo you can do:


Code:
SLASH_MYSCRIPT1 = "/myscript";
SLASH_MYSCRIPT2 = "/mys"; -- A shortcut or alias
SlashCmdList["MYSCRIPT"] = function(cmd)


   cmd = string.lower(cmd) 


   if cmd == "enable" then
      <Do Stuff>


   elseif cmd == "disable" then
      <Do Stuff>


   else 
      DEFAULT_CHAT_FRAME:AddMessage("<Addons> Slash commands:")
      DEFAULT_CHAT_FRAME:AddMessage("enable: to enable this addon")
      DEFAULT_CHAT_FRAME:AddMessage("disable: to disable this addon")
    end
end
  Reply With Quote
05-24-08, 04:26 AM   #13
Thunder12
An Aku'mai Servant
 
Thunder12's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 36
that makes it alot more clearer, i did look at that wiki page but got confused. Thankyou
  Reply With Quote
07-12-08, 07:20 AM   #14
Thunder12
An Aku'mai Servant
 
Thunder12's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 36
right this is what ive got so far:
-- Partyframe Move
2 SLASH_MYSCRIPT = "/mem";
3 SlashCmdList["Mafariun's Elements Mover"] = function(cmd)
4
5
6 cmd = string.lower(cmd)
7
8
9 if cmd == "partyunlock" then
10 PartyMemberFrame1:SetMovable(true)
11 PartyMemberFrame1:EnableMouse(true)
12 PartyMemberFrame1:SetScript("OnMouseDown",function()
13 PartyMemberFrame1:StartMoving()
14 end)
15 PartyMemberFrame1:SetScript("OnMouseUp",function()
16 PartyMemberFrame1:StopMovingOrSizing()
17 end)
18
19 elseif cmd == "partylock" then
20 PartyMemberFrame1:SetMovable(false)
21
22 else
23 DEFAULT_CHAT_FRAME:AddMessage("<Mafariun's Elements Mover> Slash commands:")
24 DEFAULT_CHAT_FRAME:AddMessage("partyunlock: to unlock the party frames")
25 DEFAULT_CHAT_FRAME:AddMessage("partylock: to lock the party frames")
26 end
27 end
28
  Reply With Quote
07-12-08, 08:12 AM   #15
Slakah
A Molten Giant
 
Slakah's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2007
Posts: 863
Originally Posted by Thunder12 View Post
right this is what ive got so far:
Code:
SlashCmdList["Mafariun's Elements Mover"] = function(cmd)
"Mafariun's Elements Mover" Should be in caps nospaces.

Code:
SLASH_MYSCRIPT = "/mem";
MYSCRIPT should be replaced with the name of your addon again all caps nospaces and should be the same as in SlashCmdList.

The code which you have there will only be run when the you call the slash command, meaning it won't be saved accross setions.

Also for the love of good properly indent your code.

I would also suggest taking a look at the interface options frame for any options you wanna implement, it just makes it easier for the user.
  Reply With Quote
07-13-08, 04:37 PM   #16
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
What Slakah's saying is that you need
Code:
SlashCmdList["MAFURIUNSELEMENTSMOVER"] = function(cmd)
and
Code:
SLASH_MAFURIUNSELEMENTSMOVER = "/mem";
If you plan on having more options, then take a look at wowwiki and how to add your options to the new default Interface Options window, as it's easier for users to have things all in one place.

And properly indented code makes it much easier for others to read and for you to keep track of.
Code:
function foo()
     if blah then
          do something
     elseif yadayada then
          do something else
     end
end
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Slash Commands


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off