mehmet Posted February 26, 2018 Posted February 26, 2018 (edited) Hi, I'm looking for an ideal structure for files. If I keep all the scripts in one resource and compile all scripts into one file in server.lua and client.lua is this bad? Edited February 26, 2018 by mehmet
Moderators IIYAMA Posted February 26, 2018 Moderators Posted February 26, 2018 Yes, could be bad depending on your code style. Because files are also code blocks. Which limit the accessibility of local variables. Example, where it can go wrong: File 1 local variableName = "can't be changed outside of this file" function show () iprint(variableName) end File 2 variableName = "yes" show () -- call the function show It should output: "can't be changed outside of this file" Because the local variable can't be changed outside of it's scope. Now put it in 1 file. local variableName = "can't be changed outside of this file" function show () iprint(variableName) end variableName = "yes" show () -- call the function show It should output: "yes" We have 1 file, 1 file scope. The `variableName` is available at the place where it is overwritten. (so the local variable will be overwritten) 1
mehmet Posted February 26, 2018 Author Posted February 26, 2018 3 minutes ago, IIYAMA said: Yes, could be bad depending on your code style. Because files are also code blocks. Which limit the accessibility of local variables. Example, where it can go wrong: File 1 local variableName = "can't be changed outside of this file" function show () iprint(variableName) end File 2 variableName = "yes" show () -- call the function show It should output: "can't be changed outside of this file" Because the local variable can't be changed outside of it's scope. Now put it in 1 file. local variableName = "can't be changed outside of this file" function show () iprint(variableName) end variableName = "yes" show () -- call the function show It should output: "yes" We have 1 file, 1 file scope. The `variableName` is available at the place where it is overwritten. (so the local variable will be overwritten) Thank's man. Can you show a good file structure?(screenshot)
Moderators IIYAMA Posted February 26, 2018 Moderators Posted February 26, 2018 There isn't really a good file structure. The real question is: "Does it work for you? If yes, then it might be a good file structure for you."
mehmet Posted February 26, 2018 Author Posted February 26, 2018 1 minute ago, IIYAMA said: There isn't really a good file structure. The real question is: "Does it work for you? If yes, then it might be a good file structure for you." Well, which one do you use?
Captain Cody Posted February 26, 2018 Posted February 26, 2018 'Good' file structures differ from person to person one scripter may put everything in one script, one in one resource, another in multiple resources. It highly depends on preference. Performance wise, I believe multiple resources wins though.
Moderators IIYAMA Posted February 26, 2018 Moderators Posted February 26, 2018 34 minutes ago, mehmet said: Well, which one do you use? Multiple resources and multiple files. Every resource for every gamemode component. (hud, external interfaces) And each file for sub tasks. Sometimes it can be difficult to determine if you should split it up or not. Which can sometimes mean that it can actually be both. When split it up? > If the tasks which the code full fill, are entirely different from each other. As @CodyJ(L) did mention: performance There are two types of performance showing up when doing this: Computer performance. Your own performance. (writing/reading code speed) You will slowly learn how to keep those balanced, based on experience and inspiration. 1
mehmet Posted February 27, 2018 Author Posted February 27, 2018 10 hours ago, IIYAMA said: Multiple resources and multiple files. Every resource for every gamemode component. (hud, external interfaces) And each file for sub tasks. Sometimes it can be difficult to determine if you should split it up or not. Which can sometimes mean that it can actually be both. When split it up? > If the tasks which the code full fill, are entirely different from each other. As @CodyJ(L) did mention: performance There are two types of performance showing up when doing this: Computer performance. Your own performance. (writing/reading code speed) You will slowly learn how to keep those balanced, based on experience and inspiration. like that?
Moderators IIYAMA Posted February 27, 2018 Moderators Posted February 27, 2018 (edited) Scoreboard isn't related to nametags. First-person isn't to both of them. Hud might be related to scoreboard and yet it isn't. So if you want to merge this in to a single resource. Then merge it in to the main gamemode. Because they aren't all huds (even though they might contain them). And for the files: /scripts/... /fonts/... Edited February 27, 2018 by IIYAMA
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