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

Shortcut

Started by Crowdy199, 15 January 2013 - 08:05 AM
Crowdy199 #1
Posted 15 January 2013 - 09:05 AM
I have alot of code and i am going to use the same thing agin and agin so is there away to make all the code in one word so i dont have to keep re typing it
OmegaVest #2
Posted 15 January 2013 - 09:28 AM
Functions. Or loops. Only works in one program, though.


function fName (param1, param2)
   for i = param1, param2 do
	  print("I like Trains")
   end
   while param1 ~= param2 do
	  print("Hello Mine Turtle.")
   end
   if param1 == param2 then
	  print("HELLO!")
   end
end
GopherAtl #3
Posted 15 January 2013 - 09:37 AM
If you want to reuse functions like defined in the prev post in multiple programs, put them in a separate file, "myFuncs" or whatever, and load it from other programs with "os.loadAPI("myFuncs")" at the top, then you can call them with "myFuncs.<funcName>(<args>)"