xXMADEXx Posted July 8, 2014 Share Posted July 8, 2014 Hey guys. So, I'm scripting with the new OOP feature in mta 1.4 beta, but for some reason I am having issues with the GuiGridlist class. I'm using it just like any other class but it says the following: attempt to index global 'grid' (a userdata value) I'm honestly not sure if I'm doing something wrong or if it's just an MTA bug, but here's the code that I wrote: function makeGui ( ) window = GuiWindow.create(334, 104, 710, 479, "Nerd Gaming Help", false) window.setSizable = false; grid = GuiGridlist.create(356, 34, 274, 150, false, window) --guiGridListAddColumn(grid, "", 0.9) grid:addColumn ( "", 0.9 ) -- Issue here img = GuiStaticImage.create(61, 34, 272, 150, ":NGLogin/files/logo.png", false, window) info = GuiLabel.create(61, 234, 569, 186, "This is my text", false, window) info:setFont ( "default-bold-small" ) info:setHorizontalAlign ( "left", true ) showCursor ( true ) for i, v in pairs ( options2 ) do local r = grid:addRow ( ); -- Issue here grid:setItemText ( r, 1, tostring ( v [ 1 ] ), false, false ) end end Link to comment
Max+ Posted July 8, 2014 Share Posted July 8, 2014 function makeGui ( ) window = GuiWindow.create(334, 104, 710, 479, "Nerd Gaming Help", false) window.setSizable = false; grid = GuiGridlist.create(356, 34, 274, 150, false, window) --guiGridListAddColumn(grid, "", 0.9) grid:addColumn (grid, "", 0.9 ) --- you must add the gridlist you want to add the column for img = GuiStaticImage.create(61, 34, 272, 150, ":NGLogin/files/logo.png", false, window) info = GuiLabel.create(61, 234, 569, 186, "This is my text", false, window) info:setFont ( "default-bold-small" ) info:setHorizontalAlign ( "left", true ) showCursor ( true ) for i, v in pairs ( options2 ) do ----is this defined ? options2 ? local r = grid:addRow (grid); --- you must add the gridlist you want to add the row for grid:setItemText ( r, 1, tostring ( v [ 1 ] ), false, false ) end end Link to comment
xXMADEXx Posted July 8, 2014 Author Share Posted July 8, 2014 function makeGui ( ) window = GuiWindow.create(334, 104, 710, 479, "Nerd Gaming Help", false) window.setSizable = false; grid = GuiGridlist.create(356, 34, 274, 150, false, window) --guiGridListAddColumn(grid, "", 0.9) grid:addColumn (grid, "", 0.9 ) --- you must add the gridlist you want to add the column for img = GuiStaticImage.create(61, 34, 272, 150, ":NGLogin/files/logo.png", false, window) info = GuiLabel.create(61, 234, 569, 186, "This is my text", false, window) info:setFont ( "default-bold-small" ) info:setHorizontalAlign ( "left", true ) showCursor ( true ) for i, v in pairs ( options2 ) do ----is this defined ? options2 ? local r = grid:addRow (grid); --- you must add the gridlist you want to add the row for grid:setItemText ( r, 1, tostring ( v [ 1 ] ), false, false ) end end Yes, options2 is defined and in OOP you don't have add the element as an argument, that's what grid: does. Thanks for trying to help though. Link to comment
Max+ Posted July 8, 2014 Share Posted July 8, 2014 function makeGui ( ) window = GuiWindow.create(334, 104, 710, 479, "Nerd Gaming Help", false) window.setSizable = false; grid = GuiGridlist.create(356, 34, 274, 150, false, window) --guiGridListAddColumn(grid, "", 0.9) grid:addColumn (grid, "", 0.9 ) --- you must add the gridlist you want to add the column for img = GuiStaticImage.create(61, 34, 272, 150, ":NGLogin/files/logo.png", false, window) info = GuiLabel.create(61, 234, 569, 186, "This is my text", false, window) info:setFont ( "default-bold-small" ) info:setHorizontalAlign ( "left", true ) showCursor ( true ) for i, v in pairs ( options2 ) do ----is this defined ? options2 ? local r = grid:addRow (grid); --- you must add the gridlist you want to add the row for grid:setItemText ( r, 1, tostring ( v [ 1 ] ), false, false ) end end Yes, options2 is defined and in OOP you don't have add the element as an argument, that's what grid: does. Thanks for trying to help though. what is , OOP ? and did you try this script ? Link to comment
xXMADEXx Posted July 8, 2014 Author Share Posted July 8, 2014 function makeGui ( ) window = GuiWindow.create(334, 104, 710, 479, "Nerd Gaming Help", false) window.setSizable = false; grid = GuiGridlist.create(356, 34, 274, 150, false, window) --guiGridListAddColumn(grid, "", 0.9) grid:addColumn (grid, "", 0.9 ) --- you must add the gridlist you want to add the column for img = GuiStaticImage.create(61, 34, 272, 150, ":NGLogin/files/logo.png", false, window) info = GuiLabel.create(61, 234, 569, 186, "This is my text", false, window) info:setFont ( "default-bold-small" ) info:setHorizontalAlign ( "left", true ) showCursor ( true ) for i, v in pairs ( options2 ) do ----is this defined ? options2 ? local r = grid:addRow (grid); --- you must add the gridlist you want to add the row for grid:setItemText ( r, 1, tostring ( v [ 1 ] ), false, false ) end end Yes, options2 is defined and in OOP you don't have add the element as an argument, that's what grid: does. Thanks for trying to help though. what is , OOP ? and did you try this script ? https://wiki.multitheftauto.com/wiki/OOP_Introduction Link to comment
Arnold-1 Posted July 8, 2014 Share Posted July 8, 2014 OOP, Object oriented programming, read about it in the Tutorial section. @xXMADEXx i think it's some bug, userdata means MTA classes/elements, so i think it's a bug. Link to comment
xXMADEXx Posted July 8, 2014 Author Share Posted July 8, 2014 OOP, Object oriented programming, read about it in the Tutorial section.@xXMADEXx i think it's some bug, userdata means MTA classes/elements, so i think it's a bug. I'm guessing that it is a bug because I'm using it in the same form as the gui label and the GUI label is creating just fine. Link to comment
Max+ Posted July 8, 2014 Share Posted July 8, 2014 OOP, Object oriented programming, read about it in the Tutorial section.@xXMADEXx i think it's some bug, userdata means MTA classes/elements, so i think it's a bug. I'm guessing that it is a bug because I'm using it in the same form as the gui label and the GUI label is creating just fine. Just asking why do you use opp scripting ? why don't you use the old scripting it's much esay and no erros , Link to comment
xXMADEXx Posted July 8, 2014 Author Share Posted July 8, 2014 OOP, Object oriented programming, read about it in the Tutorial section.@xXMADEXx i think it's some bug, userdata means MTA classes/elements, so i think it's a bug. I'm guessing that it is a bug because I'm using it in the same form as the gui label and the GUI label is creating just fine. Just asking why do you use opp scripting ? why don't you use the old scripting it's much esay and no erros , Because OOP makes it easier to read the code and most programming languages are OOP so it would only make since to write in it since I can now. Link to comment
Mr_Moose Posted July 8, 2014 Share Posted July 8, 2014 If it works for the window then I assume that you set: <oop>true</oop> In the server config file, for some reason it's often the most simple errors that causes the most trouble, I would try to figure out what "grid" in your code actually is, a "userData value" could be nil referring to an older syntax, or something else due to a misspelled class or function, try to replace Gridlist with GridList to see if the class name where misspelled, otherwise it's hard to say what the issue could be in this case. Link to comment
xXMADEXx Posted July 8, 2014 Author Share Posted July 8, 2014 If it works for the window then I assume that you set: <oop>true</oop> In the server config file, for some reason it's often the most simple errors that causes the most trouble, I would try to figure out what "grid" in your code actually is, a "userData value" could be nil referring to an older syntax, or something else due to a misspelled class or function, try to replace Gridlist with GridList to see if the class name where misspelled, otherwise it's hard to say what the issue could be in this case. Yeah, this is set. Link to comment
Mr_Moose Posted July 8, 2014 Share Posted July 8, 2014 And the second question, how about the "List" part in Gridlist, did you try to uppercase that L on line 5 yet? OOP classes usually uppercase the first char in all new words that is brought together. List is a word and Grid is a word so the name of that class could be GridList. Link to comment
xXMADEXx Posted July 8, 2014 Author Share Posted July 8, 2014 And the second question, how about the "List" part in Gridlist, did you try to uppercase that L on line 5 yet? OOP classes usually uppercase the first char in all new words that is brought together. List is a word and Grid is a word so the name of that class could be GridList. The class is GuiGridlist, when you put a capital L it says a nil value is given. Link to comment
cheez3d Posted July 8, 2014 Share Posted July 8, 2014 Have you tried without syntactic sugar? grid.addColumn(grid,"",0.9); Link to comment
xXMADEXx Posted July 8, 2014 Author Share Posted July 8, 2014 Have you tried without syntactic sugar? grid.addColumn(grid,"",0.9); Yeah, but it still didn't work. Pretty sure it's an MTA bug. Link to comment
Arnold-1 Posted July 9, 2014 Share Posted July 9, 2014 i told many people, MTA 1.4 isn't stable yet, they're not believing me. 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