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

Cant Fuigure Out whats wrong with some code for a Jeopardy game help?

Started by Pure_Diamond, 13 June 2012 - 03:50 PM
Pure_Diamond #1
Posted 13 June 2012 - 05:50 PM
Im trying to code a jeopardy like game and I have hit a wall. I am having 1 console control all of it, 14 different grid slave consoles and 1 monitor and console. What i am thinking is to have 3 or 4 other podiums with buttons and consoles that tell the master console and then i have a manual override… my problem is that my grid slave code isn't working. here it is, got any ideas?

rednet.open("front")
senderId, message, distance = rednet.receive()
if message == "who" then
if rs.getInput("back") == "true" then
sleep(1)
rednet.broadcast("test")
os.shutdown()
else
os.reboot()
end
else
os.reboot()
end


included are some pictures that I took of my rig (srry about the quality this forum wouldn't let me upload anything higher). Also I am using redpower for the wiring, didn't want to have to deal with the wiring.
MysticT #2
Posted 13 June 2012 - 06:10 PM
The problem is here:

if rs.getInput("back") == "true" then
You are comparing the return value of getInput (wich is a boolean) with a string. It should be:


if rs.getInput("back") == true then
-- or the short way:
if rs.getInput("back") then
-- checking for a boolean doesn't require a comparation
Pure_Diamond #3
Posted 13 June 2012 - 06:27 PM
I just tried that and it didn't work? here is what my code is now

rednet.open("front")
local nTime = os.time()
print( "The time is "..textutils.formatTime( nTime, false ) )
senderId, message, distance = rednet.receive()
if message == "who" then
	if rs.getInput("back") == true then
		sleep(1)
		rednet.broadcast("test")
		os.reboot()
	else
		os.reboot()
		end
else
	os.reboot()
	end

Edit- Nvm it works i just didn't have the lever switched thx!