Author Topic: Can we get proper array support?  (Read 1001 times)

http://www.garagegames.com/community/resources/view/4711

I have no proper way of sorting things (for leaderboards), and it's bogging down a server of mine.

everybody needs better arrays

The code file download link is 404

I have no proper way of sorting things (for leaderboards), and it's bogging down a server of mine.
what are you trying to sort?
currently the proper way is to probably do it yourself

what are you trying to sort?
currently the proper way is to probably do it yourself
I recently moved over from multiple for loops and global variables to just using a GuiTextListCtrl object
just trying to sort scores

What's stopping you from sorting? What do you need arrays for?

if you're trying to sort scores, you might be able to pull them sorted from the player list
isn't there options to sort based off of different values? ie BLID, name, score, admin status?

and if you only call it every so often, an insertion sort or binary sort could work well
if you're trying to keep something like a scoreboard updated, you could run a bubble sort once each time a player's score changes

If you're up for it, you can always write an external program to sort stuff, in your favorite language; that's what I did.

how would you shove the data in/out?
writing/reading to/from files?

how would you shove the data in/out?
writing/reading to/from files?
I had a program reading from standard output once, so i could communicate just with echo("some stuff in a specific format");
never got standard input to work properly though.
The easiest communication is through TCP.
I did it just for fun and loving around. It's a lot of hassle to set up an external program though. It would also make the add-on unreleasable
« Last Edit: September 11, 2015, 11:07:02 AM by Headcrab Zombie »

But really

What do you need arrays for?

You can do any kind of array manipulation you want in TorqueScript
You should not need to outsource anything to external programs

If you just need to sort some text or numbers, the text list ctrl is kinda the best way to go. It takes very little time to fill, uses c++ qsort internally, and takes little time to read. It'll be faster than sending stuff over tcp or file io any day.

Even works on dedicated servers, which doesn't make sense, but it does.

Even works on dedicated servers, which doesn't make sense, but it does.
Yeah I wasn't expecting it to work as well as it is, it just feels hacky to use it.

Yeah I wasn't expecting it to work as well as it is, it just feels hacky to use it.

new GuiTextListCtrl(TextSorter);

Now it doesn't look hacky anymore when you use it!