WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   AddOn Help/Support (https://www.wowinterface.com/forums/forumdisplay.php?f=3)
-   -   Please Help Button for /command`s (https://www.wowinterface.com/forums/showthread.php?t=57636)

BloodDragon 10-27-19 09:24 AM

Please Help Button for /command`s
 
1 Attachment(s)
Hi,

i have a little Problem, i make a Button with a /command, like this

Lua Code:
  1. [b]QC.b=Add_Button(L["PullTimer"],"/pull 6",W,0,QC.F,{0.7,0.7,0.2,1});W=W+50;[/b]


In the game now i press the button PullTimer.
Now it is in chat /pull 6 and I would have to confirm with Enter. But I want if I click the button PullTimer the command /pull 6 is executed automatically.

Iam new on lua so i hope everyone can help me with it.
It would be very very friendly if someone could help me.

Sorry for my Bad English.

Xrystal 10-27-19 11:46 AM

I assume /pull x is simply a text display alerting the group when the pull will start ? If so maybe what you need to use instead is ..

DEFAULT_CHAT_FRAME:AddMessage(text,r,g,b)

We use this in nUI to display messages automatically such as for errors and information.


However, if /pull x actually does something in the game play then unless there is a macro or script function equivalent there is unlikely to be an automated equivalent.

BloodDragon 10-27-19 11:57 AM

I trying to execute the slash command, rather than just put the text in the editbox.

The commands are:
/roll
/readycheck
/pull 6

Kanegasi 10-27-19 12:45 PM

If you're trying to call DBM's pull command from a button, you can use their slash function directly:

This will call the default 10 seconds:
SlashCmdList.DEADLYBOSSMODSPULL()
This will call the 6 seconds you want:
SlashCmdList.DEADLYBOSSMODSPULL(6)
Same with /break as well:
SlashCmdList.DEADLYBOSSMODSBREAK()
(break's number is in minutes)

BloodDragon 10-27-19 12:51 PM

This is my Button:
Lua Code:
  1. QC.b=Add_Button(L["PullTimer"],"/pull 6",W,0,QC.F,{0.7,0.7,0.2,1});W=W+50;

So i must insert your command here?:
Lua Code:
  1. QC.b=Add_Button(L["PullTimer"],"SlashCmdList.DEADLYBOSSMODSPULL(6)",W,0,QC.F,{0.7,0.7,0.2,1});W=W+50;

I'm really a big beginner in the .lua area.

I think my main.lua is not bad. but I'm not quite there :).

Kanegasi 10-27-19 01:05 PM

Ahh, I see what you're doing there. Your buttons only open chat. Replace your OnClick handler with this:

Lua Code:
  1. Button:SetScript("OnClick", function()
  2.     if command=="/pull 6" then
  3.         SlashCmdList.DEADLYBOSSMODSPULL(6)
  4.     else
  5.         Open_chat(command)
  6.     end
  7. end)

This is a simple way to do it. You can also do this for readycheck and roll as well, which are DoReadyCheck() and RandomRoll("1","100").

BloodDragon 10-27-19 01:23 PM

Ok Pulltimer works very nice now thx a lot.

Lua Code:
  1. Button:SetScript("OnClick", function()
  2.         if command=="/pull 6" then
  3.             SlashCmdList.DEADLYBOSSMODSPULL(6)
  4.         else
  5.             Open_chat(command)
  6.         end
  7.     end)
  8.     return Button;

So now i must add the the other commands
on the same place like:

Lua Code:
  1. Button:SetScript("OnClick", function()
  2.         if command=="/pull 6" then
  3.             SlashCmdList.DEADLYBOSSMODSPULL(6)
  4.         else
  5.         if command=="/readycheck" then
  6.             SlashCmdList.DoReadyCheck()
  7.         else
  8.             Open_chat(command)
  9.         end
  10.     end)
  11.     return Button;

But this dont work.

Kanegasi 10-27-19 01:31 PM

It's just DoReadyCheck(), no SlashCmdList for that. The colored functions I mentioned are exactly how they are. You're also missing "elseif".

Lua Code:
  1. Button:SetScript("OnClick", function()
  2.     if command=="/pull 6" then
  3.         SlashCmdList.DEADLYBOSSMODSPULL(6)
  4.     elseif command=="/readycheck" then
  5.         DoReadyCheck()
  6.     else
  7.         Open_chat(command)
  8.     end
  9. end)

BloodDragon 10-27-19 02:12 PM

Ahhhh ok i understand very very thank you i love you for the help.


All times are GMT -6. The time now is 05:38 AM.

vBulletin © 2020, Jelsoft Enterprises Ltd
© 2004 - 2020 MMOUI