Jump to content




Load code from a file


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

#1 GreenGene

  • Members
  • 78 posts
  • LocationMagic land, awesomeness

Posted 29 October 2015 - 02:03 AM

Hello! I would like to know how to load code from a file without an api like os.loadApi() or shell.run() tnx ~GreenGene

#2 GreenGene

  • Members
  • 78 posts
  • LocationMagic land, awesomeness

Posted 29 October 2015 - 02:09 AM

I found that loadstring() works, thank you for viewing this topic though ;)

#3 Creator

    Mad Dash Victor

  • Members
  • 2,168 posts
  • LocationYou will never find me, muhahahahahaha

Posted 29 October 2015 - 05:21 AM

or dofile("path")

#4 Lupus590

  • Members
  • 2,028 posts
  • LocationUK

Posted 29 October 2015 - 07:38 AM

dofile is better I think

#5 valithor

  • Members
  • 1,053 posts

Posted 29 October 2015 - 11:38 AM

Dofile uses loadstring, so it really is up to preference. Since he said load code from a file out of the two loadstring is definitely the better direct solution.

However, there is a function defined in the bios that will save you a little time, if you only want to load the file as a function but not have it automatically executed like if you were to use dofile. loadfile just loads the file at the given path, and iirc you can pass an environment as the second arg which is used when loadstringing the file.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users