6 posts
Posted 02 August 2014 - 12:13 PM
Hi
Bit new to all this ComputerCraft stuff and im a little stuck on a program …
Ive made a 1 vs 1 PVP arena on our server and the idea is that each player drops down a shoot hitting a pressure plate at the bottom. Once both pressure plates are activated it starts a countdown timer of 1 minute before the doors open allowing access to the arena.
Ive made the countdown timer and it works fine, its just the redstone activation program to start the countdown that im having problem with.
Heres the redstone input program im having problems with…
while true do
event = os.pullEvent()
if event == "redstone" and rs.getInput(right) == true then
–run countdown
end
When run I get the error..
bios:339 [string "redstone"] :7 : '=' expected
Any help would be much appriciated
Thanks
Moogstar
7508 posts
Location
Australia
Posted 02 August 2014 - 02:39 PM
okay everything you're doing there is fine. The first thing I notice is the error is saying the problem is in the file 'redstone', is this code from that file and is this all of the code?
did you type this out manually here or copy/paste? if you've typed it out here make sure in the if condition on your version in-game are both == and not a single =
6 posts
Posted 02 August 2014 - 02:49 PM
Hi
Thanks for the reply..
The code is from my program called redstone and what you see is all the code from that program.
I did actually copy the code originally from another thread and its identical as it is above as it is in game.
I have used == and not single =
Its got me stumped!
154 posts
Location
London, England
Posted 02 August 2014 - 05:23 PM
You need to use
rs.getInput("right")
without the quatation marks, you are passing nil variable
right to the function rather than string "right"
6 posts
Posted 03 August 2014 - 11:12 AM
Tried with quotation marks and still getting the same error.
I cant figure out what it can be, im stumped!
154 posts
Location
London, England
Posted 03 August 2014 - 01:53 PM
Oh, you also missed off the end to complete your while loop
You can also just use rs.getInput("right") and not have that comparison as getInput() just returns true or false anyway
6 posts
Posted 03 August 2014 - 03:01 PM
Mmmm like this…?
while true do
end
rs.getInput("right")
run countdown
end
Still getting..
bios:339: [string "redstone"] :7: '=' expected
Thanks
7508 posts
Location
Australia
Posted 03 August 2014 - 03:09 PM
no, like this
while true do
local event = os.pullEvent()
if event == "redstone" and rs.getInput(right) then
--# run countdown
end
end
though missing an end won't yield that error. I suspect that you've made a typo somewhere, such as a
, (comma) instead of a
. (period). Another possibility, I noticed in your latest code you only had
run countdown without the
– at the start this time, is it like this in your code?
6 posts
Posted 03 August 2014 - 05:53 PM
Doh!
Yeh missed the – /faceplam
Rewrote the code again and it doesn't crash out anymore :)/>
Doesn't seem to want to start the countdown program tho ?!
Btw…thanks for your time..
7508 posts
Location
Australia
Posted 03 August 2014 - 06:17 PM
well
– is a
comment. In order to run a program you must use
shell.run.
6 posts
Posted 03 August 2014 - 09:28 PM
Aha!
Ok, ive read about shell.run and added a line at the end,
It Works!!
Thankyou for all the help folks!
Last time I programmed anything it was on a Sinclair Spectrum! :blink:/>