- ComputerCraft | Programmable Computers for Minecraft
- → --Kaos--'s Content
--Kaos--'s Content
There have been 10 items by --Kaos-- (Search limited from 29-March 23)
#275533 1 terminal multiple disks
Posted by --Kaos-- on 28 February 2018 - 03:08 PM in Ask a Pro
Hi alll
so i have tried to figurie this out myself and look online for about a week before finally giving in and asking for help.
what i am trying to do is the following
I have 1 terminal computer and 1 disk drive. The disk drive is on the top of the computer
back , front left and right have redstone connected to them
What i want to do is when i insert a disk named "level2" then it activates for example the left side redstone for a time and then turn off , however, if i put in a disk named "basement" then the right redstone is activated
the labels of the names are redundant tbh as i was looking for the computer to read the disk with the following
ie.
disk labeled BASEMENT has data written of
key = "basement"
disk labeled "level2" has data written of
key = "level2"
So instead of having loads of disks i can have 4 disks to 1 computer and 1 drive. I want them to be used as access keys to open up different places per floor so having loads of terminals is something that wouldnt work
can someone pleaaasee help me as this is driving me nuts
thanks
Kaos
so i have tried to figurie this out myself and look online for about a week before finally giving in and asking for help.
what i am trying to do is the following
I have 1 terminal computer and 1 disk drive. The disk drive is on the top of the computer
back , front left and right have redstone connected to them
What i want to do is when i insert a disk named "level2" then it activates for example the left side redstone for a time and then turn off , however, if i put in a disk named "basement" then the right redstone is activated
the labels of the names are redundant tbh as i was looking for the computer to read the disk with the following
ie.
disk labeled BASEMENT has data written of
key = "basement"
disk labeled "level2" has data written of
key = "level2"
So instead of having loads of disks i can have 4 disks to 1 computer and 1 drive. I want them to be used as access keys to open up different places per floor so having loads of terminals is something that wouldnt work
can someone pleaaasee help me as this is driving me nuts
thanks
Kaos
#275535 1 terminal multiple disks
Posted by --Kaos-- on 28 February 2018 - 04:43 PM in Ask a Pro
wow thats great thank you
i understand the idea of that but not sure how to put this into context.
i found someone elses code online who wrote
this is actually perfect if this worked for say 4 different floppy disks
i understand the idea of that but not sure how to put this into context.
i found someone elses code online who wrote
os.pullEvent = os.pullEventRaw while true do if disk.isPresent("top") then if fs.exists("disk/.security/key") then shell.run("disk/.security/key") if key == "lemmein" then disk.eject("top") rs.setOutput("left", true) sleep(3) rs.setOutput("left", false) else disk.eject("top") end else disk.eject("top") end end sleep(0.1) endbut this only works for one floppy disk
this is actually perfect if this worked for say 4 different floppy disks
#275539 1 terminal multiple disks
Posted by --Kaos-- on 28 February 2018 - 05:48 PM in Ask a Pro
Hi again
for some reason the programme seems to stop
i set the programe as startup
i get "startup:9: expected String, string
i assume the part its point to is line
if tKeys[ key ] then --#modify this to be "basement" or whatever you want"
ive put it in as
[basement]
["basement"]
"basement"
but stil not playing
this stuff is hard man hahahaha
for some reason the programme seems to stop
i set the programe as startup
i get "startup:9: expected String, string
i assume the part its point to is line
if tKeys[ key ] then --#modify this to be "basement" or whatever you want"
ive put it in as
[basement]
["basement"]
"basement"
but stil not playing
this stuff is hard man hahahaha
#275543 1 terminal multiple disks
Posted by --Kaos-- on 28 February 2018 - 06:34 PM in Ask a Pro
am i correct in saying this based on your expert knowledge
currently fails
startup:7: Expected String
local tKeys = { ["basement"] = "back", ["level2"] = "left", } while true do local event, side = os.pullEvent("disk") if disk.hasData("top") and fs.exists( "/disk/.security/key", "r") then local file = fs.open( "/disk/.security/key" ) local key = file.readAll() file.close() if tKeys["basement"] then disk.eject("top") rs.setOutput(tKeys[key], true) sleep(3) rs.setOutput(tKeys[key], false) elseif tKeys["level2"] then disk.eject("top") rs.setOutput(tKeys[key], true) sleep(3) rs.setOutput(tKeys[key], false) else disk.eject("top") end end end
currently fails
startup:7: Expected String
#275545 1 terminal multiple disks
Posted by --Kaos-- on 28 February 2018 - 06:55 PM in Ask a Pro
im so glad knowledgable people like yourself exist as this is more complicated than i first thought ! haha
honestly, its appreciated like so much!
Startup:13: Expected string Boolean
:S
figured it out
the Boolean was because the part
rs.setOutput(tKeys[key], true)
should be
rs.setOutput(tKeys["basement"], true)
testing more as we speak but so grateful guys
honestly, its appreciated like so much!
Startup:13: Expected string Boolean
:S
figured it out
the Boolean was because the part
rs.setOutput(tKeys[key], true)
should be
rs.setOutput(tKeys["basement"], true)
testing more as we speak but so grateful guys
#275546 1 terminal multiple disks
Posted by --Kaos-- on 28 February 2018 - 07:16 PM in Ask a Pro
so update
basement works fine
the code works as it should. the disk ejects, the redstone at the back lights up and then turns off
however, if i do the exact same thing with a floppy disk with level2 it does nothing ,no ejection or redstone
its like its being ignored :s
basement works fine
the code works as it should. the disk ejects, the redstone at the back lights up and then turns off
however, if i do the exact same thing with a floppy disk with level2 it does nothing ,no ejection or redstone
its like its being ignored :s
#275549 1 terminal multiple disks
Posted by --Kaos-- on 28 February 2018 - 10:19 PM in Ask a Pro
KingofGamesYami, on 28 February 2018 - 10:09 PM, said:
I'm terribly sorry I've been messing this up so much, thought this would be super easy to write. Had a bunch of classes to take but I'm back now />
Spoiler
Don't actually modify the part that was marked as "modify this" with a comment earlier -- that was accedentially left in there from an earlier design. The only part you should need to change is the table at the top.local tKeys = { ["basement"] = "right", ["level2"] = "left", --# add additional entries here to pair more sides and phrases } while true do local event, side = os.pullEvent( "disk" ) --#note: instead of checking 10 times a second, --#this only checks when a disk was inserted if disk.hasData( side ) and fs.exists( "/disk/.security/key" ) then --#I check if the disk has data first, because technically --#it's possible to insert music disks which don't have a file system. local file = fs.open( "/disk/.security/key", "r" ) local key = file.readAll() file.close() --#running a program on a disk is a major security flaw of the progrm you posted --#that program could do anything, such as deleting all your files, or opening all the doors --#instead, here I read the file, the contents of which should simply be basement or level2 if tKeys[ key ] then --#if the key given is in tKeys ("basement" or "level2") --#eject the disk disk.eject( side ) --# set output on the side paired in tKeys (for "basement", that is "right") rs.setOutput(tKeys[key], true) sleep(3) rs.setOutput(tKeys[key], false) else disk.eject( side ) end end end
hehe its okay.
your time on this is very kind of you
i really appreciate it honestly, forever in your debt
#275550 1 terminal multiple disks
Posted by --Kaos-- on 28 February 2018 - 10:32 PM in Ask a Pro
im sorry i am not much use of this, im learning stacks of information from what you are giving so im learning as we go along
i fixed it!
it was the path in the end that was causing the major issues, i change the path just to /disk/disk/ in the code and now reads like a dream!!!!!
thanks so much!!!!
- ComputerCraft | Programmable Computers for Minecraft
- → --Kaos--'s Content