JeViCo Posted September 29, 2018 Share Posted September 29, 2018 Hello everyone! Could you help me with this? I tried to make it but it doesn't work properly (at all) function moveToFirst(curpos) --local curpos = 5 for r = 1,curpos do --print(r) if r == curpos then dgsGridListSetItemText(layergrid,1,1,"#1") dgsGridListSetItemText(layergrid,r,1,"#"..r) else local r1_data = dgsGridListGetItemData(layergrid,curpos-r,1) -- 4 local r1_data2 = dgsGridListGetItemData(layergrid,curpos-r,2) -- local r1_text = dgsGridListGetItemText(layergrid,curpos-r,2) local r1_text2 = dgsGridListGetItemText(layergrid,curpos-r,3) local r1_text3 = dgsGridListGetItemText(layergrid,curpos-r,4) -- local r2_data = dgsGridListGetItemData(layergrid,curpos-r+1,1) -- 5 local r2_data2 = dgsGridListGetItemData(layergrid,curpos-r+1,2) -- local r2_text = dgsGridListGetItemText(layergrid,curpos-r+1,2) local r2_text2 = dgsGridListGetItemText(layergrid,curpos-r+1,3) local r2_text3 = dgsGridListGetItemText(layergrid,curpos-r+1,4) -- dgsGridListSetItemData(layergrid,curpos-r+1,1,r1_data) dgsGridListSetItemData(layergrid,curpos-r+1,2,r1_data2) dgsGridListSetItemText(layergrid,curpos-r+1,2,r1_text) dgsGridListSetItemText(layergrid,curpos-r+1,3,r1_text2) dgsGridListSetItemText(layergrid,curpos-r+1,4,r1_text3) -- dgsGridListSetItemData(layergrid,curpos-r,1,r2_data) dgsGridListSetItemData(layergrid,curpos-r,2,r2_data2) dgsGridListSetItemText(layergrid,curpos-r,2,r2_text) dgsGridListSetItemText(layergrid,curpos-r,3,r2_text2) dgsGridListSetItemText(layergrid,curpos-r,4,r2_text3) end end end p.s. for i = 1,10 works however for i = 10,1 is not pp.s. i used thisdp's DX Gui system for this action Link to comment
NeXuS™ Posted September 29, 2018 Share Posted September 29, 2018 What do you mean by "for i = 10,1"? Link to comment
iMr.WiFi..! Posted September 29, 2018 Share Posted September 29, 2018 (edited) 46 minutes ago, NeXuS™ said: What do you mean by "for i = 10,1"? He wants to loop with index starting from 10 to 1, 1 hour ago, JeViCo said: Hello everyone! Could you help me with this? I tried to make it but it doesn't work properly (at all) Any way you cant do it by this way, Try this: function moveToFirst(curpos) --local curpos = 5 for r = 1, curpos do r = ( curpos + 1 ) - r; --print(r) if r == curpos then dgsGridListSetItemText(layergrid,1,1,"#1") dgsGridListSetItemText(layergrid,r,1,"#"..r) else local r1_data = dgsGridListGetItemData(layergrid,curpos-r,1) -- 4 local r1_data2 = dgsGridListGetItemData(layergrid,curpos-r,2) -- local r1_text = dgsGridListGetItemText(layergrid,curpos-r,2) local r1_text2 = dgsGridListGetItemText(layergrid,curpos-r,3) local r1_text3 = dgsGridListGetItemText(layergrid,curpos-r,4) -- local r2_data = dgsGridListGetItemData(layergrid,curpos-r+1,1) -- 5 local r2_data2 = dgsGridListGetItemData(layergrid,curpos-r+1,2) -- local r2_text = dgsGridListGetItemText(layergrid,curpos-r+1,2) local r2_text2 = dgsGridListGetItemText(layergrid,curpos-r+1,3) local r2_text3 = dgsGridListGetItemText(layergrid,curpos-r+1,4) -- dgsGridListSetItemData(layergrid,curpos-r+1,1,r1_data) dgsGridListSetItemData(layergrid,curpos-r+1,2,r1_data2) dgsGridListSetItemText(layergrid,curpos-r+1,2,r1_text) dgsGridListSetItemText(layergrid,curpos-r+1,3,r1_text2) dgsGridListSetItemText(layergrid,curpos-r+1,4,r1_text3) -- dgsGridListSetItemData(layergrid,curpos-r,1,r2_data) dgsGridListSetItemData(layergrid,curpos-r,2,r2_data2) dgsGridListSetItemText(layergrid,curpos-r,2,r2_text) dgsGridListSetItemText(layergrid,curpos-r,3,r2_text2) dgsGridListSetItemText(layergrid,curpos-r,4,r2_text3) end end end Good luck Edited September 29, 2018 by iMr.WiFi..! Link to comment
JeViCo Posted September 29, 2018 Author Share Posted September 29, 2018 i tried. Text and player's data is fine now but rows' data is reversed somehow =D function moveTable(curpos) for m = 1, curpos do r = ( curpos + 1 ) - m -- добавка if r-1 > 0 then local r1_data = dgsGridListGetItemData(layergrid,r,1) -- привязка к номеру local r1_data2 = dgsGridListGetItemData(layergrid,r,1) -- привязка к номеру --local r1_text1 = dgsGridListGetItemText(layergrid,r,1) local r1_text2 = dgsGridListGetItemText(layergrid,r,2) local r1_text3 = dgsGridListGetItemText(layergrid,r,3) local r1_text4 = dgsGridListGetItemText(layergrid,r,4) -- добавка 2 local r2_data = dgsGridListGetItemData(layergrid,r-1,1) -- привязка к номеру local r2_data2 = dgsGridListGetItemData(layergrid,r-1,1) -- привязка к номеру --local r2_text1 = dgsGridListGetItemText(layergrid,r-1,1) local r2_text2 = dgsGridListGetItemText(layergrid,r-1,2) local r2_text3 = dgsGridListGetItemText(layergrid,r-1,3) local r2_text4 = dgsGridListGetItemText(layergrid,r-1,4) -- dgsGridListSetItemData(layergrid,r-1,1,r1_data) dgsGridListSetItemData(layergrid,r-1,2,r1_data2) --dgsGridListSetItemText(layergrid,r-1,1,r1_text1) dgsGridListSetItemText(layergrid,r-1,2,r1_text2) dgsGridListSetItemText(layergrid,r-1,3,r1_text3) dgsGridListSetItemText(layergrid,r-1,4,r1_text4) -- dgsGridListSetItemData(layergrid,r,1,r2_data) dgsGridListSetItemData(layergrid,r,2,r2_data2) --dgsGridListSetItemText(layergrid,r,1,r2_text1) dgsGridListSetItemText(layergrid,r,2,r2_text2) dgsGridListSetItemText(layergrid,r,3,r2_text3) dgsGridListSetItemText(layergrid,r,4,r2_text4) -- local k = getElementData(localPlayer,"player:data") local mid = k[m-1] k[m-1] = k[m] k[m] = mid setElementData(localPlayer,"player:data",k) end end end Link to comment
iMr.WiFi..! Posted September 29, 2018 Share Posted September 29, 2018 4 minutes ago, JeViCo said: i tried. Text and player's data is fine now but rows' data is reversed somehow =D So you want that Text, and Data reversed, but you want that rows show without reverse Link to comment
JeViCo Posted September 29, 2018 Author Share Posted September 29, 2018 (edited) 7 minutes ago, iMr.WiFi..! said: So you want that Text, and Data reversed, but you want that rows show without reverse not really. Ok, forget about rows - concentrate on tables. table.insert adds value to the end of table right?. I want to add this value and then drag it on first place without replacing it (all other values will move forwards by 1 step) Edited September 29, 2018 by JeViCo Link to comment
JeViCo Posted September 29, 2018 Author Share Posted September 29, 2018 (edited) solved. I used this info. Thanks everyone for suggestions anyway Edited September 29, 2018 by JeViCo Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now