So I want to setup a tutorial to start for when a person first plays my game.
However, while I know how to make the tutorial, I have no idea how to make the event get triggered.
Any ideas?
So I want to setup a tutorial to start for when a person first plays my game.
However, while I know how to make the tutorial, I have no idea how to make the event get triggered.
Any ideas?
Hi,
One option would be to write a text file as a flag, and check it when your app opens.
-dev
Thanks for replying!!
What do you mean as flag?
Like I mean how would you set up a text file as a flag?
save a flag in a file after the user opens the app and check for the existence of that file/flag on each launch.
Using SSK, this is easy.
You could put this in main.lua
-- DONE ONCE ONLY IN MAIN.lua require "ssk2.loadSSK" \_G.ssk.init() -- .. any code you want... local settings = table.load( "settings.json" ) or {} if( not settings.showedTutorial ) then settings.showedTutorial = true table.save( settings, "settings.json") showTutorial() -- your function to show tutorial; you need to write it end
please do not do that…
HUGE FONTS (aka shouting) and odd colors in response are NOT cool.
Just use normal fonts please.
Sorry my bad just having a bit of fun.
Anyways, is settings.json included in SSK or I have to make that?
I got to admit, im not experienced in writing json files.
I thought the code was pretty clear, but let me break it down for you…
-- Load JSON encoded table "settings.json" and store reference in variable 'settings' -- -OR- -- If no file exists (function returns nil), store a blank table in the variable 'settings' local settings = table.load( "settings.json" ) or {} -- If the field 'showedTutorial' is NOT true (i.e. doesn't exist or is set to 'false') -- run this code... if( not settings.showedTutorial ) then -- Set the field/flag 'showedTutorial' to true settings.showedTutorial = true -- Save the table referenced by variable 'settings' as a JSON encoded -- text file settings.json -- IF THE FILE DOES NOT EXIST IT IS CREATED NOW. table.save( settings, "settings.json") -- call a function (you need to write it) to show a tutorial showTutorial() end
The table.save() and table.load() functions are extensions added by SSK and fully documented:
https://roaminggamer.github.io/RGDocs/pages/SSK2/extensions/#saving-loading-tables
The names:
Can be anything you want and changing them to suit your style of coding will make no difference in functionality.
I understand the code but do i need to make settings.json?
I don’t think you understood the code so I UPDATED the comments in my last post.
Hi,
Using SSK as mentioned above is the simplest method, but you might have a look at this guide as well:
https://docs.coronalabs.com/guide/data/readWriteFiles/index.html
-dev
Thanks for all your help!
i will definitely look into all of this.
Hi,
One option would be to write a text file as a flag, and check it when your app opens.
-dev
Thanks for replying!!
What do you mean as flag?
Like I mean how would you set up a text file as a flag?
save a flag in a file after the user opens the app and check for the existence of that file/flag on each launch.
Using SSK, this is easy.
You could put this in main.lua
-- DONE ONCE ONLY IN MAIN.lua require "ssk2.loadSSK" \_G.ssk.init() -- .. any code you want... local settings = table.load( "settings.json" ) or {} if( not settings.showedTutorial ) then settings.showedTutorial = true table.save( settings, "settings.json") showTutorial() -- your function to show tutorial; you need to write it end
please do not do that…
HUGE FONTS (aka shouting) and odd colors in response are NOT cool.
Just use normal fonts please.
Sorry my bad just having a bit of fun.
Anyways, is settings.json included in SSK or I have to make that?
I got to admit, im not experienced in writing json files.
I thought the code was pretty clear, but let me break it down for you…
-- Load JSON encoded table "settings.json" and store reference in variable 'settings' -- -OR- -- If no file exists (function returns nil), store a blank table in the variable 'settings' local settings = table.load( "settings.json" ) or {} -- If the field 'showedTutorial' is NOT true (i.e. doesn't exist or is set to 'false') -- run this code... if( not settings.showedTutorial ) then -- Set the field/flag 'showedTutorial' to true settings.showedTutorial = true -- Save the table referenced by variable 'settings' as a JSON encoded -- text file settings.json -- IF THE FILE DOES NOT EXIST IT IS CREATED NOW. table.save( settings, "settings.json") -- call a function (you need to write it) to show a tutorial showTutorial() end
The table.save() and table.load() functions are extensions added by SSK and fully documented:
https://roaminggamer.github.io/RGDocs/pages/SSK2/extensions/#saving-loading-tables
The names:
Can be anything you want and changing them to suit your style of coding will make no difference in functionality.
I understand the code but do i need to make settings.json?
I don’t think you understood the code so I UPDATED the comments in my last post.