I'm working on a journal GUI where the journal starts out with a few pages, and then at certain points in the game new pages are added to the journal. My problem is that, unlike the other threads on journal scripting that I was able to find in AGS, my journal is made up of sprites. This is how I plan to do it:
1. declare all sprite slots in an array
2. save states in a globalint, starting from 1 (or however many starting pages)
3. set button as page image
4. in the GUI where you click on a button to turn a page, script the button so that it checks the state of the globalint:
while (globalint > 0) {
// change page button sprite according to array
// decrease globalint
}
The problem is, I have no clue how to actually declare sprite slot numbers in an array, much less change the page button sprite according to the array. I don't even know if this is possible.
Is there an easier way to do this? Or is there a way to make my idea work?
Thanks in advance for help rendered :)
At the top of the global script, declare the array, then set the array in game_start:
int page[100];
...
function game_start() {
page[1] = 54;
page[2] = 55;
...
}
In the button's code for advancing a page:
pagebutton.NormalGraphic = page[x];
I'd use consecutive numbers as page sprite slots, because then you don't need an array. If, as in my example code, the first page was sprite 54, you'd simply in-/decrease the current_page variable, then set the button's .NormalGraphic to current_page + 53.
Thanks KhrisMUC. I did think of using consecutive sprite slots, but then I remembered that there's a certain amount of non-linearity in my game, in which players can do a range of actions in any order or even not at all. The journal pages would have to be flexible enough to accomodate that.
I'll try out your solution :) Thanks again!