New Features on a Current Game

Hello,

I currently have a game on Android and Apple Stores needing some important revisions.  The most urgent is a video that needs to be shown only 1 time to all downloaders of the most recent version I’m going to launch ASAP.  Several things from Level 1 forward are changing, and I need all players to see this and to be directed to the new Level 1 video. 

My 1st coder, who signed an exclusive agreement and cannot code, but can advise, said,

“For showing a new video, you’d just set a system flag after the user watches it and then not show it again.  Same would apply to new users, it’s just a logic flow on startup.”

We can go further into the situation / code of course.  If we can work to get together to get this resolved quickly and effectively I have several other items to work through.  I look forward to hearing back from anyone interested.  Thanks.

Isaiah

This is a relatively straightforward task.

Perhaps the simplest way of accomplishing this is to check if a specific file exists when the app starts. If it doesn’t, create it. If it does, then load its contents. The contents can be as simple as a “1” and “0” or “true” and “false”.

Then, you use this information in your game file to check if the video has been watched and update the file once the video has been watched to prevent unwanted future showings of the video.

Here’s the sample code:

-- main.lua: ------------ local path = system.pathForFile( "videoShown.txt", system.DocumentsDirectory ) local file = io.open( path, "r" ) if not file then videoShown = false -- create a simple global variable for ease & simplicity local path = system.pathForFile( "videoShown.txt", system.DocumentsDirectory ) local file = io.open( path, "w" ) file:write( "false" ) io.close( file ) else local contents = file:read( "\*a" ) if contents == "false" then videoShown = false else videoShown = true end io.close( file ) end file = nil -- game.lua (i.e. where the levels are played) ------------ local videoShown = videoShown or false -- get the global variable's values or default to false if not videoShown then local onComplete = function( event ) local path = system.pathForFile( "videoShown.txt", system.DocumentsDirectory ) local file = io.open( path, "w" ) if file then file:write( "true" ) io.close( file ) end -- video has been shown and videoShown.txt saved as true, so start the level end media.playVideo( "video/yourVideo.mp4", false, onComplete ) else -- video already shown, so start the level end

If you need help getting the code to your app or with something else, feel free to send me a private message or contact me at eetu@erantanen.com.

This is a relatively straightforward task.

Perhaps the simplest way of accomplishing this is to check if a specific file exists when the app starts. If it doesn’t, create it. If it does, then load its contents. The contents can be as simple as a “1” and “0” or “true” and “false”.

Then, you use this information in your game file to check if the video has been watched and update the file once the video has been watched to prevent unwanted future showings of the video.

Here’s the sample code:

-- main.lua: ------------ local path = system.pathForFile( "videoShown.txt", system.DocumentsDirectory ) local file = io.open( path, "r" ) if not file then videoShown = false -- create a simple global variable for ease & simplicity local path = system.pathForFile( "videoShown.txt", system.DocumentsDirectory ) local file = io.open( path, "w" ) file:write( "false" ) io.close( file ) else local contents = file:read( "\*a" ) if contents == "false" then videoShown = false else videoShown = true end io.close( file ) end file = nil -- game.lua (i.e. where the levels are played) ------------ local videoShown = videoShown or false -- get the global variable's values or default to false if not videoShown then local onComplete = function( event ) local path = system.pathForFile( "videoShown.txt", system.DocumentsDirectory ) local file = io.open( path, "w" ) if file then file:write( "true" ) io.close( file ) end -- video has been shown and videoShown.txt saved as true, so start the level end media.playVideo( "video/yourVideo.mp4", false, onComplete ) else -- video already shown, so start the level end

If you need help getting the code to your app or with something else, feel free to send me a private message or contact me at eetu@erantanen.com.