ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   General Authoring Discussion (https://www.esoui.com/forums/forumdisplay.php?f=174)
-   -   Any alternative to d()? (https://www.esoui.com/forums/showthread.php?t=1372)

lyravega 05/04/14 11:24 PM

Any alternative to d()?
 
Is there a similar command that works like d()?

Harven 05/04/14 11:56 PM

If you mean a command that add some text to chat window, then there is CHAT_SYSTEM:AddMessage()

lyravega 05/04/14 11:58 PM

Yep, thanks!

SpecialK 05/05/14 02:32 AM

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.

Seerah 05/05/14 10:29 PM

Every time you call your P() function, you create a new instance of your w() function.

zgrssd 05/19/14 02:45 AM

Quote:

Originally Posted by lyravega (Post 6955)
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.

zolan 05/23/14 03:49 PM

Quote:

Originally Posted by lyravega (Post 6955)
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

Seerah 05/23/14 06:57 PM

Or just
Lua Code:
  1. CHAT_SYSTEM:AddMessage("text")

zolan 05/29/14 04:51 PM

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

zgrssd 05/30/14 11:49 AM

Quote:

Originally Posted by zolan (Post 8759)
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.

Seerah 05/30/14 12:22 PM

But Zolan's second post is for if you want to write to a tab other than the default/1st.

zolan 05/30/14 02:54 PM

Quote:

Originally Posted by Seerah (Post 8815)
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() :D

zolan 05/30/14 02:56 PM

Quote:

Originally Posted by zgrssd (Post 8812)
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. :D But my first post definitely doesn't behave like d() as it adds a message to whatever your currently selected tab is.

Seerah 05/30/14 03:39 PM

Quote:

Originally Posted by zolan (Post 8828)
Zolan's first post is to write to whatever your currently selected tab is which, I believe, is different than CHAT_SYSTEM:AddMessage() :D

My post wasn't to correct yours, just to offer a more simplified alternative to d(). ;)

lyravega 05/30/14 04:35 PM

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

Seerah 05/30/14 05:26 PM

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. :p Good coding practices aside, only worry about optimizing when doing heavy calculations or frequent updates.

lyravega 05/30/14 05:39 PM

True, true, but still :)

zgrssd 05/31/14 04:08 AM

Quote:

Originally Posted by Seerah (Post 8839)
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

thelegendaryof 05/31/14 06:59 AM

Quote:

Originally Posted by zgrssd (Post 8845)
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!


All times are GMT -6. The time now is 02:07 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI