Jump to content




help with my file writing problem


  • You cannot reply to this topic
3 replies to this topic

#1 wilcomega

  • Members
  • 466 posts
  • LocationHolland

Posted 29 July 2012 - 03:03 AM

i have made a program that writes a table to a file line by line but on every line it writes 'table: (numbers)'
here is the PIECE code:

local f = fs.open( "keys.txt", "w" )
local toWrite = ""
for i=1,#logging do
toWrite = logging[i]
f:writeLine( toWrite )
if debug == true then print( "writed: ", logging[i] ) end
end
f:close( )

thx in adv :ph34r:/>

edit: if you want full code just ask. i am not going to give it in public, i will PM you :)/>

#2 Luanub

    Lua Nub

  • Members
  • 1,135 posts
  • LocationPortland OR

Posted 29 July 2012 - 06:48 AM

I'm not sure why you are doing this
toWrite = logging[i]
f:writeLine( toWrite )

It's probably what is causing your error, try just this.
f:writeLine(logging[i])


#3 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 29 July 2012 - 07:43 AM

Yeah, there's nothing visibly wrong with that code. Luanub mentioned a bad coding practice to correct, but even that shouldn't be causing the problem. Let's see the rest of it.

#4 ChiknNuggets

  • Members
  • 130 posts

Posted 29 July 2012 - 10:36 AM

local f = fs.open("keys.txt", "w")
for i,v in ipairs(logging) do
if i == 1 then text = v else text = text.."n"..v end
if debug == true then print( "writed: ", v ) end
end
f.write(text)
f:close()

Will do what you want, i tested it and it worked





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users