I found the solution.
I used the cabinet file from- https://github.com/Wavalab/corona-cabinet
I’ve included here for anyone who wants to see what I did
Main.lua
----------------------------------------------------------------------------------------- -- -- main.lua -- ----------------------------------------------------------------------------------------- -- Your code here local composer = require( "composer" ) display.setStatusBar(display.HiddenStatusBar) local options = { effect = "fade", time = 500, } composer.gotoScene( "scene1", options )
scene1.lua
local composer = require( "composer" ) --local globalData = require( "globalData" ) local cabinet = require("cabinet") local scene = composer.newScene() -- ----------------------------------------------------------------------------------- -- Code outside of the scene event functions below will only be executed ONCE unless -- the scene is removed entirely (not recycled) via "composer.removeScene()" -- ----------------------------------------------------------------------------------- -- ----------------------------------------------------------------------------------- -- Scene event functions -- ----------------------------------------------------------------------------------- -- create() function scene:create( event ) local sceneGroup = self.view -- Code here runs when the scene is first created but has not yet appeared on screen -- TextField Listener local function fieldHandler( event ) if ( "began" == event.phase ) then elseif ( "editing" == event.phase ) then myTextString = event.target.text elseif ( "ended" == event.phase ) then native.setKeyboardFocus( nil ) end end inputTextField = native.newTextField(150,100, 200, 50) inputTextField:addEventListener("userInput", fieldHandler) timer.performWithDelay(50, function()native.setKeyboardFocus( inputTextField )end, 1) cabinet.set("playerName",myTextString) local function onNextTouch( event ) if ("ended" == event.phase ) then composer.gotoScene("scene2") end end local nextButton = display.newText( "Next", 150, 400, native.systemFont, 75 ) nextButton:setFillColor(25,25,4) nextButton:addEventListener( "touch", onNextTouch ) sceneGroup:insert(inputTextField) sceneGroup:insert(nextButton) end -- show() function scene:show( event ) local sceneGroup = self.view local phase = event.phase if ( phase == "will" ) then -- Code here runs when the scene is still off screen (but is about to come on screen) elseif ( phase == "did" ) then -- Code here runs when the scene is entirely on screen end end -- hide() function scene:hide( event ) local sceneGroup = self.view local phase = event.phase if ( phase == "will" ) then -- Code here runs when the scene is on screen (but is about to go off screen) elseif ( phase == "did" ) then -- Code here runs immediately after the scene goes entirely off screen end end -- destroy() function scene:destroy( event ) local sceneGroup = self.view -- Code here runs prior to the removal of scene's view end -- ----------------------------------------------------------------------------------- -- Scene event function listeners -- ----------------------------------------------------------------------------------- scene:addEventListener( "create", scene ) scene:addEventListener( "show", scene ) scene:addEventListener( "hide", scene ) scene:addEventListener( "destroy", scene ) -- ----------------------------------------------------------------------------------- return scene
scene2.lua
local composer = require( "composer" ) --local globalData = require( "globalData" ) local cabinet = require("cabinet") local scene = composer.newScene() -- ----------------------------------------------------------------------------------- -- Code outside of the scene event functions below will only be executed ONCE unless -- the scene is removed entirely (not recycled) via "composer.removeScene()" -- ----------------------------------------------------------------------------------- -- ----------------------------------------------------------------------------------- -- Scene event functions -- ----------------------------------------------------------------------------------- -- create() function scene:create( event ) local sceneGroup = self.view -- Code here runs when the scene is first created but has not yet appeared on screen cabinet.get("playerName") --local currentPlayer = globalData.playerName local nametext = display.newText("player " ..myTextString, 100,300,75,100) nametext:setFillColor(25,25,4) end -- show() function scene:show( event ) local sceneGroup = self.view local phase = event.phase if ( phase == "will" ) then -- Code here runs when the scene is still off screen (but is about to come on screen) elseif ( phase == "did" ) then -- Code here runs when the scene is entirely on screen end end -- hide() function scene:hide( event ) local sceneGroup = self.view local phase = event.phase if ( phase == "will" ) then -- Code here runs when the scene is on screen (but is about to go off screen) elseif ( phase == "did" ) then -- Code here runs immediately after the scene goes entirely off screen end end -- destroy() function scene:destroy( event ) local sceneGroup = self.view -- Code here runs prior to the removal of scene's view end -- ----------------------------------------------------------------------------------- -- Scene event function listeners -- ----------------------------------------------------------------------------------- scene:addEventListener( "create", scene ) scene:addEventListener( "show", scene ) scene:addEventListener( "hide", scene ) scene:addEventListener( "destroy", scene ) -- ----------------------------------------------------------------------------------- return scene
and last but not least… cabinet.lua
--[[ Cabinet v1.1 | MIT | github.com/wavalab/corona-cabinet Save/retrieve Tables, Numbers, Strings & Booleans via persistent JSON file. --]] local j = require "json" local cabinet = {} local function rj(fname, dir) local t, f = {}, io.open(system.pathForFile(fname, dir), "r") if not f then return end t = j.decode(f:read("\*a")) io.close(f) return t end local function wj(t, fname, dir) local f = io.open(system.pathForFile(fname, dir), "w") if not f then return end f:write(j.encode(t)) io.close(f) end local f = "cabinet.json" local d = system.DocumentsDirectory local t = rj(f, d) or {} function cabinet.set(k, v) t[k] = v wj(t, f, d) end function cabinet.get(k) return t[k] end function cabinet.remove(k) t[k] = nil wj(t, f, d) end function cabinet.clear() t = {} wj(t, f, d) end return cabinet
you will also need a blank caninet.json file.
i hope this is of some help to someone. It was a strugle, but I made it. best way to learn!
thanks to those who provided input for me.
Thanks,\
Mike