Thread Tools Display Modes
06-18-16, 12:43 PM   #1
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
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
 
06-18-16, 12:56 PM   #2
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
I don't think print returns anything? You need to do the formatting inside.
__________________
Grab your sword and fight the Horde!
 
06-18-16, 01:21 PM   #3
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Yeah.
Lua Code:
  1. print("your text here":format())
__________________
"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

 
06-18-16, 01:49 PM   #4
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
Right, so I had forgotten how to use format. but that does look weird.

Thank you! Now onward to crushing boredom!!
 
06-18-16, 03:26 PM   #5
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Then do it this way.

Lua Code:
  1. print(string.format("your text here - %s", token))
__________________
"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

 
06-19-16, 11:28 PM   #6
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,313
Originally Posted by myrroddin View Post
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.





Originally Posted by Seerah View Post
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.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
 
 

WoWInterface » Site Forums » Archived Beta Forums » Legion Beta archived threads » did print():format() change?

Thread Tools
Display Modes

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