Jump to content
RealModScene
Sign in to follow this  
Gualdimar

Sorting lua script

Recommended Posts

You can setup your own sorting script you know... you can set one up that sorts by last played game followed by alphabetical order...

is it possible? as i understand, this sorting type require two cycles. first cycle sorts items by last played time, second - by name excluding first item. or you need some buffer to store last played game and in the end of sorting put it in the first place.

but how can you achieve this? functions in lua files only compare two items and you can`t tell what iteration is running or what items are in process

  • Like 1

Share this post


Link to post
Share on other sites

from this topic: http://www.realmodscene.com/index.php?/topic/3824-aurora-quick-launch-to-start-the-last-played-game/

is it possible? as i understand, this sorting type require two cycles. first cycle sorts items by last played time, second - by name excluding first item. or you need some buffer to store last played game and in the end of sorting put it in the first place.

but how can you achieve this? functions in lua files only compare two items and you can`t tell what iteration is running or what items are in process

The way you do it is by first checking if they're on the same time, if not; compare that, if they're the same you change the comparison to title...

It's all done in a single function =)

Share this post


Link to post
Share on other sites

The way you do it is by first checking if they're on the same time, if not; compare that, if they're the same you change the comparison to title...

It's all done in a single function =)

tried it, result: all games that i have played were sorted by time and only those with "last played time: never" - by name.

here is the code:

GameListSorters["MySort"] = function(Item1, Item2, Type)
	-- Check if sort Descending
	if Type == SortType.Descending then
	   if Item2.LastPlayed.HighPart == Item1.LastPlayed.HighPart then
	      if Item2.LastPlayed.LowPart == Item1.LastPlayed.LowPart then
	         return string.lower(Item1.Name) > string.lower(Item2.Name)
	      end
	      return Item2.LastPlayed.LowPart > Item1.LastPlayed.LowPart
	   end
	   return Item2.LastPlayed.HighPart > Item1.LastPlayed.HighPart
	end

	-- Sort Ascending
	if Item2.LastPlayed.HighPart == Item1.LastPlayed.HighPart then
	   if Item2.LastPlayed.LowPart == Item1.LastPlayed.LowPart then
	      return string.lower(Item1.Name) < string.lower(Item2.Name)
	   end
	   return Item2.LastPlayed.LowPart < Item1.LastPlayed.LowPart
	end
	return Item2.LastPlayed.HighPart < Item1.LastPlayed.HighPart
end 

Share this post


Link to post
Share on other sites

tried it, result: all games that i have played were sorted by time and only those with "last played time: never" - by name.

here is the code:

GameListSorters["MySort"] = function(Item1, Item2, Type)
	-- Check if sort Descending
	if Type == SortType.Descending then
	   if Item2.LastPlayed.HighPart == Item1.LastPlayed.HighPart then
	      if Item2.LastPlayed.LowPart == Item1.LastPlayed.LowPart then
	         return string.lower(Item1.Name) > string.lower(Item2.Name)
	      end
	      return Item2.LastPlayed.LowPart > Item1.LastPlayed.LowPart
	   end
	   return Item2.LastPlayed.HighPart > Item1.LastPlayed.HighPart
	end

	-- Sort Ascending
	if Item2.LastPlayed.HighPart == Item1.LastPlayed.HighPart then
	   if Item2.LastPlayed.LowPart == Item1.LastPlayed.LowPart then
	      return string.lower(Item1.Name) < string.lower(Item2.Name)
	   end
	   return Item2.LastPlayed.LowPart < Item1.LastPlayed.LowPart
	end
	return Item2.LastPlayed.HighPart < Item1.LastPlayed.HighPart
end 

Yeah, that's exactly how you would do it... otherwise, what did you expect to get? all with a date specified to be first?

That's also possible, you just check for whatever it would be when it's been played, and check if Item1 and 2 is set, then compare text, otherwise item1 goes before item2 or vice versa

Share this post


Link to post
Share on other sites

Yeah, that's exactly how you would do it... otherwise, what did you expect to get? all with a date specified to be first?

That's also possible, you just check for whatever it would be when it's been played, and check if Item1 and 2 is set, then compare text, otherwise item1 goes before item2 or vice versa

i wanted to show the last played game(only one latest title) in the begining of the list and all others in alphabetical order after it. cause the script i wrote has almost the same sorting order as the standart "Recent Activity" one.

but from everything i know for now, i assume this is impossible, unless implemented in aurora. correct me if i`m wrong

Share this post


Link to post
Share on other sites

i wanted to show the last played game(only one latest title) in the begining of the list and all others in alphabetical order after it. cause the script i wrote has almost the same sorting order as the standart "Recent Activity" one.

but from everything i know for now, i assume this is impossible, unless implemented in aurora. correct me if i`m wrong

It's not impossible, nothing is ever "impossible", it's all a matter of thinking correctly, it's not an easy task, and quite frankly, you don't need it, if you use the Quick Browse, it should show latest played game at the top, and all of the rest after that... meaning, it should be possible to just have it set to the sort that sorts by name, and use the Quick Browse feature to see the last game you played...

Share this post


Link to post
Share on other sites

It's not impossible, nothing is ever "impossible", it's all a matter of thinking correctly, it's not an easy task, and quite frankly, you don't need it, if you use the Quick Browse, it should show latest played game at the top, and all of the rest after that... meaning, it should be possible to just have it set to the sort that sorts by name, and use the Quick Browse feature to see the last game you played...

nope, quick browse(X button) shows titels in abc order, whithout last played at the top.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...