I have a "save bank" and "load bank" action. The only Bank actions in the save are Store string (storing a StarCode string) and Bank - Save bank. I can save and then load within a game fine. I can get values to change between saves/loads.
My problem is that if I try to load the string before saving it in a given game instance, it will return a blank string. I can open the SC2Bank file and see my value there as saved from the last game just fine, but the game is simply refusing to read the file. Once I save the bank explicitly, I can then load to my heart's content for the rest of the game.
So...why is that I need to store a string and save a bank file in a game instance before I can reload that data?
I *am* using StarCode, which I indicated in my original post.
The problem is with pulling data from Banks on map init, not with StarCode functionality. I am indeed preloading/syncing and then opening. However, this refuses to happen on map init or by calling directly *unless* I've called my Save function first in that game session. Is there anything off the top of anyone's head that would cause this? It makes no sense to me why I should have to save something before loading it - totally defeats the purpose of Banks.
You defiantly do not have to save your banks before loading them I certainty don't. No idea what might cause you to be unable to load before saving. Maybe you could post the triggers you are using to handle banks so we can see if you did anything wrong?
Oh, sorry, must have skipped over that part where you said it was StarCode. Silly me :P
Try preloading, synchronizing, and opening after map initialization. In other words, make a trigger with the event "0.5 seconds Game Time have elapsed" or whatever it is. Then under actions do the preloading, syncing, and opening.
I already tested that idea with just triggering my functions using chat commands like "load" and "save". I am getting 100% consistent results with this: if I try to run the load functions before running save in a given game session, load always returns empty strings. Once I run the save functions, though, it's all good. And the bank file definitely exists and holds the correct data before launching the game and after closing the game. The problem is when loading before saving in a game session. Attached are relevant parts of the code. This shows absolutely every "Bank" function I'm using.
Keep in mind all of this is being done by using Test Document on my local machine. Also note that I have SC2 installed on E: drive instead of the default C: (Bank files are on my C: drive though in My Documents) ... neither of those should have any effect but I did want to mention my special cases here since we're dealing with runtime-generated files.
Oh, I see your problem. You have to preload, sync, and open banks directly. You can't reference them as variables - at least when doing these functions. And you have to do it directly for each player.
I don't believe you are correct that you can't reference bank names as variables...I have a bank file with data in it on my hard drive and I watch it get updated using the code above. I know everyone says what you're saying, but it's incorrect. Blizzard must have fixed in recent update, because otherwise the SC2Bank would not be sitting there on my HD. AGAIN: I can read/write to my bank. The problem is that the game is requiring the Save function before the Load function will return anything other than a null string.
CONFIRM: Replacing with hand-typed strings has no effect on my problem.
If you'll notice, recPlayer is an array of records. Each player has its own bBank member of that record, so they are definitely separated. You'll notice I also am passing in the player ID as a parameter, so I believe everything is correct in that regard.
Thanks for your posts...keep those ideas coming if you have any more :)
Try simplifying your process. Do a simple bank like the STARCODE tutorial and see if that doesn't work. If it does, then break down your process step by step until you find where the problem is happening. If even the simple bank doesn't work, you might be dealing with a corrupt map file.
The bank tutorial I originally learned to use banks also said not to use variables in preload or as names in save/load so even if that wasn't your problem there is some precedent for it.
Spent some time on this. It turns out you can't pass variables in for player integers either. That seems to be the problem. So I'll have to have a case statement that checks a parameter and then hard-codes the values of player number in. Is this normal?
Sorry I misunderstood what you meant by "direct". Using the words "literal string" or "hand-typed" would have been more clear in that context I think. Just sayin' :)
I have a "save bank" and "load bank" action. The only Bank actions in the save are Store string (storing a StarCode string) and Bank - Save bank. I can save and then load within a game fine. I can get values to change between saves/loads.
My problem is that if I try to load the string before saving it in a given game instance, it will return a blank string. I can open the SC2Bank file and see my value there as saved from the last game just fine, but the game is simply refusing to read the file. Once I save the bank explicitly, I can then load to my heart's content for the rest of the game.
So...why is that I need to store a string and save a bank file in a game instance before I can reload that data?
I recommend you check out STARCODE. It's a handy tool for banking. The page has a nice downloadable map that explains the banking process rather well.
I suspect that you are not properly initializing your bank files. You have to preload, synchronize, and open the bank every game.
@BasharTeg: Go
I *am* using StarCode, which I indicated in my original post.
The problem is with pulling data from Banks on map init, not with StarCode functionality. I am indeed preloading/syncing and then opening. However, this refuses to happen on map init or by calling directly *unless* I've called my Save function first in that game session. Is there anything off the top of anyone's head that would cause this? It makes no sense to me why I should have to save something before loading it - totally defeats the purpose of Banks.
You defiantly do not have to save your banks before loading them I certainty don't. No idea what might cause you to be unable to load before saving. Maybe you could post the triggers you are using to handle banks so we can see if you did anything wrong?
Oh, sorry, must have skipped over that part where you said it was StarCode. Silly me :P
Try preloading, synchronizing, and opening after map initialization. In other words, make a trigger with the event "0.5 seconds Game Time have elapsed" or whatever it is. Then under actions do the preloading, syncing, and opening.
@BasharTeg: Go
I already tested that idea with just triggering my functions using chat commands like "load" and "save". I am getting 100% consistent results with this: if I try to run the load functions before running save in a given game session, load always returns empty strings. Once I run the save functions, though, it's all good. And the bank file definitely exists and holds the correct data before launching the game and after closing the game. The problem is when loading before saving in a game session. Attached are relevant parts of the code. This shows absolutely every "Bank" function I'm using.
Keep in mind all of this is being done by using Test Document on my local machine. Also note that I have SC2 installed on E: drive instead of the default C: (Bank files are on my C: drive though in My Documents) ... neither of those should have any effect but I did want to mention my special cases here since we're dealing with runtime-generated files.
Oh, I see your problem. You have to preload, sync, and open banks directly. You can't reference them as variables - at least when doing these functions. And you have to do it directly for each player.
@BasharTeg: Go
I don't believe you are correct that you can't reference bank names as variables...I have a bank file with data in it on my hard drive and I watch it get updated using the code above. I know everyone says what you're saying, but it's incorrect. Blizzard must have fixed in recent update, because otherwise the SC2Bank would not be sitting there on my HD. AGAIN: I can read/write to my bank. The problem is that the game is requiring the Save function before the Load function will return anything other than a null string.
CONFIRM: Replacing with hand-typed strings has no effect on my problem.
If you'll notice, recPlayer is an array of records. Each player has its own bBank member of that record, so they are definitely separated. You'll notice I also am passing in the player ID as a parameter, so I believe everything is correct in that regard.
Thanks for your posts...keep those ideas coming if you have any more :)
Try simplifying your process. Do a simple bank like the STARCODE tutorial and see if that doesn't work. If it does, then break down your process step by step until you find where the problem is happening. If even the simple bank doesn't work, you might be dealing with a corrupt map file.
@BasharTeg: Go
I was afraid you were going to say that... :(
The bank tutorial I originally learned to use banks also said not to use variables in preload or as names in save/load so even if that wasn't your problem there is some precedent for it.
Spent some time on this. It turns out you can't pass variables in for player integers either. That seems to be the problem. So I'll have to have a case statement that checks a parameter and then hard-codes the values of player number in. Is this normal?
Yes, that's why I said, "And you have to do it directly for each player." :P
@BasharTeg: Go
Sorry I misunderstood what you meant by "direct". Using the words "literal string" or "hand-typed" would have been more clear in that context I think. Just sayin' :)
Thanks you for this topic. I had forgot that you couldn't use variables in preload bank.