Error in combu scri...
 
Notifications
Clear all

Error in combu script

7 Posts
2 Users
0 Reactions
1,084 Views
(@artyom)
Posts: 16
Eminent Member
Topic starter
 

Hello,
I have this error :
"Error CS1660 Cannot convert lambda expression to type 'IComparer<T>' because it is not a delegate type lastTime.CSharp" CombuScriptsCombuPlatform.cs 178

What can I do with that?

 
Posted : 29/10/2015 2:15 pm
(@skaredcreations)
Posts: 805
Prominent Member Admin
 

I haven't any Sort or Comparer at line 178 of latest Combu, can you please post the line?

EDIT:

Nevermind, I was looking at older scripts, I see achievements.Sort at that line, I'll investigate.

FRANCESCO CROCETTI @ SKARED CREATIONS

 
Posted : 29/10/2015 2:36 pm
(@artyom)
Posts: 16
Eminent Member
Topic starter
 

achievements.Sort((Achievement a, Achievement b) => {

 
Posted : 29/10/2015 2:41 pm
(@skaredcreations)
Posts: 805
Prominent Member Admin
 

I tried to call the following after a successful login but I'm not having any warning/error:

CombuManager.platform.LoadAchievements((IAchievement[] obj) => {
   Debug.Log(obj.Length);
});

What Unity version and platform (and deploy platform) are you using?

Also I read something about "lastTime" but we haven't any variable with this name in our scripts.

FRANCESCO CROCETTI @ SKARED CREATIONS

 
Posted : 29/10/2015 2:46 pm
(@artyom)
Posts: 16
Eminent Member
Topic starter
 

Skared Creations said
I tried to call the following after a successful login but I'm not having any warning/error:

CombuManager.platform.LoadAchievements((IAchievement[] obj) =&gt; {
   Debug.Log(obj.Length);
});

What Unity version and platform (and deploy platform) are you using?

Also I read something about "lastTime" but we haven't any variable with this name in our scripts.

No, lastTime - this is my script,  LastTimeUser.cs 
Unity 5.2.1

Microsoft Visual Studio Community 2015 - IDE

Unity web player

I have this error in Visual Studio, Unity works correct...

 
Posted : 29/10/2015 2:52 pm
(@skaredcreations)
Posts: 805
Prominent Member Admin
 

Try this in Achievement.cs

  • add the interface IComparer to declaration:
public class Achievement : IAchievement, IAchievementDescription, IComparer

  • add the following code in the class Achievement (you can probably remove the comparer in CombuPlatform.LoadAchievements and call directly Sort without parameter, try that too):
#region IComparer implementation

public int Compare (object x, object y)
{
   IAchievement a = (IAchievement)x;
   IAchievement b = (IAchievement)y;
   long idA = long.Parse(a.id);
   long idB = long.Parse(b.id);
   if (idA == idB)
      return a.percentCompleted.CompareTo(b.percentCompleted);
   return idA.CompareTo(idB);
}

#endregion

See if this will solve VS complain.

FRANCESCO CROCETTI @ SKARED CREATIONS

 
Posted : 29/10/2015 3:06 pm
(@artyom)
Posts: 16
Eminent Member
Topic starter
 

It works in visual studio , but if in CombuPlatform remove this

achievements.Sort((Achievement a, Achievement b) => {
long idA = long.Parse(a.id);
long idB = long.Parse(b.id);
if (idA == idB)
return a.percentCompleted.CompareTo(b.percentCompleted);
return idA.CompareTo(idB);
});

and I write this

achievements.Sort();

In Unity I have this error:

ArgumentException: does not implement right interface
System.Collections.Generic.Comparer`1+DefaultComparer[Combu.Achievement].Compare (Combu.Achievement x, Combu.Achievement y) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Collections.Generic/Comparer.cs:86)
System.Array.compare[Achievement] (Combu.Achievement value1, Combu.Achievement value2, IComparer`1 comparer) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System/Array.cs:1744)
System.Array.qsort[Achievement,Achievement] (Combu.Achievement[] keys, Combu.Achievement[] items, Int32 low0, Int32 high0, IComparer`1 comparer) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System/Array.cs:1721)
System.Array.Sort[Achievement,Achievement] (Combu.Achievement[] keys, Combu.Achievement[] items, Int32 index, Int32 length, IComparer`1 comparer) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System/Array.cs:1674)
Rethrow as InvalidOperationException: The comparer threw an exception.
System.Array.Sort[Achievement,Achievement] (Combu.Achievement[] keys, Combu.Achievement[] items, Int32 index, Int32 length, IComparer`1 comparer) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System/Array.cs:1677)
System.Array.Sort[Achievement] (Combu.Achievement[] array, Int32 index, Int32 length, IComparer`1 comparer) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System/Array.cs:1623)
System.Collections.Generic.List`1[Combu.Achievement].Sort () (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Collections.Generic/List.cs:568)
Combu.CombuPlatform+c__AnonStorey30`1[Combu.Achievement].<>m__3A (System.String text, System.String error) (at Assets/AllScripts/Combu/Scripts/CombuPlatform.cs:185)
Combu.CombuManager+c__Iterator1.MoveNext () (at Assets/AllScripts/Combu/Scripts/CombuManager.cs:411)

 
Posted : 05/11/2015 8:42 am
Share: