我正在尝试为ComputerCraft制作一个自定义打印程序,它可以通过一个命令打印更多的副本,但我遇到了一个问题。每次向其中放入一个文件时,都不会换行,而是将?
放在换行符所在的位置(\n
)。我该怎么做才能正确呢?
问题应该在这里的某个地方:
for i=1,copyNumber do
printer.newPage();
printer.setPageTitle(pageLabel);
local h = fs.open(filePath, "r");
local text = h.readAll();
print("Tisknu:");
write(text.."\n");
printer.write(text);
h.close();
printer.endPage();
end
发布于 2013-05-09 21:58:33
试试这个:
for i=1,copyNumber do
printer.newPage();
printer.setPageTitle(pageLabel);
local h = fs.open(filePath, "r");
local text = h.readLine(); --Read one line
while(text != nil) --If line isn't nill
printer.write(text); --Write the line
_,y = printer.getCursorPos() --Get the current cursor pos.
printer.setCursorPos(1,y+1); --Move one line down
text = h.readLine(); --Read the next line
end
h.close(); --Close the file
printer.endPage(); --End the page
end
https://stackoverflow.com/questions/16261350
复制相似问题