Other Languages Moderators Lord Henry Posted August 10, 2018 Other Languages Moderators Share Posted August 10, 2018 Hello. Is there any difference between using the entity's name instead of a custom name in a variable? local vehicle = createVehicle (...) or local theVehicle = createVehicle (...) Why does the Wiki always avoid using the entity's name as variable? If I use the entity's name instead of a custom name, is this a bad programming method? PS: I am not using OOP. Link to comment
Moderators IIYAMA Posted August 10, 2018 Moderators Share Posted August 10, 2018 If you did use OOP, then you would be overwriting the MTA classes. https://www.lua.org/pil/16.1.html > It should be fine as long as you do not use OOP or overwrite predefined variables. https://wiki.multitheftauto.com/wiki/Predefined_variables_list Be aware that other people who do use OOP and want/need to edit your resource will be having a hard time. So no worries, just but be consistent in your code. Link to comment
Discord Moderators Pirulax Posted August 11, 2018 Discord Moderators Share Posted August 11, 2018 (edited) No, he would't overwrite any of the classes, since class names are always UpperCamalCase, and not camalCase. But, as @IIYAMA (man, I writing ur name down is so f*cking hard) said, you be consistent in your code. And, because I see you put effort in your work, I'll write down a few tips: Be as consistent with your style ap(as possible) Variables are always camalCase, classes are UpperCamalCase, and constants are either UPPERCASE or UPPER_CASE, try to use tables with constants which have the same purpose(like so: local ANIM_SETTINGS = { speed = 1, eastingFunction = "Linear", } instead of: local ANIM_EASTING_FUNCTION = "Linear" local ANIM_SPEED = 1 Try to ask google first, and not someone else, because asking Google is much faster. Try to use OOP, instead of PP, because OOP is more readable. If you use OOP, then try to organize functions by classes, like. (So instead of: setWeather() have a class like: Weather.set()) Premature optimization is the root of all evil Use ternary operations as much as possible, because 'if' statements are ugly, and slow. (Sure, don't do what I do sometimes(I tend to rewrite a whole if statement to a ternary operation)) Try to be as descriptive ap in var names, so instead of TYPE(of animation) do ANIM_TYPE. Because TYPE can be really anything. I hope I helped you Edited August 11, 2018 by Pirulax Link to comment
Other Languages Moderators Lord Henry Posted August 11, 2018 Author Other Languages Moderators Share Posted August 11, 2018 18 hours ago, Lord Henry said: Why does the Wiki always avoid using the entity's name as variable? PS: I am not using OOP. Any answer? Link to comment
Moderators IIYAMA Posted August 11, 2018 Moderators Share Posted August 11, 2018 59 minutes ago, Lord Henry said: Any answer? Yes, more than enough. And if you want to be 100% sure, you can check the wiki logs and find the person that wrote the comment + ask him/her yourself. Link to comment
Other Languages Moderators Lord Henry Posted August 12, 2018 Author Other Languages Moderators Share Posted August 12, 2018 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