English 中文(简体)
Lua:在外部txt档案中找到最新线
原标题:Lua: getting the latest line in external txt file
  • 时间:2011-10-03 04:56:35
  •  标签:
  • lua

我有阅读和书写轴心的旋转功能,我每次都需要用黄瓜书写新字,而不是取代以前的文字。 我如何这样做? 在我撰写文章之前,我是否需要每次阅读和阅读第1条。

我的守则是:

local function FileOutput(name)
    local f = io.open(name, "w+")
    local meta = {
        __call = function(t, str) f:write(str ..  
 ) end,
        __gc = function() f:close() end
    }
    return setmetatable({}, meta)
end

function writeRec()
LOG("writing")
local testfile = FileOutput(getScriptDirectory().. /textOutput.txt ) 
testfile( oh yes! )
testfile = nil
end
最佳回答

您是否尝试过<条码>a+而不是<条码>w+?

问题回答

暂无回答




相关问题
Wrapping a Lua object for use in C++ with SWIG

Currently I know how to have C++ objects instantiated and passed around in Lua using SWIG bindings, what I need is the reverse. I am using Lua & C++ & SWIG. I have interfaces in C++ and ...

Can t lua_resume after async_wait?

I have some lua script that have some long running task like getting a web page so I make it yield then the C code handle get page job async, so the thread free to do other job and after a specify ...

How to remove a lua table entry by its key?

I have a lua table that I use as a hashmap, ie with string keys : local map = { foo = 1, bar = 2 } I would like to "pop" an element of this table identified by its key. There is a table.remove() ...

Lua plain string.gsub

I ve hit s small block with string parsing. I have a string like: footage/down/temp/cars_[100]_upper/cars_[100]_upper.exr and I m having difficulty using gsub to delete a portion of the string. ...

why do i get "attempt to call global require (a nil value)"?

I have 3 lua files, Init.lua, FreeCamera.lua and Camera.lua , init.lua calls require "Core.Camera.FreeCamera" Free Camera: module(...) require "Core.Camera.Camera" local M = {} FreeCamera = M M ...

热门标签