This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
mitterdoo's profile picture

Something Like Include Or Using?

Started by mitterdoo, 06 September 2013 - 05:19 PM
mitterdoo #1
Posted 06 September 2013 - 07:19 PM
Hello. I want to know how I can do this:
file1

function bar()
  print("World!")
end
file2

function foo()
  print("Hello")
end
foo()
bar()

And no, I don't want file2 to be this:

os.loadAPI("file1")
function foo()
  print("Hello")
end
foo()
file1.bar()
Yevano #2
Posted 06 September 2013 - 07:30 PM
dofile fits the description.


dofile("file1")
function foo()
  print("Hello")
end
foo()
bar()
Kingdaro #3
Posted 06 September 2013 - 07:30 PM
Try dofile().

file1:

function bar()
  print("World!")
end

file2:

dofile("file1")
function foo()
  print("Hello")
end
foo()
bar()

EDIT: Ninja'd hardcore. Oh well.
mitterdoo #4
Posted 06 September 2013 - 07:35 PM
Thanks.
Mod lock please.
Kingdaro #5
Posted 06 September 2013 - 08:08 PM
Actually, AAP threads usually aren't locked, in the event that maybe someone has useful or updated information to add to the thread, or if the OP wants to ask another question on the same issue.