Hi @tall-story-games.
Sorry for being so late to the party, I had a couple intense weeks and I ended up postpone this reply.
As I told you, my solution basically relies on counting savegame files to understand what to do. To better explain what we did, it's better to look at the first screenshot.
As you can see, a savegame is present and the picture is selected. We can load the savegame or save over it. Simple stuff.
What is very baffling is that if you click on a different empty area (and it becomes highlighted), the next savegame will end up in the first free slot. Which, from a user's perspective, seems like a bug.
Moreover, if you leave the area selected (and I didn't find a way to deselect it) and go on pressing the save button, more savegames will be queued, until you reach your selection. From there on, all the other clicks will create a savegame in your selected area.
There are many workaro... solutions to this, but we thought the less odd for the user is that, when you click on an empty area, no matter which, the first free slot is selected and highlighted.
This stil seems like a bug but at least it's clear to the user what will happen when "Save" button is clicked.
To select the first empty slot, no matter which one you click, I created this script:
local getFilesCommand
local files = {}
local tmpFile = localAppDir .. 'savegame.count.tmp'
if package.config:sub(1,1) == '/' then
-- We are on a Unix filesystem, use ls
getFilesCommand = "ls -1 " .. localAppDir:gsub(" ", "\\ ") .. "Savegames/savegame*.dat" .. " > '" .. tmpFile .. "'"
else
-- We are on Windows (or non-unix at least), use dir
getFilesCommand = "dir " .. localAppDir .. "Savegames/savegame*.dat" .. " > " .. tmpFile
end
os.execute(getFilesCommand)
-- Count the saved games
local SavegameCount = 0
for _ in io.lines(tmpFile) do
SavegameCount = SavegameCount + 1
end
os.remove(tmpFile)
-- Highlight the first empty savegame slot available
Scenes['Menu - Savegame'].Values['selected_slot'].Int = SavegameCount + 1
Lua has no way to list a folder's content (if not with external extensione that I can't use in Visionaire), so I had to rely on a command.
Also, Visionaire doesn't seem to support
popen(), which would have allowed me to read the output in a variable. So, redirecting the command output to a file, then opening the file and reading the content did the trick.
Once I got the file count, I was able to do highlight the first free slot.
Now, despite being pretty proud of how we made it work, I still feel we had to choose between two different "WTF", decide which one was bigger and take the other road.
We then spent the last couple weeks wrestling with Visionaire to create a barely decent set of menus and settings screens for the game. This experience really killed my buzz.
Despite the first approaches with visionaire allowed us to set a game up very quickly, I experienced how limited it is on many aspects other than the bulk of the game management (scenes, animations, characters, etc). And this is scary, from a developer perspective. I feel that at some point I may stumble onto a limitation that will hinder my creativity.
I totally understand that Visionare is a tool aimed towards creatives with little coding skills, so I may personally be out of target. But I also think that a creative with little coding skill may be not able to come up with something like the above. If such, the guy should reconsider his own coding skills and be less scared to get his hands dirty.
Sorry for the little rant. Hope this script may be useful to someone else anyway!
Cheers