Jump to content




Variable for code?


  • You cannot reply to this topic
2 replies to this topic

#1 vyse

  • Members
  • 45 posts

Posted 10 October 2014 - 01:23 AM

I was trying to shorten things that i have to repeat for exp term.setCursorPos(1,1)
and i wanted to do x = term.setCursorPos(1,1)
then have it so when i needed to use that code all i needed to do was do function(X) or print(x)

but all i get is named expected. or the code as text.

So im wondering if you actually your variables for codes?

I know you can do like..
x = colors.red
y = 3

term.setBackground(x)
term.clear()
term.setCursorPos(10,1)
  print("hello")
sleep(y)
but can you do the whole thing?

#2 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 10 October 2014 - 01:29 AM

I think you are looking for functions.
local function x()
  term.setBackgroundColor( colors.red )
  term.clear()
  term.setCursorPos( 10, 1 )
  print( "hello" )
  sleep( 3 )
end
--#and calling it
x()


#3 vyse

  • Members
  • 45 posts

Posted 10 October 2014 - 01:59 AM

thank you





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users