Create a button's icon with a part of a big image? - Beleaguered Castle

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Zax
Posts: 487
Joined: Mon May 28, 2007 10:12 am
Location: France
Contact:

Re: Create a button's icon with a part of a big image? - Beleaguered Castle

Post by Zax » Sat Oct 08, 2022 4:13 pm

I'll look at the stats bug.
The prefs file is located within user's prefs folder. Here on a Mac:
/Users/.../Library/Preferences/BCastle_Prefs.ixp

Concerning the DL link, it will be fixed when I'll have a stable version... when you won't be able to find annoying bugs ;)

Zax
Posts: 487
Joined: Mon May 28, 2007 10:12 am
Location: France
Contact:

Re: Create a button's icon with a part of a big image? - Beleaguered Castle

Post by Zax » Sun Oct 09, 2022 11:48 am

I was unable to reproduce the bug in the statistics. According to my tests, the statistics work correctly.
I uploaded 0.33 version on my server, available from the "Check for update" command in the application. This new version fixes some minor bugs unrelated to statistics.

SWEdeAndy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 265
Joined: Sat Aug 16, 2008 9:48 am
Location: Stockholm, Sweden
Contact:

Re: Create a button's icon with a part of a big image? - Beleaguered Castle

Post by SWEdeAndy » Sun Oct 09, 2022 2:27 pm

Zax wrote:
Sun Oct 09, 2022 11:48 am
I was unable to reproduce the bug in the statistics. According to my tests, the statistics work correctly.
That is strange. I cannot avoid reproducing it. I delete the prefs file, start the game, play until one game is won: Number of wins jumps from 0 to 8.
Zax wrote:
Sun Oct 09, 2022 11:48 am
I uploaded 0.33 version on my server, available from the "Check for update" command in the application. This new version fixes some minor bugs unrelated to statistics.
Unfortunately, nothing at all happens when clicking OK in the Check for update dialog. No browser is launched.
Andreas Bergendal
Independent app and system developer
Free LC dev tools: https://github.com/wheninspace
WhenInSpace: https://wheninspace.se/en

Zax
Posts: 487
Joined: Mon May 28, 2007 10:12 am
Location: France
Contact:

Re: Create a button's icon with a part of a big image? - Beleaguered Castle

Post by Zax » Sun Oct 09, 2022 2:49 pm

I really don't know what to say. All is working fine for me, statistics and download.

These are direct links:
https://sw.ixoft.com/files/BeleagueredC ... 33_OSX.zip
https://sw.ixoft.com/files/BeleagueredC ... 33_win.zip

EDIT: I found why the browser don't launch anything on update: it works fine with 0.33 and future version.

SWEdeAndy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 265
Joined: Sat Aug 16, 2008 9:48 am
Location: Stockholm, Sweden
Contact:

Re: Create a button's icon with a part of a big image? - Beleaguered Castle

Post by SWEdeAndy » Sun Oct 09, 2022 5:13 pm

I still get the same error. I notice that my choice of board (Pool) and cards (Castle special) remains after installing a new version and trashing the prefs file. Are those the default ones? If not, is it possible that the game saves some info anywhere else?

I'm using macOS 12.6 Monterey. I've normally put the folder with the game in the Apps folder. I now removed it from there and run it from the downloads folder, just to see if it made any difference. It didn't.

BC3.png
Winning 500% of the games is now my record :D , and this time the game even gave me a discount on the moves, so that 71 moves were registered as 70...

I know how frustrating it is when users get an error that you can't reproduce. I hope some more people can try the game, so we get some idea of what may cause this strange bug.
Andreas Bergendal
Independent app and system developer
Free LC dev tools: https://github.com/wheninspace
WhenInSpace: https://wheninspace.se/en

Zax
Posts: 487
Joined: Mon May 28, 2007 10:12 am
Location: France
Contact:

Re: Create a button's icon with a part of a big image? - Beleaguered Castle

Post by Zax » Sun Oct 09, 2022 6:42 pm

SWEdeAndy wrote:
Sun Oct 09, 2022 5:13 pm
I know how frustrating it is when users get an error that you can't reproduce.
Indeed!
But don't forget most of the bugs you reported was easily reproducible. For that reason, your reports were highly valuable during this development :)

Yes, Pool and Castle Special are the default value. If the game is launched without finding preferences file, it started a new game and also don't remember the latest window size.
SWEdeAndy wrote:
Sun Oct 09, 2022 5:13 pm
Winning 500% of the games is now my record :D , and this time the game even gave me a discount on the moves, so that 71 moves were registered as 70...
:lol: :lol: :lol:
Imagine it could be the contrary: it could pretend you never won a game! ;)

Zax
Posts: 487
Joined: Mon May 28, 2007 10:12 am
Location: France
Contact:

Re: Create a button's icon with a part of a big image? - Beleaguered Castle

Post by Zax » Mon Oct 10, 2022 11:59 am

There was a stupid Preferences bug in 0.33 version, so this is the 0.34:

https://sw.ixoft.com/files/BeleagueredC ... 34_OSX.zip
https://sw.ixoft.com/files/BeleagueredC ... 34_win.zip

(I don't think this new version will solve strange behaviors you encountered, Andreas).

SWEdeAndy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 265
Joined: Sat Aug 16, 2008 9:48 am
Location: Stockholm, Sweden
Contact:

Re: Create a button's icon with a part of a big image? - Beleaguered Castle

Post by SWEdeAndy » Wed Oct 12, 2022 9:27 pm

Zax wrote:
Mon Oct 10, 2022 11:59 am
(I don't think this new version will solve strange behaviors you encountered, Andreas).
Indeed, it doesn't. I've tried on another Mac now, running macOS Mojave (so a bit older), and the same error occurs.
Have you tested on a Mac on your side? I see now that the number of wins is consistently multiplied by 8 in the stats. So, after 4 wins, the stats say 32 wins etc.

It seems very strange that this calculation error should occur on Macs only, but so far that seems to be the case...
Andreas Bergendal
Independent app and system developer
Free LC dev tools: https://github.com/wheninspace
WhenInSpace: https://wheninspace.se/en

Zax
Posts: 487
Joined: Mon May 28, 2007 10:12 am
Location: France
Contact:

Re: Create a button's icon with a part of a big image? - Beleaguered Castle

Post by Zax » Thu Oct 13, 2022 7:44 am

The app was created and tested on MacOS Sierra.
After several days with the 0.34 version, all seems OK for me:

bc.jpg

I'll try on a PC with Windows 10.

SWEdeAndy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 265
Joined: Sat Aug 16, 2008 9:48 am
Location: Stockholm, Sweden
Contact:

Re: Create a button's icon with a part of a big image? - Beleaguered Castle

Post by SWEdeAndy » Thu Oct 13, 2022 9:45 am

Zax wrote:
Thu Oct 13, 2022 7:44 am
The app was created and tested on MacOS Sierra.
Hmm, ok, so then we've narrowed it down to Macs post-Sierra (a somewhat outdated macOS version) or possibly limited to MY Macs... :?

I tried to decipher the prefs file, to see which value is actually stored, but could not get legible data out of it. I assumed you use arrayEncode/Decode, but that alone did not work to convert it. Or is it XML?
Andreas Bergendal
Independent app and system developer
Free LC dev tools: https://github.com/wheninspace
WhenInSpace: https://wheninspace.se/en

Zax
Posts: 487
Joined: Mon May 28, 2007 10:12 am
Location: France
Contact:

Re: Create a button's icon with a part of a big image? - Beleaguered Castle

Post by Zax » Thu Oct 13, 2022 1:23 pm

SWEdeAndy wrote:
Thu Oct 13, 2022 9:45 am
.I tried to decipher the prefs file, to see which value is actually stored, but could not get legible data out of it. I assumed you use arrayEncode/Decode, but that alone did not work to convert it. Or is it XML?
I used arrayEncode/Decode.

Code: Select all

put URL ("binfile:" & prefsFile) into encodedArr
put arrayDecode(encodedArr) into savedUserPrefs

Dump of my prefs file (nested arrays):
Array
. [screenSettings] = Array
. . [MCwwLDE5MjAsMTIwMAotMTkyMCwwLDAsMTIwMA==] = Array // screens configs
. [checkedDate] = 1980.01.01
. [prefs] = Array
. . [board] = Array
. . . [hilite] = 253,159,40
. . . [cardSet] = Castle Special
. . . [background] = Pool
. . . [foundHilite] = 3,193,156
. . . [hiliteBorder] = 114,171,239
. . [sounds] = 1
. . [stats] = Array
. . . [gameWonCount] = 5
. . . [gameLaunchedCount] = 18
. . . [topScores] = Array
. . . . [136] = Array
. . . . . [date] = 1665643052
. . . . . [gameid] = 1665642770
. . . . . [name] = thierry
. . . . [124] = Array
. . . . . [date] = 1665558837
. . . . . [gameid] = 1665558408
. . . . . [name] = thierry
. . . . [142] = Array
. . . . . [name] = thierry
. . . . . [gameid] = 1665570291
. . . . . [date] = 1665570617
. . . . [110] = Array
. . . . . [name] = thierry
. . . . . [gameid] = 1665483151
. . . . . [date] = 1665483347
. . . . [180] = Array
. . . . . [date] = 1665471394
. . . . . [gameid] = 1665470984
. . . . . [name] = thierry
. . . [dateInit] = 1665470849
. . . [gamePlayedCount] = 11
. . [prefsVersion] = 0.32

SWEdeAndy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 265
Joined: Sat Aug 16, 2008 9:48 am
Location: Stockholm, Sweden
Contact:

Re: Create a button's icon with a part of a big image? - Beleaguered Castle

Post by SWEdeAndy » Thu Oct 13, 2022 4:23 pm

Ah, of course, "binfile"! I had forgotten that's the format when saving arrays to disk.

So, I can now read the file, but it doesn't give any hint as to how the game can arrive at more games won than played.

To really find the bug, I think you'll either need to send me the LC stack or at least a cut down version with the score calculation scripts — or implement some logging that documents each step when updating and reading the stats, so we can (hopefully) catch where the 'octupling' occurs on my computers.

(The amount of time we spend on this error hunt may seem silly, but I tend to see every such exercise as a learning experience, which may prove valuable if/when similar problems occur in other projects, that may be more business crucial. :) )
Andreas Bergendal
Independent app and system developer
Free LC dev tools: https://github.com/wheninspace
WhenInSpace: https://wheninspace.se/en

Zax
Posts: 487
Joined: Mon May 28, 2007 10:12 am
Location: France
Contact:

Re: Create a button's icon with a part of a big image? - Beleaguered Castle

Post by Zax » Fri Oct 14, 2022 8:48 am

Before posting the code (which is quite complicated), I think it would be interesting to determine if the weird stats you are seeing are coming from the preferences file, or from displaying data in the statistics dialog.
So, now that you can access the data from the preferences file, the following test could be done:

1 - make sure the game is not running
2 - delete the "BCastle_Prefs.ixp" and "BCastle_Savegame.ixp" files
3 - start the game and play a game (it doesn't matter if you win or not)
4 - when the game is over (blocked or won), don't display the stats and quit the game, which will write the prefs
5 - decode the stats file and study it
6 - repeat the process, without displaying the stats in the game, and quitting the game after each game

This way, I think we would be able to determine if the stats are correctly saved into the prefs file.

SWEdeAndy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 265
Joined: Sat Aug 16, 2008 9:48 am
Location: Stockholm, Sweden
Contact:

Re: Create a button's icon with a part of a big image? - Beleaguered Castle

Post by SWEdeAndy » Sat Oct 15, 2022 2:31 pm

Good idea! I've done that now and here is the result:

Playing 9 blocked games (never opening the stats view), and regularly quitting and checking the prefs file, gives:
gameLaunchedCount: 9
gamePlayedCount: 8
gameWonCount: 0

All seems fine so far.

Then I won the 10th game and quit, and the prefs file gives:
gameLaunchedCount: 10
gamePlayedCount: 10
gameWonCount: 8

So something goes wrong already at this stage. I've noticed though that it's not always a multiple of 8! On another Mac I have 6 won games and the stats say 50 won games (should be 48 if it were consequently a multiple of 8 ). So the mystery deepens... :?
Andreas Bergendal
Independent app and system developer
Free LC dev tools: https://github.com/wheninspace
WhenInSpace: https://wheninspace.se/en

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7258
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Create a button's icon with a part of a big image? - Beleaguered Castle

Post by jacque » Sat Oct 15, 2022 5:57 pm

That's very strange. Could the game be updating the scores in more than one place? That might cause multiple additions.

I had some similar issues with prefs once and decided to update scores immediately at the conclusion of the game, which fixed the problem. But my game was showing too low scores, the opposite of this one.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”