필자는 특정 방식으로 입력 된 텍스트를 users.txt에 추가하기 위해 lua 함수를 작성했으나 단독 실행시에는 잘 작동하지만 main.lua에서 필요할 때 작동합니다 작동하지만 users.txt에 결코 쓰지 않습니다. 이 내 두 파일의 코드입니다 :다른 .lua에서 작동하지 않는 file.write
adminprograms.lua :
function adduser()
print("Username")
local username = io.read()
print("Password")
local password = io.read()
print("State")
local state = io.read()
state = state.upper(state)
print(state.."-"..username.."-"..password)
--------------the code that dosent work
local users = io.open("users.txt", "a")
users.write(users , state.."-"..username.."-"..password.."\n")
end
main.lua : 왜이
require "adminprograms"
loginstate = "admin"
repeat
local command = io.read()
if loginstate == "admin" and command == "newuser" then
adduser()
end
until false
입니까? 그들은 users.txt와 함께 같은 폴더에 있습니다. 그게 중요하다면 나는 윈도우 64 비트를 달리고있다. 오류가 발생하지 않습니다.
그래서'main.lua'를 사용하면 인쇄 메시지를 볼 수 있지만 종료 한 후 파일에는 추가 콘텐츠가 없습니다? – Schollii
나는 내가 묻는 이유가 전혀 모른다. :) – DivideByZero