Jump to content




Help me! Function buGS


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

#1 thegreatstudio

  • Banned
  • 164 posts
  • LocationI am on your computer

Posted 04 May 2013 - 08:29 AM

function draw()
desktop = paintutils.loadImage("background")
paintutils.drawImage(image, screenX, 3)
end
local screenX, screenY = term.getSize()
term.clear()
term.setCursorPos(1, 1)
os.sleep(1)
while true do
term.setBackgroundColor(colors.cyan)
term.clear()
paintutils.drawLine(1, 1, screenX, 1, colors.lightGray)
term.setTextColor(colors.black)
term.setCursorPos(1, 2)
term.setBackgroundColor(colors.lightBlue)
term.setTextColor(colors.blue)
print("[Studio]")
term.setBackgroundColor(colors.red)
term.setCursorPos(10, 2)
term.setTextColor(colors.lightBlue)
print(" [Programs] ")
term.setCursorPos(30 , 1)
term.setTextColor(colors.black)
term.setBackgroundColor(colors.lightGray)
print("Testing 2")
while true do
local event, button, X, Y = os.pullEvent("mouse_click")
if event == "mouse_click" then
if X >= 1 and X <= 10 and Y == 2 and button == 1 then
print("Welcome to Studio OS")
sleep(1)
studio() -- Error: attempt to call nil
elseif X >= 10 and X <= 20 and Y == 2 and button == 1 then
print("Welcome to program section!")
sleep(1)
program() -- Error:attempt to call nil
end
end
end
end
function studio()
term.clear()
term.setBackgroundColor(colors.cyan)
term.clear()
paintutils.drawLine(1, 1, screenX, 1, colors.lightGray)
term.setTextColor(colors.black)
term.setCursorPos(1, 2)
print("[Terminal]")
local event, button, X, Y = os.pullEvent("mouse_click")
if event == "mouse_click" then
if X >= 1 and X <= 10 and Y == 2 and button == 1 then
term.clear()
print("Studio OS version. Testing 3")
print("Type /help for commands!")
while true do
cmd = read("> ")
if cmd == "/help" then
print("Coming soon")
end
end
end
end
end
function program()
term.clear()
term.setBackgroundColor(colors.cyan)
term.clear()
paintutils.drawLine(1, 1, screenX, 1, colors.lightGray)
term.setTextColor(colors.white)
term.setCursorPos(1, 2)
term.setBackgroundColor(colors.black)
print("[Terminal]")
local event, button, X, Y = os.pullEvent("mouse_click")
if event == "mouse_click" then
if X >= 1 and X <= 10 and Y == 2 and button == 1 then
term.clear()
term.setCursorPos(1, 1)
print("Studio OS Testing 2")
print("Type exit to exit this program.")
print("Type help to get started!")
while true do
cmd = read("# ")
if cmd == "help" then
print("Shutdown -- Shutsdown the computer")
print("Restart -- Restarts the computer")
print("Edit -- edits a file")
print("paint -- paints the program!")
print("clrs -- clears the screen")
elseif cmd == "shutdown" then
os.shutdown()
elseif cmd == "restart" then
os.restart()
elseif cmd == "exit" then
break
elseif cmd == "clrs" then
term.clear()
term.setCursorPos(1, 1)
print("Studio OS Testing 2")
print("Type exit to exit this program.")
print("Type help to get started!")
else
shell.run(sr)
end
end
end
end
end

Help me please!

#2 Engineer

  • Members
  • 1,378 posts
  • LocationThe Netherlands

Posted 04 May 2013 - 08:57 AM

What is the unexpected behaviour/error you get?... You should know that by now..

#3 thegreatstudio

  • Banned
  • 164 posts
  • LocationI am on your computer

Posted 04 May 2013 - 09:06 AM

the error is attempt to call nil

#4 GravityScore

  • Members
  • 796 posts
  • LocationLand of Meh

Posted 04 May 2013 - 10:32 AM

You put the program function below where you're calling it from. Move it to the top of the file and it should work.

As a general rule, any functions you call must be placed above where you're calling them from.

#5 thegreatstudio

  • Banned
  • 164 posts
  • LocationI am on your computer

Posted 04 May 2013 - 11:44 AM

View PostGravityScore, on 04 May 2013 - 10:32 AM, said:

You put the program function below where you're calling it from. Move it to the top of the file and it should work.

As a general rule, any functions you call must be placed above where you're calling them from.

ok i'll try it

#6 Dlcruz129

    What's a Lua?

  • Members
  • 1,423 posts

Posted 05 May 2013 - 01:24 AM

Argh. Indent your code, mine eyes are bleeding.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users