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

Floppy to Create redstone signal

Started by DCactivity, 28 March 2017 - 05:17 PM
DCactivity #1
Posted 28 March 2017 - 07:17 PM
hi guys, Im a novice Lua coder and im trying to make a basic code for setting off a redstone signal when a floppy disk named "launch key" is placed into the disk drive. The error im getting is just a red number. here is my code:


print("Insert Launch Key")
disk = disk.hasData("bottom")
diskname = disk.getLabel("bottom")
while true do
   if disk == "true" and diskName == "Launch Key" then
   print("Launching!")
   rs.setOutput("top", true)
   sleep(5)
   rs.setOutput("top", false)
   end
   else
   print("Launch Failed")
   end
end
Bomb Bloke #2
Posted 29 March 2017 - 12:48 AM
Rebooting the system would likely correct the error message display.

You're overwriting the disk API table pointer on your second line, so you'll have difficulty indexing into it to fetch "getLabel" on your third. Also bear in mind that "true" isn't the same as true.

There's furthermore a yielding issue in your loop, much like the one I explained here.
DCactivity #3
Posted 29 March 2017 - 07:22 PM
ah ok thanks for the help :)/>
Dave-ee Jones #4
Posted 29 March 2017 - 11:38 PM
You have an end in your if statement yet you want to put an else statement there.

if
...
end
else
...
end
Do it like this:

if
...
else
...
end