So i tryied this
But it won't work and i get no errors
- Code: Select all
var headItems = ["Cue", "Tokens"];
inv.head_txt.text = TheClient.payVault.count(headItems).toString();
by oonka » October 23rd, 2015, 1:17 am
var headItems = ["Cue", "Tokens"];
inv.head_txt.text = TheClient.payVault.count(headItems).toString();
by Guillaume » October 23rd, 2015, 9:16 pm
by oonka » October 23rd, 2015, 9:18 pm
by Guillaume » October 23rd, 2015, 9:48 pm
public static string ItemsCountCanonical(Client client, string[] itemsId)
{
string canonicalResult = string.Empty;
for (int i = 0 ; i < items.Length ; i++)
{
int nb = client.payVault.Count(items[i]);
canonicalResult += items[i] + ": " + nb.ToString();
if (i + 1 < items.Length)
canonicalResult += ", ";
}
return canonicalResult;
}
public static int ItemsGroupCount(Client client, string[] itemsId)
{
int nb = 0;
for (int i = 0 ; i < items.Length ; i++)
{
nb += client.payVault.Count(items[i]);
}
return nb;
}
by oonka » October 23rd, 2015, 9:50 pm
by oonka » October 23rd, 2015, 9:59 pm
Guillaume wrote:Yes, but from what i see of your code, i don't know what you are expecting as return value.
It would be easier to write your own method/class method in order to do that.
Something like:
- Code: Select all
public static string ItemsCountCanonical(Client client, string[] itemsId)
{
string canonicalResult = string.Empty;
for (int i = 0 ; i < items.Length ; i++)
{
int nb = client.payVault.Count(items[i]);
canonicalResult += items[i] + ": " + nb.ToString();
if (i + 1 < items.Length)
canonicalResult += ", ";
}
return canonicalResult;
}
However, if your goal was to create a super items counter, and return all the matched value, just do this:
- Code: Select all
public static int ItemsGroupCount(Client client, string[] itemsId)
{
int nb = 0;
for (int i = 0 ; i < items.Length ; i++)
{
nb += client.payVault.Count(items[i]);
}
return nb;
}
Thats all.