WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Legion Beta archived threads (https://www.wowinterface.com/forums/forumdisplay.php?f=177)
-   -   did print():format() change? (https://www.wowinterface.com/forums/showthread.php?t=53732)

myrroddin 06-18-16 12:43 PM

did print():format() change?
 
Doing some random testing on libs, trying to get the major, minor to print and see the values. Boredom~

Anyway, I got nil errors for these, yet LibStub loads the lib properly if you remove the print statements:
Code:

local major = "LibUtilities-1.0"
local minor = "$Revision: 10000 $"
local lib = LibStub:NewLibrary(major, minor)
print("major: %s"):format(major)
print("minor: %s"):format(minor)
print("minor: %d"):format(tonumber(minor))
if not lib then return end


Lombra 06-18-16 12:56 PM

I don't think print returns anything? You need to do the formatting inside.

Seerah 06-18-16 01:21 PM

Yeah.
Lua Code:
  1. print("your text here":format())

myrroddin 06-18-16 01:49 PM

Right, so I had forgotten how to use format. :eek: but that does look weird.

Thank you! Now onward to crushing boredom!! :cool::banana:

Seerah 06-18-16 03:26 PM

Then do it this way. :p

Lua Code:
  1. print(string.format("your text here - %s", token))

SDPhantom 06-19-16 11:28 PM

Quote:

Originally Posted by myrroddin (Post 315797)
Doing some random testing on libs, trying to get the major, minor to print and see the values. Boredom~

Anyway, I got nil errors for these, yet LibStub loads the lib properly if you remove the print statements:
Code:

local major = "LibUtilities-1.0"
local minor = "$Revision: 10000 $"
local lib = LibStub:NewLibrary(major, minor)
print("major: %s"):format(major)
print("minor: %s"):format(minor)
print("minor: %d"):format(tonumber(minor))
if not lib then return end


Running something like print("major: %s"):format(major) makes the ChatFrame show major: %s and throw an "attempt to index nil" error since print() doesn't return anything.





Quote:

Originally Posted by Seerah (Post 315800)
Lua Code:
  1. print("your text here":format())

This causes Lua to throw a syntax error. As a quirk, the string needs to be encased in parenthesis in order to function.


All times are GMT -6. The time now is 07:00 AM.

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