Text input to file?

I believe i have that topic worded right?

This app is my first project that will use User Text Input.

using native.newTextField I want to allow users to type a message, and upon closing the overlay window, it saves to the “myData.lua” file where i store variables.

I do not know how to go about doing this, though.

If the user types Hello into field one.

then * myData.msg1 = “Hello” * should happen once they close the window.

This is so i can later pull myData.msg1 to use in display.newText, and get the word “Hello” displayed on the screen.

Would also be helpful if the same messages were loaded back into the input field if they go back to the options.

There will be several other fields as well, but if i can understand one, I will be able to add all of the others.

I have no real code right now, other than this “brainstorming” above, so I cannot paste anything.

Thanks in advance.  

I will be tackling this problem in a day or two, so i thought i could get a head start by asking.

Tyler

Ok.  Thought I would come back and let you all know that I pretty much already had it summed up in my original post, and it worked.

 local input1 -- Create text field input1 = native.newTextField( display.contentCenterX, 95, display.contentWidth-50, 30 ) input1.placeholder = myData.msg1 sceneGroup:insert( input1 ) local function textListener1( event ) if ( event.phase == "began" ) then -- user begins editing defaultField print( event.text ) elseif ( event.phase == "ended" or event.phase == "submitted" ) then -- do something with defaultField text print( event.target.text ) myData.msg1 = input1.text input1.placeholder = myData.msg1 elseif ( event.phase == "editing" ) then print( event.newCharacters ) print( event.oldText ) print( event.startPosition ) print( event.text ) end end input1:addEventListener( "userInput", textListener1 )

The main line that is doing what i needed is

myData.msg1 = input1.text

Every time I type, it updates myData.lua with the correct message for later use.

Ok.  Thought I would come back and let you all know that I pretty much already had it summed up in my original post, and it worked.

 local input1 -- Create text field input1 = native.newTextField( display.contentCenterX, 95, display.contentWidth-50, 30 ) input1.placeholder = myData.msg1 sceneGroup:insert( input1 ) local function textListener1( event ) if ( event.phase == "began" ) then -- user begins editing defaultField print( event.text ) elseif ( event.phase == "ended" or event.phase == "submitted" ) then -- do something with defaultField text print( event.target.text ) myData.msg1 = input1.text input1.placeholder = myData.msg1 elseif ( event.phase == "editing" ) then print( event.newCharacters ) print( event.oldText ) print( event.startPosition ) print( event.text ) end end input1:addEventListener( "userInput", textListener1 )

The main line that is doing what i needed is

myData.msg1 = input1.text

Every time I type, it updates myData.lua with the correct message for later use.