Jump to content




storing code in a file


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

#1 hugeblank

  • Members
  • 122 posts
  • LocationA grocery store near you!

Posted 29 November 2015 - 05:57 AM

You probably get this question a million times, but how does one store lines of code in a file?

I have this:

file.writeLine(for I, side in ipairs(rs.getsides()) do)

and it gives me an error. I already have a line above that that opens the file, so it's not that.

#2 valithor

  • Members
  • 1,053 posts

Posted 29 November 2015 - 06:03 AM

Put quotes around what you are trying to write to the file:

file.writeLine("for I, side in ipairs(rs.getsides()) do")

Also you might have already done this, but don't forgot to close the file. :P

#3 hugeblank

  • Members
  • 122 posts
  • LocationA grocery store near you!

Posted 29 November 2015 - 06:20 AM

I did. Thank you! One question,

1. What if you have something like this:

file.writeLine("if peripheral.get Type == "modem" then")

Wouldn't it turn "modem" into a variable?

#4 Bomb Bloke

    Hobbyist Coder

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

Posted 29 November 2015 - 07:08 AM

Using the \ escape character to specify that we want certain quotes to be part of the string, we can do this:

file.writeLine("if peripheral.get Type == \"modem\" then")






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users