Sorata_Kanda Posted August 26, 2018 Share Posted August 26, 2018 Hello everyone, I'm sort of new to MTA scripting and thus a beginner to Lua. I have programmed in Java before where I prefered trying to stay on OOP. I just found out that it's also possible to do that in Lua, but it looks kind of confusing to me. Moreover, it's a feature that was introduced in MTA 1.4 which seems not too long ago. That's why I want to ask you what kind of programming you would prefer? OOP or procedural programming? Thank you in advance! Link to comment
Captain Cody Posted August 26, 2018 Share Posted August 26, 2018 OOP is pretty slow in lua in general.. 1 Link to comment
DiGiTal Posted August 26, 2018 Share Posted August 26, 2018 Each one has his way of working . Oop its a just a style of prgramming . It can be easy for u to peactise with oop and other one nope and the contrary too## So. I suggest you OOP as you will find it in many languages 1 Link to comment
Moderators IIYAMA Posted August 26, 2018 Moderators Share Posted August 26, 2018 (edited) In lua I somehow do not really like OOP to the max. It doesn't feel like how it works in JavaScript(always OOP). So I prefer a mix depending on the situation, but consisted. Edited August 26, 2018 by IIYAMA 1 Link to comment
Sorata_Kanda Posted August 27, 2018 Author Share Posted August 27, 2018 Let's take a MySQL script with function() _query as an example. If I follow the OOP approach, then it would be a little bit messy because then I would have to create a new MySQL object for each script which would result in multiple connections. So I don't know how I can use the functions of the MySQL script in other scripts without doing OOP. Link to comment
Crossy101 Posted August 27, 2018 Share Posted August 27, 2018 (edited) Lua doesn't really like OOP and it can make it it pretty slow an example of this is on the wikipedia page. --OOP start = getTickCount() a = 1 for i=1,1000000 do a = localPlayer.position end stop = getTickCount() print("variable", stop - start ) -- Time Taken: 1500ms --Structural start = getTickCount() b = nil for i=1,1000000 do b = getElementPosition(localPlayer) end stop = getTickCount() print("structural", stop - start ) -- Time Taken: 200ms Edited August 27, 2018 by Crossy101 1 Link to comment
Sorata_Kanda Posted August 28, 2018 Author Share Posted August 28, 2018 (edited) Wow. Didn't expect that it would make such a difference. Well, I guess I'll try to do it this way and that way. Thank you very much for your responses! Edited August 28, 2018 by Sorata_Kanda Spelling mistake 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