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

Function Help.

Started by Bosher, 29 November 2013 - 05:29 PM
Bosher #1
Posted 29 November 2013 - 06:29 PM
Hey, I'm trying to make a click able OS so I'm using button I am making a function to help it stay neat
as I am a noob to ComputerCraft, here is my code.
  • function add(x,y,msg) – this is to set cords for button, but the msg bit does not work.
  • term.clear()
  • term.setBackgroundColor(colors.orange)
  • term.setCursorPos(x,y)
  • print " "
  • term.setCursorPos(x,y+1)
  • print " "
  • term.setCursorPos(x,y+2)
  • print (msg)
  • term.setCursorPos(x,y+3)
  • print " "
  • term.setCursorPos(x,y+4)
  • print " "
  • local sEvent,button,x,y = os.pullEvent("mouse_click")
  • if (x >=x or x<=x+7) and (y >=y or y<=y+5) then
  • print "hi"
  • end
  • end
  • function homepage()
  • add(2,2,Games) – This is were it doesn't work it only seems to read numbers any way to get around this.
  • end
Thanks to anyone that helps me. :)/>
Edited on 29 November 2013 - 05:34 PM
jay5476 #2
Posted 29 November 2013 - 08:56 PM

add(2,2,"Games")
Need quotation marks to tell it its a strig
oeed #3
Posted 29 November 2013 - 09:02 PM
In future please put your code in code tags.

e.g.


print("Hello")
local i = 1 + 1

Select the code and click the blue '< >' button.