Here is another code trick. you know how sometimes we want only a particular variable from a function return. Ok for example lets say we want the distance between computers and we are using 'modem_message' event. I don't know why we want the distance, lets just pretend that we do.
ok so normally you would do this
local event, receiveChannel, replyChannel, message, distance = os.pullEvent('modem_message')
but there are a few variables that are sitting there that might confuse us later. so maybe we would do this
local _, _, _, _, distance = os.pullEvent('modem_message')
that looks a little better, but why not get just the distance variable… well we all know we can put it into a table and do this
local event = { os.pullEvent('modem_message') }
local distance = event[5]
but why not just put that in one line? like so
local distance = ( { os.pullEvent('modem_message') } )[5]
this probably isn't really the best way to do things, its very expensive, as we are making a table getting one value, then destroying the table again. But I'm not telling you about this for efficiency, I'm telling you this as a "you can do this"
now we are getting only one variable from function returns. another usage example might be that you are wanting to reset the cursor to the front of the current line
-- this is how you would normally do it
local currentX, currentY = term.getCursorPos()
term.setCursorPos(1, currentY)
-- this is how you could do it with the method described above.
term.setCursorPos(1, ({term.getCursorPos()})[2])
…
Another trick related to the last code snippet.
term.setCursorPos( term.getCursorPos(), 4 )
this will set the cursor x pos to the first value returned by getCursorPos and ignore the other return values from that function.