Log In  

I was working on a Chinese to English vocab program, and pinyin (The English alphabet for Chinese) uses diacritics all the time

maybe not a thing that can be used in the code, but in text variables. Having a function in the text variable like "dia" (like flr) or something. If you're having issues imaging what the would look like, here

 Print("Hello W' .. dia("o") .. "rld")


Hello Wòrld

P#45465 2017-10-25 15:20 ( Edited 2017-10-26 21:19)

Here's a function that I think will do what you want (you use it by putting the diacritic in front of the letter: ^ is upside-down but the function draws it right-side-up using pset).

function printd(s,x,y,c)
 local f=""
 for i=1,#s do
  local ss=sub(s,i,i)
  local xs=4*#f
  if ss=="'" then
   print(ss,x+xs+1,y-3,c)
  elseif ss=="`" then
   print(ss,x+xs-1,y-3,c)
  elseif ss=="-" then
   print(ss,x+xs,y-4,c)
  elseif ss=="^" then
   pset(x+xs,y-3,c)
   pset(x+xs+1,y-2,c)
   pset(x+xs+2,y-3,c)
  else
   f=f..ss
  end
 end
 print(f,x,y,c)
end

-- here's an example of how to use it
function _draw()
 cls()
 printd("m-a m'a m^a m`a ma",32,64,7)
end
P#45469 2017-10-25 20:47 ( Edited 2017-10-26 00:54)

@ianh
谢谢 ^-^

P#45483 2017-10-26 17:19 ( Edited 2017-10-26 21:19)

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-28 23:14:06 | 0.016s | Q:13