Jump to content




Always eject Disk


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

#1 Kouksi44

  • Members
  • 89 posts
  • LocationMunich, Germany

Posted 03 May 2013 - 11:55 AM

i tried to make little program that ejects a floppy as soon as its injected. But every time I am starting the program, I am getting the same error:'=' expected.

Code:

function Check()
local x= peripheral.isPresent("left")
local y= peripheral.getType("left")
If x==true and y=="drive" then disk.eject("left") end
end

Check()

I just don't get it !! What's wrong with this code ????

#2 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 03 May 2013 - 12:03 PM

Split into new topic.

You have capitalized `if`. It needs to be lower case.

#3 Kouksi44

  • Members
  • 89 posts
  • LocationMunich, Germany

Posted 03 May 2013 - 01:02 PM

oh! thx!!

#4 PixelToast

  • Signature Abuser
  • 2,265 posts
  • Location3232235883

Posted 03 May 2013 - 02:27 PM

here is a better implementation:
local oldpull=os.pullEventRaw
function os.pullEventRaw(...)
local p={coroutine.yield(...)}
if p[1]=="disk" then
peripheral.call(p[2],"eject")
end
return unpack(p)
end
-- eject disks
os.pullEventRaw=oldpull
-- stop ejecting disks






2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users