Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Selection option when the app runs for the first time?
Started by BulkOlav Nov 07 2018 06:47 AM

4 replies to this topic

Best Answer Rob Miracle , 07 November 2018 - 01:04 PM

I generally have a "settings" file which isn't created until the app runs the first time. If that file doesn't exist, then you know it's a first run, or the app was deleted and re-installed in which case, you want to use your "first run" logic anyway.

 

You can also use the system.getPreference() and system.setPreferences() APIs to do the same thing. It might be a little less code to use these APIs: http://docs.coronalabs.com/api/library/system/getPreference.html

local hasAppRunBefore = system.getPreference( "app", "hasAppRunBefore", "boolean" )
if not hasAppRunBefore then
     system.setPreferences( "app", { hasAppRunBefore = true } )
     -- do your first run logic here
end

(untested code)

 

Rob

[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

BulkOlav

[GLOBAL: userInfoPane.html]
BulkOlav
  • Observer

  • 15 posts
  • Corona SDK

I want the player to choose a class the frist time he/she runs the app. My current solution is to look for the highscores file my game creates, and if the file does not exist then I will send them to the choose lua file.

 

My questions are:

 

Are there an alternative better method to do this or is my solution sufficient?

 

Can this method cause any problems?



[TOPIC: post.html]
#2

nick_sherman

[GLOBAL: userInfoPane.html]
nick_sherman
  • Corona Geek

  • 1,610 posts
  • Corona SDK

As good a solution as an, some create a specific empty text file just for this purpose, but checking for the existence of a high scores or settings file is just as good.



[TOPIC: post.html]
#3

BulkOlav

[GLOBAL: userInfoPane.html]
BulkOlav
  • Observer

  • 15 posts
  • Corona SDK

As good a solution as an, some create a specific empty text file just for this purpose, but checking for the existence of a high scores or settings file is just as good.

 

Okey thank you:) I was just worried it would cause some problems or that it was a bit noobish.



[TOPIC: post.html]
#4

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 24,860 posts
  • Corona Staff

  Best Answer

I generally have a "settings" file which isn't created until the app runs the first time. If that file doesn't exist, then you know it's a first run, or the app was deleted and re-installed in which case, you want to use your "first run" logic anyway.

 

You can also use the system.getPreference() and system.setPreferences() APIs to do the same thing. It might be a little less code to use these APIs: http://docs.coronalabs.com/api/library/system/getPreference.html

local hasAppRunBefore = system.getPreference( "app", "hasAppRunBefore", "boolean" )
if not hasAppRunBefore then
     system.setPreferences( "app", { hasAppRunBefore = true } )
     -- do your first run logic here
end

(untested code)

 

Rob



[TOPIC: post.html]
#5

BulkOlav

[GLOBAL: userInfoPane.html]
BulkOlav
  • Observer

  • 15 posts
  • Corona SDK

I think that the preference solution fits better. Thank you for including an example, I will use that and add a another line if the hasAppRunBefore is true then it will go to the menu insted.

 

 

I generally have a "settings" file which isn't created until the app runs the first time. If that file doesn't exist, then you know it's a first run, or the app was deleted and re-installed in which case, you want to use your "first run" logic anyway.

 

You can also use the system.getPreference() and system.setPreferences() APIs to do the same thing. It might be a little less code to use these APIs: http://docs.coronalabs.com/api/library/system/getPreference.html

local hasAppRunBefore = system.getPreference( "app", "hasAppRunBefore", "boolean" )
if not hasAppRunBefore then
     system.setPreferences( "app", { hasAppRunBefore = true } )
     -- do your first run logic here
end

(untested code)

 

Rob




[topic_controls]
[/topic_controls]