Skip to content
Trevor Martin edited this page Apr 8, 2017 · 34 revisions

print

print text [x y [color [fixed] ] ] -> text width

Parameters:

  • text : any string to be printed to the screen
  • x : x coordinate where to print the text
  • y : y coordinate where to print the text
  • color : the color to use to draw the text to the screen
  • fixed : a flag indicating whether to fix the width of the characters, by default is not fixed

Output:

  • text width : returns the width of the text in pixels.

Description:

This will simply print text to the screen using the font defined in config.

  • To use a custom rastered font, check out font.
  • To print to the console, check out trace.

Printing Centered

--Printing Centered Text by nesbox
local string="my perfectly centered text"
local width=print(string,0,-6)
print(string,(240-width)//2,(136-6)//2)

##Example

-- title:  print demo
-- author: Filippo
-- desc:   print matrix
-- script: lua
-- input:  gamepad
-- pal:00000000ff0000e50000cc0000b200009900007f00006600004c00003300001900000000b2ffb2ccffcce5ffe5ffffff

msg="FNORD                      "
t=0
function TIC()
 cls()
 c=1
 for x=0,29 do
  for y=0,16 do
   c=(c+1)%#msg
   l=(c-math.floor(t))%#msg
   print(msg:sub(l,l),x*8,y*8,y%12)
  end  
 end 
 t=t+0.15
end

Example 2

-- title:  print demo 2
-- author: Vadim
-- desc:   print text perfectly centered
-- script: lua
-- input:  gamepad

cls()
local string="my perfectly centered text"
local width=print(string,0,-6)
print(string,(240-width)//2,(136-6)//2)

function TIC()end
Clone this wiki locally