your way of coding?
Started by Jappards, Apr 10 2013 08:11 AM
27 replies to this topic
#1
Posted 10 April 2013 - 08:11 AM
Everyone writes code different, i first try to write it in the lua program (in CC, not a program on the computer) then i then i write the code in Chunks. What is your way of writing codes in Lua on CC?
#2
Posted 10 April 2013 - 08:13 AM
Have everything in functions then call each of those functions in a master function that gets called at the end of the script
#3
Posted 10 April 2013 - 08:17 AM
I separate my files when doing big projects. Then I add it into one file if it is not an API, and then I go debugging 
Warning, the following is advertisement, not blocked by Adblock+ :
See my channel, then you can see it. Im currently rendering a debugging video
Warning, the following is advertisement, not blocked by Adblock+ :
See my channel, then you can see it. Im currently rendering a debugging video
#6
#7
Posted 10 April 2013 - 09:14 AM
I've written a program called "open" which takes a directory as an argument. It looks at all the files in the folder and loads each one into an environment. Then all the environments have their __index set to the same table, and they're all added to that table.
So basically, you can call each file's functions just like you would an api.
After all that, the main function in the file "main" is called.
As for my actual development environment, I have all my programs stored on one disk. I've deleted the folders for each individual dev computer, and replaced them with a symbolic link to the disk. So now I just edit the files on the disk via TextWrangler, and all my computers use the new code. Very useful.
So basically, you can call each file's functions just like you would an api.
-- file1 file2.function()
After all that, the main function in the file "main" is called.
As for my actual development environment, I have all my programs stored on one disk. I've deleted the folders for each individual dev computer, and replaced them with a symbolic link to the disk. So now I just edit the files on the disk via TextWrangler, and all my computers use the new code. Very useful.
#8
#9
Posted 10 April 2013 - 09:32 AM
Sammich Lord, on 10 April 2013 - 08:13 AM, said:
Have everything in functions then call each of those functions in a master function that gets called at the end of the script 
I despise this practice. It would make so much more sense to break the top-level function out of being a function and just use it as the body of the program.
#10
Posted 10 April 2013 - 09:50 AM
Lyqyd, on 10 April 2013 - 09:32 AM, said:
Sammich Lord, on 10 April 2013 - 08:13 AM, said:
Have everything in functions then call each of those functions in a master function that gets called at the end of the script 
I despise this practice. It would make so much more sense to break the top-level function out of being a function and just use it as the body of the program.
#11
Posted 10 April 2013 - 03:37 PM
Engineer, on 10 April 2013 - 08:17 AM, said:
I separate my files when doing big projects. Then I add it into one file if it is not an API, and then I go debugging 
Warning, the following is advertisement, not blocked by Adblock+ :
See my channel, then you can see it. Im currently rendering a debugging video
Warning, the following is advertisement, not blocked by Adblock+ :
See my channel, then you can see it. Im currently rendering a debugging video
EDIT: ON TOPIC:
I usually only make functions if I use a block of code multiple times, I really need too, I'm making an API, or I'm using parallels. Otherwise, just smash everything down. Usually don't comment. Usually don't put empty lines between parts. I have found myself doing these more and more often though.
#12
Posted 10 April 2013 - 04:18 PM
All of my code goes in functions, except for a while true do statement and a few if statements.
#14
#15
#16
Posted 10 April 2013 - 08:57 PM
For bigger programs, I just put the main code in something like main.lua, and have classes and stuff in other files, and then I require() them.
#17
Posted 10 April 2013 - 11:28 PM
Most of my code goes into functions, which I then call in the code logic after the function declarations.
#18
Posted 11 April 2013 - 12:17 AM
I write my code in functions in Sublime Text and then run the functions (usually)
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











