I wrote a lua function to add entered text to a users.txt in a specific manner, and that works fine when executed alone, but when i require it in main.lua it works- but never writes to users.txt. These are my two file's codes:
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
Why is this? They are both in the same folder along with users.txt. I am running Windows 64 bit if that matters at all. No errors are thrown.