Thread Tools Display Modes
05/04/14, 11:24 PM   #1
lyravega
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 93
Any alternative to d()?

Is there a similar command that works like d()?
  Reply With Quote
05/04/14, 11:56 PM   #2
Harven
 
Harven's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 135
If you mean a command that add some text to chat window, then there is CHAT_SYSTEM:AddMessage()
  Reply With Quote
05/04/14, 11:58 PM   #3
lyravega
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 93
Yep, thanks!
  Reply With Quote
05/05/14, 02:32 AM   #4
SpecialK
Join Date: Apr 2014
Posts: 6
A handy way for formatted print to screen with a default color; sort of C "printf()" style.

Lua Code:
  1. local function p(...)
  2.    local function w(...) CHAT_SYSTEM:AddMessage("|cD8C1FF"..string.format(...).."|r") end
  3.    local s, r = pcall(w, ...)
  4.    if not s then error(r, 2) end
  5. end

With the pcall() to the wrapper it will catch string.format() errors and point to the exact "p()" call where it happened (like accidentally passing a "nil" value for example). With out this setup it you'll only see the context on/inside the "p()" call it's self.

Example usage:
Lua Code:
  1. p("My name is \"%s\"", GetUnitName("player"))

You could add more variations of course.
Like pass a color argument instead of a default color "local function p(color, ...)", etc.
  Reply With Quote
05/05/14, 10:29 PM   #5
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 648
Every time you call your P() function, you create a new instance of your w() function.
  Reply With Quote
05/19/14, 02:45 AM   #6
zgrssd
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 280
Originally Posted by lyravega View Post
Is there a similar command that works like d()?
If you want d() messages from before the init of chat window being shown, LibDebug can do that (it adds buffering to d() ). But right now it has minor bug with swallowed Parsing errors so it's a two edged sword for Developers till next version.
  Reply With Quote
05/23/14, 03:49 PM   #7
zolan
 
zolan's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 11
Originally Posted by lyravega View Post
Is there a similar command that works like d()?
I do this in my addons. It will output to whatever chat window screen that the user has open.

CHAT_SYSTEM["containers"][1]["currentBuffer"]:AddMessage('message here')

It, of course, won't work until after PLAYER_ACTIVATED is fired off, so that won't work if you are just trying to get debug info but is great for outputting stuff for the user.

~Zolan
  Reply With Quote
05/23/14, 06:57 PM   #8
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 648
Or just
Lua Code:
  1. CHAT_SYSTEM:AddMessage("text")
  Reply With Quote
05/29/14, 04:51 PM   #9
zolan
 
zolan's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 11
Just in case this might help someone else out.. If you know the container and tab that you want to output to you can do this:

By default there is only one container, though I think there may be addons that make other containers:

Lua Code:
  1. containerNum = 1

And the tabs seem to be numbered from left to right so the second tab would be 2:

Lua Code:
  1. tabNum = 2

Using those you can output 'Ta daaaaaaa' to the first container on the 2nd tab using the following:

Lua Code:
  1. CHAT_SYSTEM.containers[containerNum].windows[tabNum].buffer:AddMessage('Ta daaaaaaa')

I'd be glad to know if someone comes up with a better solution than this.

~Zolan
  Reply With Quote
05/30/14, 11:49 AM   #10
zgrssd
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 280
Originally Posted by zolan View Post
I'd be glad to know if someone comes up with a better solution than this.
You should propably go up and read the post of Seraah just between your two posts. Not tried them, but I think he knows what he is saying.
  Reply With Quote
05/30/14, 12:22 PM   #11
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 648
But Zolan's second post is for if you want to write to a tab other than the default/1st.
  Reply With Quote
05/30/14, 02:54 PM   #12
zolan
 
zolan's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 11
Originally Posted by Seerah View Post
But Zolan's second post is for if you want to write to a tab other than the default/1st.
Zolan's first post is to write to whatever your currently selected tab is which, I believe, is different than CHAT_SYSTEM:AddMessage()
  Reply With Quote
05/30/14, 02:56 PM   #13
zolan
 
zolan's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 11
Originally Posted by zgrssd View Post
You should propably go up and read the post of Seraah just between your two posts. Not tried them, but I think he knows what he is saying.
Serrah definitely knows what *she* is saying. But my first post definitely doesn't behave like d() as it adds a message to whatever your currently selected tab is.
  Reply With Quote
05/30/14, 03:39 PM   #14
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 648
Originally Posted by zolan View Post
Zolan's first post is to write to whatever your currently selected tab is which, I believe, is different than CHAT_SYSTEM:AddMessage()
My post wasn't to correct yours, just to offer a more simplified alternative to d().
  Reply With Quote
05/30/14, 04:35 PM   #15
lyravega
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 93
So, another question about d() then.

I looked around but wasn't able to find that post again, which kinda explained how d() works. Which is faster? Adding a message through CHAT_SYSTEM directly, or d() is just a shortcut for it (no difference in between, so to speak)?

Even 1 nano-second win is important for me :P
  Reply With Quote
05/30/14, 05:26 PM   #16
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 648
It depends on what you want printed to chat.

This is the d() function:
Lua Code:
  1. function d(...)    
  2.     for i = 1, select("#", ...) do
  3.         local value = select(i, ...)
  4.         if(type(value) == "table")
  5.         then
  6.             EmitTable(value)
  7.         else
  8.             EmitMessage(tostring (value))
  9.         end
  10.     end
  11. end

If all you want to print is simple text, then just use CHAT_SYSTEM:AddMessage("text").

Granted, you shouldn't be looking for 1 nanosecond optimizations. Good coding practices aside, only worry about optimizing when doing heavy calculations or frequent updates.
  Reply With Quote
05/30/14, 05:39 PM   #17
lyravega
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 93
True, true, but still
  Reply With Quote
05/31/14, 04:08 AM   #18
zgrssd
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 280
Originally Posted by Seerah View Post
This is the d() function:
Lua Code:
  1. function d(...)    
  2.     for i = 1, select("#", ...) do
  3.         local value = select(i, ...)
  4.         if(type(value) == "table")
  5.         then
  6.             EmitTable(value)
  7.         else
  8.             EmitMessage(tostring (value))
  9.         end
  10.     end
  11. end
Are you certain it takes any amount of parameters? When I tried to give it more then one value, it took only the first. But it could have been a fault in the override BugEater provides for d() too.

Edit: I Added the whole "how do I output to the chat" thing to the quick questions:
http://wiki.esoui.com/AddOn_Quick_Qu...to_the_chat.3F

Last edited by zgrssd : 05/31/14 at 04:18 AM.
  Reply With Quote
05/31/14, 06:59 AM   #19
thelegendaryof
 
thelegendaryof's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 161
Originally Posted by zgrssd View Post
a fault in the override BugEater provides for d() too.
Correct that 's long since on my todo list as in planning to move away from modifing d() to heavly
as in implementing buffers - I'm planning to write distinct debugging methods with filters next (as suggested).

Edit: Fixed it in 1.0 - R9- thanks Seerah for the provided info.

Cheers!

Last edited by thelegendaryof : 05/31/14 at 08:05 AM.
  Reply With Quote

ESOUI » Developer Discussions » General Authoring Discussion » Any alternative to d()?


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