I'm not really sure what you're trying to do so it's hard to pinpoint the problem. You may have simply forgot to load the player's bank before checking it. Or it may need to be decrypted if you are using any kind of encryption.
True. What I am trying to do is find out if the player has completed each difficulty level (there are 6) with a certain unit, let's say Marine. The bank are loaded and the encryption/decryption works fine as the values in the first example directly translate to the variables in the second example. The only thing is, is that the loop doesn't seem to realize when the statement is true, which is odd, because when I type it out (first example) it works fine.
I was just trying to find out if there is an error in my loop that I am not seeing. The loop (should) works like this:
Loop through the difficulty levels and through the types of units (all have been assigned numbers for ease of tracking). So it runs like this: Unit 1 - Difficulty 1 - true/false. Unit 1 - Difficulty 2 - true/false etc...
In the first example, znevar is Marine and the letter in front of that is for the difficulty level that I combine together with Combine String. The values are like that in the bank file, but the loop somehow doesn't go into the true part.
If you could just look at the loop and see if there are any errors that I am not seeing, that would be great. :)
True. What I am trying to do is find out if the player has completed each difficulty level (there are 6) with a certain unit, let's say Marine. The bank are loaded and the encryption/decryption works fine as the values in the first example directly translate to the variables in the second example. The only thing is, is that the loop doesn't seem to realize when the statement is true, which is odd, because when I type it out (first example) it works fine.
I was just trying to find out if there is an error in my loop that I am not seeing. The loop (should) works like this:
Loop through the difficulty levels and through the types of units (all have been assigned numbers for ease of tracking). So it runs like this: Unit 1 - Difficulty 1 - true/false. Unit 1 - Difficulty 2 - true/false etc...
In the first example, znevar is Marine and the letter in front of that is for the difficulty level that I combine together with Combine String. The values are like that in the bank file, but the loop somehow doesn't go into the true part.
If you could just look at the loop and see if there are any errors that I am not seeing, that would be great. :)
Faust
Okay, I think I understand now. There are two possibilities that I can think of.
The first is that the condition function "(Bank Player_Bank[(Picked player)] has Bank Terran Unit Encryption Difficulty and Unit[i][n] in section "cynlre") == True" is not checking what you think it's checking. If these two elements are combined into a single string within the bank, then this function might be checking for two separate elements, and since they are always combined it will always return false. It might help to extract all of these elements into a single string and use the "String Contains Substring" function. I usually save all relevant data into a single string anyway when banking because it keeps the banks simple, though this may not work for you.
The other possibility is that your function is exceeding Starcraft 2's limits. The fact that you are stacking 3 loops on top of each other might simply be too much for Starcraft 2 to handle, so the only solution might be to use less efficient code.
@Stragus: I do that in the map initialize trigger. ;-) And I inserted variables which is how I found out that it isn't going into the loop at all.
@Bashar: Very possible that it is checking for 2 strings. That would at least explain why it is never true and also why the less efficient version works. You store all of your data in one long string and then use substring? That may be something I could implement. Would you give me a little example of how I can save something into a string that already exists? This is something I have never done, so details would be great!
@Stragus: I do that in the map initialize trigger. ;-) And I inserted variables which is how I found out that it isn't going into the loop at all.
Add many text messages. Add one after every single line, to see, when exactly it breaks.
Quote:
The other possibility is that your function is exceeding Starcraft 2's limits. The fact that you are stacking 3 loops on top of each other might simply be too much for Starcraft 2 to handle, so the only solution might be to use less efficient code.
Theoretically, the 3 nested loops should not be a problem, unless they are handled incorrectly.
For one player testing, we are talking about 1 x 6 x 12 = 72 executions, which is not a big deal.
You store all of your data in one long string and then use substring? That may be something I could implement. Would you give me a little example of how I can save something into a string that already exists? This is something I have never done, so details would be great!
Convert all of the data you want to save into separate strings. Then concatenate those strings into one long string. Then encrypt and bank the long string. When loading, decrypt the long string, then use the Word of String or Substring functions to split the long string into smaller strings again. For example:
These strings indicate 1) the unit, 2) the difficulty, and 3) a binary integer to determine whether the combination was completed or not. In other words, this player beat both easy and medium difficulties with a marine, but not hard.
Next, use the Set Variable action and the Combine Strings Multiple function to concatenate, separating with a space:
Encrypt, bank, decrypt, load, and you should have the same string.
Now set String 1 = Word 1 of String 4; String 2 = Word 2 of String 4; String 3 = Word 3 of String 4
As I said, this makes things easy for me but it may or may not work for you. At this point, you would simply need to check if each string contains the number 1 to find out if that particular combination has been completed, then act accordingly.
The Bank Terran Unit Encryption Difficulty and Unit[1][1] would be then (easy difficulty encrypted + marine encrypted) which is definately in the bank file so the statement should return true, but I think it is checking something else like BasharTeg said. I am still anaylizing it when I get time and will post my results when I figure it out, or if I give up and just hardcode it. :-)
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
Hi guys,
I have the following in a save trigger:
Note: There are only 4 players at most. This: "Algorythm_Rank[(Picked player)][12] = 1" refers to the 12th unit type and not 12th player
This works just fine, but is very inefficient. I had this in a loop with arrays but it wasn't saving. See here:
I can't figure out why this isn't working. Any tips on something I may have missed? The values exist in the player bank, but somehow it doesn't work.
Thanks!!
Faust
I'm not really sure what you're trying to do so it's hard to pinpoint the problem. You may have simply forgot to load the player's bank before checking it. Or it may need to be decrypted if you are using any kind of encryption.
@BasharTeg: Go
True. What I am trying to do is find out if the player has completed each difficulty level (there are 6) with a certain unit, let's say Marine. The bank are loaded and the encryption/decryption works fine as the values in the first example directly translate to the variables in the second example. The only thing is, is that the loop doesn't seem to realize when the statement is true, which is odd, because when I type it out (first example) it works fine.
I was just trying to find out if there is an error in my loop that I am not seeing. The loop (should) works like this:
Loop through the difficulty levels and through the types of units (all have been assigned numbers for ease of tracking). So it runs like this: Unit 1 - Difficulty 1 - true/false. Unit 1 - Difficulty 2 - true/false etc...
In the first example, znevar is Marine and the letter in front of that is for the difficulty level that I combine together with Combine String. The values are like that in the bank file, but the loop somehow doesn't go into the true part.
If you could just look at the loop and see if there are any errors that I am not seeing, that would be great. :)
Faust
Did you do a "Bank - Preload and synchronize bank "foobar" for player X"?
You need one of these for each bank and for each player. The strings and player number must be immediates, they can't be variables or computed values.
After that, I would insert plenty of "text messages" to check what's going on inside the loop.
Okay, I think I understand now. There are two possibilities that I can think of.
The first is that the condition function "(Bank Player_Bank[(Picked player)] has Bank Terran Unit Encryption Difficulty and Unit[i][n] in section "cynlre") == True" is not checking what you think it's checking. If these two elements are combined into a single string within the bank, then this function might be checking for two separate elements, and since they are always combined it will always return false. It might help to extract all of these elements into a single string and use the "String Contains Substring" function. I usually save all relevant data into a single string anyway when banking because it keeps the banks simple, though this may not work for you.
The other possibility is that your function is exceeding Starcraft 2's limits. The fact that you are stacking 3 loops on top of each other might simply be too much for Starcraft 2 to handle, so the only solution might be to use less efficient code.
@BasharTeg: Go
@Stragus: I do that in the map initialize trigger. ;-) And I inserted variables which is how I found out that it isn't going into the loop at all.
@Bashar: Very possible that it is checking for 2 strings. That would at least explain why it is never true and also why the less efficient version works. You store all of your data in one long string and then use substring? That may be something I could implement. Would you give me a little example of how I can save something into a string that already exists? This is something I have never done, so details would be great!
Thanks!
Add many text messages. Add one after every single line, to see, when exactly it breaks.
Theoretically, the 3 nested loops should not be a problem, unless they are handled incorrectly.
For one player testing, we are talking about 1 x 6 x 12 = 72 executions, which is not a big deal.
@Kueken531: Go
Danke Kueken! I forgot to mention that I am using 3 nested loops in other triggers and it works fine. :-)
I will try debugging again, adding more text messages. We'll see what I come up with.
@Faust7777: Go
Convert all of the data you want to save into separate strings. Then concatenate those strings into one long string. Then encrypt and bank the long string. When loading, decrypt the long string, then use the Word of String or Substring functions to split the long string into smaller strings again. For example:
String 1: marine_easy_1
String 2: marine_medium_1
String 3: marine_hard_0
These strings indicate 1) the unit, 2) the difficulty, and 3) a binary integer to determine whether the combination was completed or not. In other words, this player beat both easy and medium difficulties with a marine, but not hard.
Next, use the Set Variable action and the Combine Strings Multiple function to concatenate, separating with a space:
String 4: marine_easy_1 marine_medium_1 marine_hard_0
Encrypt, bank, decrypt, load, and you should have the same string.
Now set String 1 = Word 1 of String 4; String 2 = Word 2 of String 4; String 3 = Word 3 of String 4
As I said, this makes things easy for me but it may or may not work for you. At this point, you would simply need to check if each string contains the number 1 to find out if that particular combination has been completed, then act accordingly.
@BasharTeg: Go
Very nice! I will definately give this a shot. It may prove to help alot. Thank you so much!
@Faust7777: Go
Can you explain exactly what is not working. And how you know it is not working?
@SouLCarveRR: Go
Yes. This statement:
Is never true, even though it should be. For example if the current statement is this:
The Bank Terran Unit Encryption Difficulty and Unit[1][1] would be then (easy difficulty encrypted + marine encrypted) which is definately in the bank file so the statement should return true, but I think it is checking something else like BasharTeg said. I am still anaylizing it when I get time and will post my results when I figure it out, or if I give up and just hardcode it. :-)