I've discovered a behaviour with event sheets that I find peculiar and I'm wondering if anyone else has discovered it, or whether it's normal.
The game I'm making has various levels that the player can revisit. Each level has its own sheet and each of those sheets access 3 common sheets that govern things that happen on every level the player visits, such as how the player moves and reacts, how the enemies move and react, etc.
As Persist makes it impossible to restart the game from scratch I'm using arrays to save the location and health of enemies upon exiting the level so if the player revisits it they'll find everything as they left it. At the end of the layout information is stored in the arrays, at the start of the layout information is being read from the arrays. The reading and writing of the arrays in on one of the common event sheets.
Now, after that long-winded introduction, here's the peculiar behaviour.
When you leave a level the game is writing to the arrays from the common sheet. I've tested it to make sure of this. When you go back to the level, however, the information isn't getting read back. The only way I seem to be able to make it read the information is by putting all of the array reading rules on the actual event sheet for the layout, not on one of the common sheets.
Is this a known problem? Is it working as intended and I'm unaware of this? I know as far as problems go it's a tiny one, after all, I can copy and paste the reading of the arrays to each layout in 10 seconds, but the behaviour itself makes no sense and I'm wondering if anyone can explain why it is so.
Nobody else had had this issue?
Are you able to recreate this in a new Capx?
I've had arrays that get updates on included pages, but I don't know how similar the situations are.
I too have encountered an issue with the array functions.
I load weapon quantities in one event sheet (layout A) then, on layout B using a different event sheet, I test for the quantity of weapons in the array to determine the opacity of some HUD icons. Of course the arrays are global. The opacity of the each HUD icon is determined by a value in the array. When tested using the 'Value At(x)' condition the icons are not displayed correctly, even though the array contains the expected value when viewed on the debugger. My work-around has been to load the required array quantity into another variable and then test that instead... I've literally just discovered this in the last 10 minutes and found this thread on the forum.
I also create loads of objects according to another global array - the x and y positions are loaded in one event sheet and then the array is subsequently used in another event sheet. All of the system Create Object functions seem to work correctly. So, to me it appears that the 'Value At(x)' test is broken even though the array data is there...
I'll try and produce an example capx later today if I can reproduce the error.
Not sure if it's related, but I find lots of issues with arrays where I need to add a 0.1 second wait between actions, or need to do the action in a non-sub event.
So really not sure why, but maybe you could try playing around with waits and positioning and see if that helps.
Develop games in your browser. Powerful, performant & highly capable.
Is it possible that the array is getting re-initialized in the common event sheet when the new layout is loaded?
I'm doing some things with global arrays but I haven't gotten to the point yet where I'm reading from the non-layout event sheet. When I get to that I'll keep an eye out for this!
I ran into this issue as well recently. I can't remember exactly what I was working on, but I did like Colludium did and just set the array.at to a variable and used the variable to compare.
I tried recreating it in a blank capx and I couldn't get it to happen so I assumed it was something else in my project. One thing was, I remember it being an older project that was started in a much earlier version of Construct 2.