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

i need help

Started by cmurtheepic, 10 July 2012 - 09:40 PM
cmurtheepic #1
Posted 10 July 2012 - 11:40 PM
i need help with a program i created and i dont know how to fix it [attachment=309:startup.txt]
LucasUK #2
Posted 11 July 2012 - 12:44 AM
Your calling function N() before you have written it. Move it up top
Grim Reaper #3
Posted 11 July 2012 - 12:47 AM
LucasUK is right. However, another issue that I see is that you never ended your 'if/elseif' tree with an 'end' statement.

Try this:


print ("what color")
x = io.read()
function n()
os.shutdown()
end

if x == "white" then
rs.setBundledOutput("back", colors.white)
n()
elseif x == "black" then
rs.setBundledOutput("back", colors.black)
n()
elseif x == "red" then
rs.setBundledOutput("back", colors.red)
n()
elseif x == "orange" then
rs.setBundledOutput("back", colors.orange)
n()
elseif x == "blue" then
rs.setBundledOutput("back", colors.blue)
n()
elseif x == "magenta" then
rs.setBundledOutput("back", colors.magenta)
n()
elseif x == "cyan" then
rs.setBundledOutput("back", colors.cyan)
n()
elseif x == "yellow" then
rs.setBundledOutput("back", colors.yellow)
n()
elseif x == "green" then
rs.setBundledOutput("back", colors.green)
n()
elseif x == "light blue" then
rs.setBundledOutput("back", colors.lightblue)
n()
elseif x == "lime" then
rs.setBundledOutput("back", colors.lime)
n()
elseif x == "pink" then
rs.setBundledOutput("back", colors.pink)
n()
elseif x == "gray" then
rs.setBundledOutput("back", colors.gray)
n()
elseif x == "purple" then
rs.setBundledOutput("back", colors.purple)
n()
elseif x == "brown" then
rs.setBundledOutput("back", colors.brown)
n()
end
cmurtheepic #4
Posted 11 July 2012 - 01:11 AM
ok thanks but when i run the program it never triggers the color i want it to
LucasUK #5
Posted 11 July 2012 - 01:41 AM
delete :)/>/>
cmurtheepic #6
Posted 11 July 2012 - 01:53 AM
nevermind
exept i would like one of you to help me with getting it to ask after what color to ask the user how many and it would turn off the bundled cable and turn on it that many times
LucasUK #7
Posted 11 July 2012 - 02:13 AM
your using bundled (all colors in 1) cable aspc output not a single color cable also? maybe check:http://www.computercraft.info/forums2/index.php?/topic/2442-rssetbundledoutput-wont-send-signal/
cmurtheepic #8
Posted 11 July 2012 - 02:50 AM
ok when i tried to fix black it would not give output and now it is giving me a syntax error for n()
plz help
Graypup #9
Posted 11 July 2012 - 04:25 AM
Idea: how about compact it a ton by doing

rs.setBundledOutput("back", colors[ix])
on a line and delete the if/else trash.
Hmm, lemme read the code thoroughly and find that syntax error. Or have LuaEdit do it for me :)/>/>.
Graypup #10
Posted 11 July 2012 - 04:32 AM
Nom good code:
Spoiler

-- init stuff first :)/>/>
function n()
os.shutdown()
end
print ("what color")
x = io.read()
if x == "white" then
rs.setBundledOutput("back", colors.white)
n()
elseif x == "black" then
rs.setBundledOutput("back", colors.black)
n()
elseif x == "red" then
rs.setBundledOutput("back", colors.red)
n()
elseif x == "orange" then
rs.setBundledOutput("back", colors.orange)
n()
elseif x == "blue" then
rs.setBundledOutput("back", colors.blue)
n()
elseif x == "magenta" then
rs.setBundledOutput("back", colors.magenta)
n()
elseif x == "cyan" then
rs.setBundledOutput("back", colors.cyan)
n()
elseif x == "yellow" then
rs.setBundledOutput("back", colors.yellow)
n()
elseif x == "green" then
rs.setBundledOutput("back", colors.green)
n()
elseif x == "light blue" then
rs.setBundledOutput("back", colors.lightblue)
n()
elseif x == "lime" then
rs.setBundledOutput("back", colors.lime)
n()
elseif x == "pink" then
rs.setBundledOutput("back", colors.pink)
n()
elseif x == "gray" then
rs.setBundledOutput("back", colors.gray)
n()
elseif x == "purple" then
rs.setBundledOutput("back", colors.purple)
n()
elseif x == "brown" then
rs.setBundledOutput("back", colors.brown)
n()
end
lol, was wondering why my spoilers didn't work, turned out to be a typo: "spoler".
My screen is a projector with rather bad readability, so that happens a lot.
Edited on 11 July 2012 - 02:36 AM