BruckLest Posted August 24, 2015 Posted August 24, 2015 Buenas quisiera saber como hago para hacer categorias en mi tienda de autos ejemplo: Deportivos Infernus Bullet Si Alguien sabe como porfavor me puede decir, esto es lo que tengo. local cars = { {579, 70000}, {400, 1000000}, {404, 38000}, {489, 75000}, {505, 75000}, {479, 55000}, {442, 55000}, {458, 55000}, {602, 60000}, {496, 52500}, {401, 51000}, {518, 70000}, {527, 85000}, {589, 85000}, {419, 55000}, {533, 85000}, {526, 60000}, {474, 65000}, {545, 60000}, {517, 55000}, {410, 51000}, {600, 60000}, {436, 51000}, {580, 60000}, {439, 85000}, {549, 85000}, {491, 55000}, {445, 55000}, {507, 55000}, {585, 55000}, {587, 85000}, {466, 65000}, {492, 60000}, {546, 55000}, {551, 55000}, {516, 55000}, {467, 55000}, {426, 57500}, {547, 55000}, {405, 65000}, {409, 85000}, {550, 55000}, {566, 55000}, {540, 55000}, {421, 60000}, {529, 55000}, {402, 130000}, {542, 75000}, {603, 130000}, {475, 85000}, {562, 130000}, {565, 105000}, {559, 130000}, {561, 60000}, {560, 130000}, {558, 110000}, {429, 130000}, {541, 130000}, {415, 130000}, {480, 105000}, {434, 110000}, {494, 130000}, {502, 130000}, {503, 130000}, {411, 200000}, {506, 99999999}, {451, 130000}, {555, 105000}, {477, 105000}, {499, 35000}, {498, 35000}, {578, 60000}, {486, 80000}, {455, 85000}, {588, 60000}, {403, 85000}, {414, 60000}, {443, 85000}, {515, 85000}, {514, 85000}, {531, 15000}, {456, 55000}, {422, 55000}, {482, 105000}, {530, 15000}, {418, 55000}, {572, 15000}, {582, 60000}, {413, 60000}, {440, 60000}, {543, 75000}, {583, 15000}, {478, 45000}, {554, 60000}, {536, 85000}, {575, 85000}, {534, 85000}, {567, 85000}, {535, 85000}, {576, 85000}, {412, 85000}, {568, 85000}, {457, 15000}, {483, 55000}, {508, 50000}, {571, 15000}, {500, 60000}, {444, 130000}, {556, 130000}, {557, 130000}, {471, 30000}, {495, 110000}, {539, 90000}, {481, 5000}, {509, 5000}, {581, 50000}, {462, 15000}, {521, 70000}, {463, 60000}, {522, 85000}, {448, 15000}, {468, 50000}, {586, 55000}, {485, 15000}, {431, 70000}, {438, 60000}, {437, 70000}, {574, 15000}, {420, 50000}, {525, 85000}, {408, 60000}, {428, 70000}, {537, 120000} } for i,v in ipairs (cars) do local carName = getVehicleNameFromModel (v[1]) local row = guiGridListAddRow (carGridList) guiGridListSetItemText (carGridList, row, 1, carName, false, true) guiGridListSetItemText (carGridList, row, 2, tostring(v[2]), false, true) end
aka Blue Posted August 24, 2015 Posted August 24, 2015 Diferentes tablas. Algo como deportivos = { {"Infernus", 120000}, {"Bullet", 50000} }
BruckLest Posted August 24, 2015 Author Posted August 24, 2015 no funciona no aparece la Categoria en el Gridlist
aka Blue Posted August 24, 2015 Posted August 24, 2015 Pon el código. Si no lo posteas no podemos hacer nada. PD: El código con las diferentes categorías.
BruckLest Posted August 24, 2015 Author Posted August 24, 2015 Lo Siento este es el Codigo. carshopWindow = guiCreateWindow(17, 90, 350, 338, "Tienda de Autos", false) guiSetVisible (carshopWindow, false) guiSetAlpha(carshopWindow,1) guiWindowSetSizable(carshopWindow,false) selectLabel = guiCreateLabel(191, 26, 149, 15, "Seleccione a tu Gusto!", false, carshopWindow) guiSetAlpha(selectLabel,1) guiLabelSetColor(selectLabel,255,255,255) guiLabelSetVerticalAlign(selectLabel,"top") guiLabelSetHorizontalAlign(selectLabel,"left",false) guiSetFont(selectLabel,"default-bold-small") Seguro = guiCreateCheckBox(191, 187, 149, 18, "Comprar con Seguro", false, false, carshopWindow) imagen = guiCreateStaticImage(191, 48, 149, 133, "utils/mtalogo.png", false, carshopWindow) carGridList = guiCreateGridList(10, 26, 174, 299, false, carshopWindow) guiGridListSetSelectionMode(carGridList,0) carColumn = guiGridListAddColumn(carGridList,"Carro",0.5) costColumn = guiGridListAddColumn(carGridList,"$",0.5) local cars = { {555, 1000000}, {411, 450000} } for i,v in ipairs (cars) do local carName = getVehicleNameFromModel (v[1]) local row = guiGridListAddRow (carGridList) guiGridListSetItemText (carGridList, row, 1, carName, false, true) guiGridListSetItemText (carGridList, row, 2, tostring(v[2]), false, true) end
aka Blue Posted August 24, 2015 Posted August 24, 2015 Ahí solo se ve el cars pero no se ven ningunas categorías. Para poner más categorías podrías loopear dos veces o en el mismo loop, insertar un item text que sea una línea o que ponga "deportivos" y de ahí hacia abajo que sean todos otro tipo de vehículos de otra tabla. Me explico, tú tienes ésto. local cars = { {555, 1000000}, {411, 450000} } for i,v in ipairs (cars) do local carName = getVehicleNameFromModel (v[1]) local row = guiGridListAddRow (carGridList) guiGridListSetItemText (carGridList, row, 1, carName, false, true) guiGridListSetItemText (carGridList, row, 2, tostring(v[2]), false, true) end Cambias local cars por deportivos, por ejemplo y en el loop pones, en el primer guiGridListSetItemText, el texto deportivos, luego, creas otra tabla con otro tipo de vehículos y haces otro guiGridListSetItemText con el texto "motos", por ejemplo. Para ahorrarte loops más que nada.
BruckLest Posted August 24, 2015 Author Posted August 24, 2015 Amigo no me funciono osea no me aparece la categoria en el gridlist. Use el Siguiente Codigo: deportivos = { {555, 1000000}, {411, 450000} } for i,v in ipairs (deportivos) do local carName = getVehicleNameFromModel (v[1]) local row = guiGridListAddRow (carGridList) guiGridListSetItemText (carGridList, row, 1, carName, false, true) guiGridListSetItemText (carGridList, row, 2, tostring(v[2]), false, true) end
aka Blue Posted August 24, 2015 Posted August 24, 2015 Prueba haciendo un doble loop. Supongo que al poner la misma variable de la gridList te lo meterá directamente. Te daré el código directamente, solo cambia las ID's y ya. normales = { {415, 10000}, {550, 100000} } deportivos = { {555, 1000000}, {411, 450000} } for i,v in ipairs (deportivos) do local carName = getVehicleNameFromModel (v[1]) local row = guiGridListAddRow (carGridList) guiGridListSetItemText (carGridList, row, 1, "Deportivos", false, true) guiGridListSetItemText (carGridList, row, 2, carName, false, true) guiGridListSetItemText (carGridList, row, 3, tostring(v[2]), false, true) end for i, v in ipairs(normales) do local carName2 = getVehicleNameFromModel (v[1]) local row = guiGridListAddRow(carGridList) guiGridListSetItemText(carGridList, row, 4, "Normales", false, true) guiGridListSetItemText(carGridList, row, 5, carName2, false, true) guiGridListSetItemText(carGridList, row, 6, tostring(v[2]), false, true) end Puedes hacer espacios añadiendo un row demás también. PD2: Lo hice muy a ojo y no lo he testeado.
Recommended Posts