376 posts
Location
[string "FindMe"]:23143: bad argument #1 to 'returnPos' (vector expected, got nil)
Posted 17 July 2014 - 01:05 PM
How do you pull up the highest/lowest "Priority" from this table using table.sort?
tasks = {dig = {priority = 100}, mine = {priority = 120, timeout = 10}}
Im really confused, please help
7508 posts
Location
Australia
Posted 17 July 2014 - 01:15 PM
As shown on the
Lua-users.org Tables Tutorial you can provide a second argument to
table.sort that is a comparator function where you compare the two arguments provided to it, therefore you'd do the following
table.sort( tasks, function( a, b ) return a > b end )
Edited by
376 posts
Location
[string "FindMe"]:23143: bad argument #1 to 'returnPos' (vector expected, got nil)
Posted 17 July 2014 - 01:21 PM
As shown on the
Lua-users.org Tables Tutorial you can provide a second argument to
table.sort that is a comparator function where you compare the two arguments provided to it, therefore you'd do the following
table.sort( tasks, function( a, b ) return a > b end )
It helps a little, but how would It compare the priorities
7508 posts
Location
Australia
Posted 17 July 2014 - 01:25 PM
well the values passed through in a and b are the table entries, so you simply just do a.priority and b.priority.
376 posts
Location
[string "FindMe"]:23143: bad argument #1 to 'returnPos' (vector expected, got nil)
Posted 17 July 2014 - 01:33 PM
well the values passed through in a and b are the table entries, so you simply just do a.priority and b.priority.
Well that helps alot!, Thank you!
Off Topic : Just in case you were wondering, I am making In-Game NBS using your MoarPeripherals mod
PM me if you are interested in it
7508 posts
Location
Australia
Posted 17 July 2014 - 01:38 PM
Oh very nice. I look forward to seeing it complete :)/> though you might want to brush up on binary manipulation if you plan on actually saving out into the
NBS format.
Edited on 17 July 2014 - 11:38 AM