Jump to content




Making program in program


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

#1 XMan3

  • Members
  • 7 posts
  • Location127.0.0.1

Posted 20 October 2014 - 06:38 PM

Well, I am trying to make File transfer system in Computercraft, I do not need any more knowledge of Rednet, but I am stuck in this thing:
Can I write program using string? Example:
If someone sends string: while true do
*Write the first line, while true do*
Then: print("HELLO WORLD!")
*Write the second line*
And: end
*Write the third line*

...Or...
If someone sends the whole program thing in one string: while true do print("HELLO WORLD!") end

So, is that possible?

#2 Dragon53535

  • Members
  • 973 posts
  • LocationIn the Matrix

Posted 20 October 2014 - 07:09 PM

It's possible both ways, however i believe the second is harder.

take a look into the fs API Here. More specificially fs.open

A small tutorial for the fs api is here.

#3 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 20 October 2014 - 07:25 PM

The second way is definitely easier. Read the file on one end, send the multiline string, receive it on the other end and write it to the file.

#4 valithor

  • Members
  • 1,053 posts

Posted 20 October 2014 - 07:50 PM

You could actually do this pretty easily by sending the program as a table then looping through the table. I know that this is how the edit program handles file saving.

#5 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 20 October 2014 - 07:55 PM

View Postvalithor, on 20 October 2014 - 07:50 PM, said:

You could actually do this pretty easily by sending the program as a table then looping through the table. I know that this is how the edit program handles file saving.
Why not just send the entire string?

#6 valithor

  • Members
  • 1,053 posts

Posted 20 October 2014 - 07:57 PM

Right now my computers doesn't want to let me quote... but I was just offering another way to do it.





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users