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

Question about some lines of code

Started by The Penguin21, 05 October 2015 - 11:36 AM
The Penguin21 #1
Posted 05 October 2015 - 01:36 PM
Thanks :D/> the program is awesome!


Im new to computercraft and i would like if someone tells me what is the:

function RCmaster()
and

RCmaster()
(at end) for, also about:

local sEvent, param = os.pullEvent("key")
.



Thanks! :)/>
Lyqyd #2
Posted 05 October 2015 - 03:33 PM
I've split this from here, to prevent unnecessary necromancy.
TheOddByte #3
Posted 05 October 2015 - 03:56 PM
This line of code declares a new function called "RCMaster"

function RCMaster()

And this one calls the function "RCMaster"

RCMaster()

An example

--# Here we declare the function foo
--# when the function is called it will
--# run all the code the function contains
local function foo()
    print( "bar" )
end

foo() --# Call the function "foo", it should output "bar"( without the quotes ofcourse )


And the final line

local sEvent, param = os.pullEvent( "key" )
This line calls the function os.pullEvent, with the parameter "key", which will make it only listen for key events.
When a key event has been pulled it returns the following variables: event, key.
I'd recommend you check out the wiki about os.pullEvent here