Jump to content




Help Cleaning Up Formatting/Program


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

#1 robbyrit

  • New Members
  • 1 posts

Posted 07 October 2016 - 11:52 PM

Hello,

I'm very new to computercraft and am attempting to learn LUA. I've written this simple program to create and store gas in a chemistry lab i've built in my world. The program works currently, though I haven't attempted it with the "refuel()" functionality yet. Mostly I'd like suggestions in terms of properly formatting my code (I have read up on this a bit on the forums/internet), and/or using loops or other aspects of lua i may not be familiar with to make the code better.

Thank you in advance for any constructive criticism.

Spoiler


#2 ebernerd

  • Members
  • 262 posts
  • LocationBoston, MA

Posted 08 October 2016 - 12:11 AM

The only thing I would suggest changing is the "do -> end" statements within the if statements.

if (1>2) then
  return true
end

is just fine, no need for
if (1>2) then
  do
    return true
  end
end


#3 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 08 October 2016 - 12:42 AM

Note that you do require "do" when constructing a "for" loop - it's just redundant in most other cases.





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users