Random row from Google Sheets (Card game)

Hello, I am looking for some help. ( I am a complete beginner in this programming)
I want to create a very simple application based on the principle of a card game.
The game consists of cards on which tasks are written. I need the cards to go in random order.
When I press the "Next card" button, a random row is loaded from Google sheets
Task names and instructions are written in google tables. I need the application to read the name and instructions from these two lines and display this information in random order. (as cards).



Thank you for any help.

Who loads the data into the sheet?

  • You (the developer), or
  • the player(s) ?

Only me the developer.

In that case, load the entire sheet into AI2 at startup.
Sample:

except don't specify a range since you want the entire sheet.

Look for the free book in

or probably easier, convert the sheet into a csv table and store that table in a text file in the assets of your app, then use the file component to read it on first run of your app

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by icon24 Taifun.

1 Like

If the data in the form is updated every now and then, it will be a bad idea to write to the file. You can only save the file as a backup. I would read the spreadsheet every time when starting the application, unless there was no internet connection, then from the file. I would use TinyDB instead of a file. Faster and easier access.

  1. Use the "Web" component. You need to make your sheet publicly available to everyone who has the link. In the component settings, in the address field, enter the address of your sheet with the changed ending:
    Instead:
    "https://docs.google.com/spreadsheets/d/1Cq...bsM/edit?usp=sharing"
    do it this way:
    https://docs.google.com/spreadsheets/d/1Cq...bsM/export?format=csv

  2. In the initialization block, insert the block "Web1.get".
    component_method

  3. Use the "when Web1.got.text" block and program the blocks as follows:

  1. Add a randomizing procedure that will start after reading csv. You can also add it to the button:

In the initialization blocks, you can add loading data from TinyDB in case the internet is unavailable. If the internet is available, the data from the sheet will overwrite the data from TinyDB.