Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/lua/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Lua的海龟库-文本(字符串,int,int,int)-更改字体和文本大小?_Lua_Turtle Graphics_Zerobrane - Fatal编程技术网

Lua的海龟库-文本(字符串,int,int,int)-更改字体和文本大小?

Lua的海龟库-文本(字符串,int,int,int)-更改字体和文本大小?,lua,turtle-graphics,zerobrane,Lua,Turtle Graphics,Zerobrane,只是一个一般性的问题。使用text(“text”,0,0,0)如果可能,我将如何更改文本的字体和/或大小?我试着做一个计时器——我已经用Lua做了两三年的数学作弊(“如果我用我的iPod作为测试的计算器可以吗?”“当然可以。”“谢谢!傻笑”),现在我开始探索它的功能——通过运行循环并每秒向窗口打印文本,但是文本太小了 io.write("Enter the time in seconds that the timer will run: ") local time = io.read('*num

只是一个一般性的问题。使用
text(“text”,0,0,0)
如果可能,我将如何更改文本的字体和/或大小?我试着做一个计时器——我已经用Lua做了两三年的数学作弊(“如果我用我的iPod作为测试的计算器可以吗?”“当然可以。”“谢谢!傻笑”),现在我开始探索它的功能——通过运行循环并每秒向窗口打印文本,但是文本太小了

io.write("Enter the time in seconds that the timer will run: ")
local time = io.read('*number')

local function sleep(s)
   local clock = os.clock
   local t0 = clock()
   while clock() - t0 >= s do
   end
end

require('turtle')

function timer(time)
   local erase = snap()
   while time ~= 0 do
      text(time, 0, 0, 0)
      time = time - 1
      sleep(1)
      undo(erase)
   end
   text("Done", 0, 0, 0)
end

wait()

在调用
text
之前,您可以调用
font
函数设置不同的字体。以下是一些示例调用:

font("serif")  -- change font
font(32)  -- change size
font("italic")

font("serif 32") -- or change both

text("Text")
或者在您的代码示例中:

io.write("Enter the time in seconds that the timer will run: ")
local time = io.read('*number')

local function sleep(s)
   local clock = os.clock
   local t0 = clock()
   while clock() - t0 >= s do
   end
end

require('turtle')
font(64)

function timer(time)
   local erase = snap()
   while time > 0 do
      text(time)
      time = time - 1
      sleep(1)
      undo(erase)
   end
   text("Done")
end

wait()