Max+ Posted July 5, 2014 Posted July 5, 2014 Hello , i made a gameMode , it has a lot of buttons , labels , dxdraw What iam Asking about is , can i make a tabel , to improt them and loop the table and it will automaticly make the buttons and labels and dxdraw , same thing with events can i make a table have like 3 events , and each event will do something , because my gameMode has like 120 lines of codes ,
SkittlesAreFalling Posted July 5, 2014 Posted July 5, 2014 120 isn't BAD, but if you want it shorter you could externally store buttons and whatnot into SQLite, removing them staticly and replacing them dynamically reduces lines of code A LOT. Find more efficient code, efficient code usually decreases the amount of lines used to write the code. You can do a lot to reduce coding.
Max+ Posted July 5, 2014 Author Posted July 5, 2014 i dont know about sql and i dont want to use it at all , i want like i posted above tables, if you know about tabel please show me ,
Dealman Posted July 6, 2014 Posted July 6, 2014 Google "lua tables" and "lua for loop". Read about how they work, and then try it yourself. There's no better way of learning than by trial and error.
#DRAGON!FIRE Posted July 7, 2014 Posted July 7, 2014 ex : local table = { labels = { 100, 100, 100, 100, 200, 200, 200, 200 }, buttons = { 300, 300, 300, 300, 500, 500, 500, 500 }, ["onClientResourceStart"] = { function1, function2 }, } CreateLabels = guiCreateLabel( table[1][1], table[1][2], table[1][3], table[1][4] ) for i = 1, #table["onClientResourceStart"] do addEventHandler( "onClientResourceStart", resourceRoot, table["onClientResourceStart"][i] ) end
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