Ralph wrote:Not sure if this is a bug, or just how valuators behave, but you can't do this
(...)
The vaulator line will fail with index number does not exist. It seems when you call an instance function as a valuator, the class function (foo.compare) is called rather than the instance one (fooinstance.compare), hence it cannot access instance variables, I guess a workaround is to pass the instance in as a parameter, but its not very neat.
Forgive me if this has come up before/is just the way things work.
Too bad this can't work. If you call 'fooinstance.compare', on the stack really is pushed foo.compare, and the instance it belongs to is lost (for ever). Therefor, the Valuator function has no way of knowing which instance 'fooinstance' is. To avoid strange crashes and other Squirrel related stuff, the 'list' instance is sent as 'this' (yes, VERY bad, I know, but there is no other way for now). I looked at the code, looked in the stack, and in many other places, but I see no way to solve this problem now or in the near future ... so for now I suggest not using such functions, and give the 'number' as extra param (like in the examples). The function in the Valuator is STATICly called, and should be handled as such

The only thing necessary for the triumph of evil is for good men to do nothing.