|
| 11 Dec 2014 07:12 AM |
local sortdis = {}
for i,v in pairs(workspace.Model:GetChildren()) do table.insert(sortdis,v = v.Value) end
--table.sort(sortdis)
--print(unpack(sortdis))
the table.insert(sortdis,v = v.Value) won't work
what i want to do is have a table of intvalues
and i wan't it to order it from least to greatest based on the intvalues Value
[ btw 4 anyone who is waiting on limited simulator, this is for the private selling feature that im adding, all i need is to finish this part & then it'll be done ] |
|
|
| Report Abuse |
|
|
| |
|
| |
|
| |
|
|
| 11 Dec 2014 07:29 AM |
Get rid of the v ='v.Value
and just put v? |
|
|
| Report Abuse |
|
|
|
| 11 Dec 2014 02:27 PM |
but then table.sort wouldnt work cause it'd be sorting a table of IntValues
i want it to sort them based on their Values |
|
|
| Report Abuse |
|
|
HexC3D
|
  |
| Joined: 30 Jun 2012 |
| Total Posts: 10044 |
|
| |
|
HexC3D
|
  |
| Joined: 30 Jun 2012 |
| Total Posts: 10044 |
|
|
| 11 Dec 2014 02:30 PM |
You don't have to use int values but mmk, also' v= ' part is not going to work. I'll post rescripted version in a sec. |
|
|
| Report Abuse |
|
|
FootBa11
|
  |
| Joined: 16 Sep 2008 |
| Total Posts: 11501 |
|
|
| 11 Dec 2014 02:31 PM |
If youre wanting to sort a table, lets say from smallest to largest, and you are sorting actual values, then table.sort wont work im pretty sure.
Look at this:
http://wiki.roblox.com/index.php?title=Category:Sorting_algorithms
This gives you 3 examples to fix your problem. |
|
|
| Report Abuse |
|
|
HexC3D
|
  |
| Joined: 30 Jun 2012 |
| Total Posts: 10044 |
|
|
| 11 Dec 2014 02:32 PM |
You cannot get value from stuff in the player that does not have value properties.. etc Parts.. if v.ClassName == "IntValue" then
end |
|
|
| Report Abuse |
|
|
HexC3D
|
  |
| Joined: 30 Jun 2012 |
| Total Posts: 10044 |
|
|
| 11 Dec 2014 02:34 PM |
for i,v in pairs(workspace.Model:GetChildren()) do if v.ClassName == "IntValue" then table.insert(sortdis, v.Value) end
end |
|
|
| Report Abuse |
|
|
HexC3D
|
  |
| Joined: 30 Jun 2012 |
| Total Posts: 10044 |
|
|
| 11 Dec 2014 02:35 PM |
| Just print the values in the table for a double check, now for that least to greatest thing. |
|
|
| Report Abuse |
|
|
|
| 11 Dec 2014 02:37 PM |
hex, my goal is to have a table of IntValues, not the Values of them
& then after that, i need a way to sort all the IntValues from least to greatest
based on the Value of them |
|
|
| Report Abuse |
|
|
FootBa11
|
  |
| Joined: 16 Sep 2008 |
| Total Posts: 11501 |
|
| |
|
|
| 11 Dec 2014 02:38 PM |
| I don't think you can store Userdata, so store the name of the value instead or copy the values into a list inside the script for later use. |
|
|
| Report Abuse |
|
|
|
| 11 Dec 2014 02:42 PM |
@footba11 everything there confused me lol
|
|
|
| Report Abuse |
|
|
HexC3D
|
  |
| Joined: 30 Jun 2012 |
| Total Posts: 10044 |
|
|
| 11 Dec 2014 02:43 PM |
You can't store userdata , not that I know of. But you could store the values in the table and save them. |
|
|
| Report Abuse |
|
|
|
| 11 Dec 2014 02:45 PM |
i found it, cntkillme helped
local sortdis = {}
for i,v in pairs(workspace.Model:GetChildren()) do table.insert(sortdis,v) end
table.sort(sortdis, function(a, b) return a.Value < b.Value; end); |
|
|
| Report Abuse |
|
|
HexC3D
|
  |
| Joined: 30 Jun 2012 |
| Total Posts: 10044 |
|
|
| 11 Dec 2014 02:46 PM |
like? local szz= {v.Value}
? |
|
|
| Report Abuse |
|
|
FootBa11
|
  |
| Joined: 16 Sep 2008 |
| Total Posts: 11501 |
|
|
| 11 Dec 2014 02:47 PM |
Fine.
Ill just write it out for you
repeat swapped = false for i=2, #sortdis do if sortdis[i-1].Value > sortdis[i].Value then sortdis[i-1].Value, sortdis[i].Value = sortdis[i].Value, sortdis[i-1].Value swapped = true end end until not swapped
This sorts your values in your table from Greatest to least. Where your greates value is sortdis[1] and your smallest value is sortdis[#sortdis] |
|
|
| Report Abuse |
|
|
|
| 11 Dec 2014 02:47 PM |
ogm so its almot done?!?!
R$62,816 on hand! Current RAP 1,268,112 |
|
|
| Report Abuse |
|
|
|
| 11 Dec 2014 03:10 PM |
Make sure u make the inventory save and stuff!!
R$62,831 on hand! Current RAP 1,268,112 |
|
|
| Report Abuse |
|
|
| |
|
|
| 11 Dec 2014 04:59 PM |
Told ya to remove the v=value crap! >:(
Just didn't inownto add the extra bit at the end... NOOB! |
|
|
| Report Abuse |
|
|