Jump to content




your way of coding?


  • You cannot reply to this topic
27 replies to this topic

#1 Jappards

  • Validating
  • 116 posts
  • LocationHolland

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 Sammich Lord

    IRC Addict

  • Members
  • 1,212 posts
  • LocationThe Sammich Kingdom

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 :P

#3 Engineer

  • Members
  • 1,378 posts
  • LocationThe Netherlands

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 :P

Warning, the following is advertisement, not blocked by Adblock+ :

See my channel, then you can see it. Im currently rendering a debugging video :P

#4 Kingdaro

    The Doctor

  • Members
  • 1,636 posts
  • Location'MURICA

Posted 10 April 2013 - 08:34 AM

View PostSammich 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 :P/>
Basically this.

#5 SuicidalSTDz

    Permutator of Strings

  • Members
  • 1,308 posts
  • LocationPennsylvania

Posted 10 April 2013 - 08:57 AM

View PostSammich 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 :P/>
Couldn't agree any more :P

#6 Sammich Lord

    IRC Addict

  • Members
  • 1,212 posts
  • LocationThe Sammich Kingdom

Posted 10 April 2013 - 08:59 AM

View PostSuicidalSTDz, on 10 April 2013 - 08:57 AM, said:

View PostSammich 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 :P/>
Couldn't agree any more :P
Lua is nothing but functions and tables :P

#7 ElvishJerricco

  • Members
  • 803 posts

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.

-- 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 ElvishJerricco

  • Members
  • 803 posts

Posted 10 April 2013 - 09:16 AM

View PostSammich Lord, on 10 April 2013 - 08:59 AM, said:

View PostSuicidalSTDz, on 10 April 2013 - 08:57 AM, said:

View PostSammich 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 :P/>/>
Couldn't agree any more :P/>
Lua is nothing but functions and tables :P/>

And numbers, strings, nils, booleans, and coroutines =P

#9 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 10 April 2013 - 09:32 AM

View PostSammich 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 :P

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 Sammich Lord

    IRC Addict

  • Members
  • 1,212 posts
  • LocationThe Sammich Kingdom

Posted 10 April 2013 - 09:50 AM

View PostLyqyd, on 10 April 2013 - 09:32 AM, said:

View PostSammich 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 :P

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.
I do what you mentioned a lot too. I sometimes have API's in files, runs those then just have my actual main script call all the functions.

#11 Shnupbups

  • Members
  • 596 posts
  • LocationThat place over there. Y'know. The one where I am.

Posted 10 April 2013 - 03:37 PM

View PostEngineer, 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 :P

Warning, the following is advertisement, not blocked by Adblock+ :

See my channel, then you can see it. Im currently rendering a debugging video :P
I used AdBlock+ to destroy any trace of your comment. So ha.

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 Dlcruz129

    What's a Lua?

  • Members
  • 1,423 posts

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.

#13 Spongy141

  • Members
  • 526 posts
  • Location'Merica

Posted 10 April 2013 - 04:23 PM

View PostDlcruz129, on 10 April 2013 - 04:18 PM, said:

All of my code goes in functions, except for a while true do statement and a few if statements.
Same, but I also do something a lot of new users are not doing, SPACING MY CODE SO ITS READABLE.

#14 SuicidalSTDz

    Permutator of Strings

  • Members
  • 1,308 posts
  • LocationPennsylvania

Posted 10 April 2013 - 04:55 PM

View PostSpongy141, on 10 April 2013 - 04:23 PM, said:

View PostDlcruz129, on 10 April 2013 - 04:18 PM, said:

All of my code goes in functions, except for a while true do statement and a few if statements.
Same, but I also do something a lot of new users are not doing, SPACING MY CODE SO ITS READABLE.
My code is readable, well, to me anyways :P

#15 Dlcruz129

    What's a Lua?

  • Members
  • 1,423 posts

Posted 10 April 2013 - 05:07 PM

View PostSpongy141, on 10 April 2013 - 04:23 PM, said:

View PostDlcruz129, on 10 April 2013 - 04:18 PM, said:

All of my code goes in functions, except for a while true do statement and a few if statements.
Same, but I also do something a lot of new users are not doing, SPACING MY CODE SO ITS READABLE.

Me too. OCD is one of the best qualities a programmer can have.

#16 Mads

  • Members
  • 604 posts
  • LocationCopenhagen, Denmark

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 Smiley43210

  • Members
  • 204 posts

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 Mackan90096

  • Signature Abuser
  • 518 posts
  • LocationIn my basement.

Posted 11 April 2013 - 12:17 AM

I write my code in functions in Sublime Text and then run the functions (usually)

#19 SuicidalSTDz

    Permutator of Strings

  • Members
  • 1,308 posts
  • LocationPennsylvania

Posted 11 April 2013 - 12:35 AM

View PostMackan90096, on 11 April 2013 - 12:17 AM, said:

I write my code in functions in Sublime Text and then run the functions (usually)
Thats because Sublime Text is the best :P

#20 Kingdaro

    The Doctor

  • Members
  • 1,636 posts
  • Location'MURICA

Posted 11 April 2013 - 03:23 AM

View PostSuicidalSTDz, on 11 April 2013 - 12:35 AM, said:

View PostMackan90096, on 11 April 2013 - 12:17 AM, said:

I write my code in functions in Sublime Text and then run the functions (usually)
Thats because Sublime Text is the best :P/>/>
Amen, brother.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users