water="on"
function await()
repeat
event, param1 = os.pullEvent()
if water=="on" then
water="off"
elseif water=="off" then
water="on"
end
until event=="char" and param1=="17"
watercontrol()
end
function watercontrol()
term.clear()
term.setCursorPos(10,5)
write("W: ")
if water=="on" then
redstone.setOutput("left", true)
print("Water cooling: ".. water .. " ")
elseif water=="off" then
redstone.setOutput("left", false)
print("Water cooling: ".. water)
end
await()
end
watercontrol()
This is a read-only snapshot of the ComputerCraft forums,
taken in April 2020.
help please, this gives no sense to me that it ain't working
Started by nicolaieno, 13 August 2014 - 07:30 PMPosted 13 August 2014 - 09:30 PM
Posted 13 August 2014 - 09:52 PM
Moved to Ask a Pro.
Could you tell us what error you're getting? The error includes the filename and line number, as well as the reason it's not working.
We just need more info as to what is not working.
Could you tell us what error you're getting? The error includes the filename and line number, as well as the reason it's not working.
We just need more info as to what is not working.
Posted 13 August 2014 - 10:33 PM
You're using the event system wrong
So basically to fix that part you would have to change it to
Now I agree with Cranium, a little more information would be good
until event == "char" and param1 == "17"
because this would never be possible, the event 'char' returns the key pressed by it's id or what you could call it, so for example if I pressed the spacebar it would return ' ', now if I used "key" instead of "char" it would return 57 which is the keycode for spacebar( if I remember correctly )So basically to fix that part you would have to change it to
until event == "key" and param1 == 17
or
until event == "char" and param1 == "w"
Now I agree with Cranium, a little more information would be good
Edited on 13 August 2014 - 09:04 PM
Posted 13 August 2014 - 10:43 PM
You made a mistake, the second one has to be "char".You're using the event system wrongbecause this would never be possible, the event 'char' returns the key pressed by it's id or what you could call it, so for example if I pressed the spacebar it would return ' ', now if I used "key" instead of "char" it would return 57 which is the keycode for spacebar( if I remember correctly )until event == "char" and param1 == "17"
So basically to fix that part you would have to change it tooruntil event == "key" and param1 == 17
until event == "key" and param1 == "w"
Now I agree with Cranium, a little more information would be good
Posted 13 August 2014 - 11:04 PM
Whoops, edited now :)/>You made a mistake, the second one has to be "char".
Posted 31 August 2014 - 04:55 AM
water = "on"
function await()
repeat
event, param1 = os.pullEvent()
if water == "on" then
water= "off"
elseif water == "off" then
water = "on"
end
until event == "char" and param1 == "17"
watercontrol()
end
function watercontrol()
term.clear()
term.setCursorPos(10,5)
write("W: ")
if water == "on" then
redstone.setOutput("left", true)
print("Water cooling: "..water " ")
elseif water=="off" then
redstone.setOutput("left", false)
print("Water cooling: ".. water)
end
await()
end
watercontrol()
Hope this help! :P/>
function await()
repeat
event, param1 = os.pullEvent()
if water == "on" then
water= "off"
elseif water == "off" then
water = "on"
end
until event == "char" and param1 == "17"
watercontrol()
end
function watercontrol()
term.clear()
term.setCursorPos(10,5)
write("W: ")
if water == "on" then
redstone.setOutput("left", true)
print("Water cooling: "..water " ")
elseif water=="off" then
redstone.setOutput("left", false)
print("Water cooling: ".. water)
end
await()
end
watercontrol()
Hope this help! :P/>
Edited on 31 August 2014 - 02:56 AM
Posted 31 August 2014 - 06:11 PM
Please use code tags when posting code-Snip-
[.code] Code here [./code] ( Without the period )
Posted 13 September 2014 - 06:27 AM
..
Edited on 13 September 2014 - 04:28 AM
Posted 13 September 2014 - 06:48 AM
Not sure if this is the problem, but I see a recursion issue with watercontrol calling await, calling watercontrol, and on and on. This would probably be better handled with a loop. Additionally, variables/functions should be localized unless they're required to be global for some reason.