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

Movie Theatre

Started by Joshuaa0525, 04 April 2014 - 11:36 PM
Joshuaa0525 #1
Posted 05 April 2014 - 01:36 AM
I am having difficulty with creating a program to run my movie theatre. My set up consists of either a lever or two buttons depending on which will work better, an advanced computer, a 6x8 advanced monitor to the right of the computer, and a disk drive on top. I am using computercraft 1.6 and using the treasyre floppy alongtimeago. What I want is to be able to have the floppy in the disk drive and to basically design a program that if I flip a lever or press a button it will initiate the movie on the monitor and if I flip the lever again or push another button it stops. I know the basic manual from the computer way is to input :

monitor right disk/alongtimeago
I have tried using bundled cables because its run from a control room setup that runs lights and that's kinda what I'm aiming to use. However I cannot get the code to work. I have tried the following example and it has not worked can someone guide me to solving this please and thank you.

while true do
  local event = os.pullEvent("redstone")
  local start=rs.testBundledInput("back",colors.orange)
  if start then
		shell.run "monitor right disk/alongtimeago"
  else
		shell.run "clear"
  end
end
Lyqyd #2
Posted 05 April 2014 - 02:16 AM
Moved to Ask a Pro.

Make sure you're not using a treasure disk from the creative menu, but one you actually found. If it still isn't working, describe what it does and list any error messages you see.
Agoldfish #3
Posted 06 April 2014 - 12:54 AM
I may be wrong, but is

shell.run "monitor right disk/alongtimeago"
Vaild? Last I checked you needed parentheses.
Possibly the same for

shell.run "monitor right disk/alongtimeago"
CometWolf #4
Posted 06 April 2014 - 01:00 AM
parentheses are not nessacary when passing a single string.
Eg.

print "derpderp"
works just fine.
Bomb Bloke #5
Posted 06 April 2014 - 01:58 AM
(At least part of) your problem is that once you "shell.run" the other script, your first script halts its execution, and sits and waits until "alongtimeago" finishes before continuing. It hence won't respond to lever/button input again until then.

In theory you should be able to get around this with the parallel API (this example built for use with a single lever):

local mon = peripheral.wrap("right")
mon.clear()

while true do
	if rs.getInput("back") then
		print("Starting playback...")
		term.redirect(mon)
		
		parallel.waitForAny(
			function()
				shell.run("disk/alongtimeago")
			end,
			
			function()
				repeat os.pullEvent("redstone") until not rs.getInput("back")
			end
		)
		
		term.redirect(term.native())
		print("Halting playback...\n")
		mon.clear()
	end

	os.pullEvent("redstone")
end

You could also implement something like Lyqyd's "pause" script.

Make sure you're not using a treasure disk from the creative menu, but one you actually found.

About that - while I gather that console commands won't yield a valid disk, I've had no such issues with creative menu disks. Mind you, I've only tried them under 1.6 and its prereleases.
1lann #6
Posted 06 April 2014 - 02:32 AM
also, isn't it stored under /disk/dan200/secret/alongtimeago or something like that? Make sure that you get the path correct.

Also if you could tell us the problem more in depth, like whether there is an error, or if it's just not doing anything, that would be helpful too.
Bomb Bloke #7
Posted 06 April 2014 - 02:41 AM
also, isn't it stored under /disk/dan200/secret/alongtimeago or something like that?

Something "like" that… but only prior to ComputerCraft 1.56.
Edited on 06 April 2014 - 12:42 AM