Preserving highscores from accidental opening of program code
|
03-01-2023, 11:01 PM
(This post was last modified: 03-01-2023 11:02 PM by Kevin Ouellet.)
Post: #1
|
|||
|
|||
Preserving highscores from accidental opening of program code
Is there a way to make a program save a number into an external variable or memory without it being erased everytime the user opens the program code? This is problematic because all other calculator models use ENTER to execute programs, while the HP Prime uses F6, so if I have a game where the highscore is saved, then the player will usually press ENTER by reflex to launch the game, only to have not only the code opened instead but also his highscore erased.
I was also thinking of working on a role-playing game with saving options, but have been reluctant about starting such project at all because of the save data being erased over and over. -Dream of Omnimaga https://dreamofomnimaga.page |
|||
03-02-2023, 02:43 AM
Post: #2
|
|||
|
|||
RE: Preserving highscores from accidental opening of program code
You can save the highscores in a Home variable, out of the program, with HVars.
|
|||
03-06-2023, 05:31 AM
Post: #3
|
|||
|
|||
RE: Preserving highscores from accidental opening of program code
(03-01-2023 11:01 PM)Kevin Ouellet Wrote: Is there a way to make a program save a number into an external variable or memory without it being erased everytime the user opens the program code? This is problematic because all other calculator models use ENTER to execute programs, while the HP Prime uses F6, so if I have a game where the highscore is saved, then the player will usually press ENTER by reflex to launch the game, only to have not only the code opened instead but also his highscore erased. I believe in the new project structure you can have side variables and data that is kept on the side and not part of the source. Nor is it compiled. Basically, a place for data and binary info to reside without appearing in user editable areas normally. TW Although I work for HP, the views and opinions I post here are my own. |
|||
10-23-2023, 04:26 AM
Post: #4
|
|||
|
|||
RE: Preserving highscores from accidental opening of program code
Heya, sorry I am very late! I actually took a while to figure out how to use HVar and I first gave up until recently when I picked up my game again and now I figured it out. Thanks for letting me know about HVar. I have now checked the on-calc help but I prefered downloading the PDF copy to my computer so it's easier to read on the larger screen. HVar seems to work with other type of variables too, which I am happy about.
-Dream of Omnimaga https://dreamofomnimaga.page |
|||
10-23-2023, 01:11 PM
Post: #5
|
|||
|
|||
RE: Preserving highscores from accidental opening of program code
Why don't you want to use the resources assigned to a specific program as TW mentioned? Of course, HVars will work correctly, but then the data saved in this way are shared in HOME for different programs, and if another program uses the same name, it will overwrite them.
On the other hand, resources (e.g., 'binary asset') are a very interesting solution when you want to have isolated files for a specific program in the 'Program Catalog' without the need to create an app. It's perfect for graphics (so you don't have to use ICON), but also for binary data. For me, it's an ideal solution to save the current game state or the highscores. I'm currently updating my game 'Radioactive Wastes' to utilize this mechanism. |
|||
10-23-2023, 07:31 PM
Post: #6
|
|||
|
|||
RE: Preserving highscores from accidental opening of program code
I prefer avoiding using apps. I had way too many problems running custom apps in the past and I prefer to use a more functional alternative that is hpprgm.
-Dream of Omnimaga https://dreamofomnimaga.page |
|||
10-23-2023, 09:04 PM
Post: #7
|
|||
|
|||
RE: Preserving highscores from accidental opening of program code
What I'm referring to is indeed hpprgm. This feature was introduced quite recently (in one of the latest firmware versions). It's a regular program (not an app) in the 'Program Catalog' that has the ability to nest other files within itself, which are not reset when someone opens the source code. Take a look at the on-calc help for the "Resource" command. If you need more details, I can prepare a usage example for you.
|
|||
10-23-2023, 09:49 PM
Post: #8
|
|||
|
|||
RE: Preserving highscores from accidental opening of program code
Oh I see now. I didn't know about this feature. I'll check the help later!
-Dream of Omnimaga https://dreamofomnimaga.page |
|||
10-24-2023, 07:59 AM
Post: #9
|
|||
|
|||
RE: Preserving highscores from accidental opening of program code
I think you should read this thread:
Program "project" structure - how to use? I've described a bit more about this topic here, mainly what to watch out for. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 2 Guest(s)