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

help please (functions and stuff)

Started by joshgreat, 19 October 2016 - 04:28 PM
joshgreat #1
Posted 19 October 2016 - 06:28 PM
hi guys
yep im back for help
for WOS 2.0 i need functions but cant figure out how to use them
the link for this is http://pastebin.com/7ZDgrfvy
thanks
-JoshGreatUK
Lupus590 #2
Posted 19 October 2016 - 07:03 PM
you need to define functions before you use them:


local function foo() --# define the function
  --# code here will execute when function is called
  --# multiple lines are accepted
end

local bar = function() --# alternative way of defining functions
  --# content as above
end

foo() --# call the function
bar() --# calling is the same nomater how it was defined
Edited on 19 October 2016 - 05:05 PM
KingofGamesYami #3
Posted 19 October 2016 - 07:39 PM
It looks like you have function calls to non-existent functions. Define those functions at the top of your script.

Ex:

local function helloWorld()
  print( "Hello, World!" )
end
--#later on in the program, calling it
helloWorld()