Log In  


A function for printing some accents above latin characters (138 tokens).

Cart #prac-0 | 2019-05-22 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
10

function prac(str, x,y)
 local dat={
  ["#"] = {",",  0, 2},
  ["^"] = {"^",  0,-3},
  ["`"] = {"`", -1,-3},
  ["|"] = {",",  1,-6},
  [":"] = {"\"", 0,-3},
  ["~"] = {"~",  0,-5},
  ["_"] = {"-",  0,-4},
  ["★"]={"★",  -2,-6}
 }
 local p=1
 while p <= #str do
  local c=sub(str,p,p)
  if (dat[c]) then
   print(dat[c][1],
    x+dat[c][2], y+dat[c][3]) 
    p+=1
   c=sub(str,p,p)
  end
  print(c,x,y)
  x+=4 p+=1
 end
end

Accents are inserted by including special markers in the text:

prac("cedille     #c",x,y) y+=h
prac("aigu        |e",x,y) y+=h
prac("circonflexe ^a ^e ^i ^o ^u",x,y) y+=h
prac("grave       `a `e `u",x,y) y+=h
prac("tr|ema       :e :i :u",x,y) y+=h

prac("ephasis     _e _i _u",x,y) y+=h
prac("wiggle      ~e ~i ~u",x,y) y+=h
prac("star        sp★ace",x,y);      
10


1

thank you! This will be very useful!


1

This is awesome and super helpful! Thanks for your work on this, Zep!
I made one (super tiny) addition to the code so I could change colors in the printed text.

function prac(str, x,y,z)              -- added 'z' arg for color setting
 local dat={
  ["#"] = {",",  0, 2},
  ["^"] = {"^",  0,-3},
  ["`"] = {"`", -1,-3},
  ["|"] = {",",  1,-6},
  [":"] = {"\"", 0,-3},
  ["~"] = {"~",  0,-5},
  ["_"] = {"-",  0,-4},
  ["★"]={"★",  -2,-6}
 }
 local p=1
 while p <= #str do
  local c=sub(str,p,p)
  if (dat[c]) then
   print(dat[c][1],
    x+dat[c][2], y+dat[c][3]) 
    p+=1
   c=sub(str,p,p)
  end
  print(c,x,y,z)                      -- added to output function
  x+=4 p+=1
 end
end


[Please log in to post a comment]