tipforeveryone Posted August 9, 2018 Share Posted August 9, 2018 I wonder how the performance is in 2 ways of using variables in lua. Which one is better when there are many of pivots which can be attached script, each script has its own "self." variables Method 1: Use table for everything Script.table = {} --create masster table of scripts function Script:Start() table.category1 = {} table.category1.variable_1 = somevalue table.category1.variable_2 = somevalue ... table.category1.variable_n = somevalue table.category2 = {} table.category2.variable_1 = somevalue table.category2.variable_2 = somevalue ... table.category2.variable_n = somevalue end Method 2: Use Script.variable only Script.valuable_1 = something Script.valuable_2 = something function Script:Start() self.valuable_3 = something self.valuable_4 = something ... self.valuable_n = something end Quote Link to comment Share on other sites More sharing options...
Josh Posted August 9, 2018 Share Posted August 9, 2018 The second one will be imperceptibly faster, but it's also less code to write. If you absolutely needed to categorize things you could just name the variable something like self.categoryname_valuename. 1 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.