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

In need of help from a experienced Lua coder!

Started by IKJB, 29 August 2012 - 02:47 AM
IKJB #1
Posted 29 August 2012 - 04:47 AM
Please not that I am using computercraft along with other Tekkit equipment, but you don't really need the knowledge of tekkit equipment, it's simple really.

What i'm trying to make is a coins system where the player inputs gold bars through a pipe that will eventually trigger a item detector that will send a pulse to a computercraft computer. For every gold bar that is inputted, I want a counter on my screen that will increase by one. But I can't figure out how to get the counter working. I'm a lua noob so please bear with me.
I have tried things like:

iCount = 0
if event "redstone" and rs.getInput("back") then
iCount = iCount+1
print("Count:"..iCount)

*I do not know how to finish it as I think you need a loop so it will keep checking for a redstone pulse?

Now I know this is bad and you'll probably be rather annoyed, but like I said, I'm new to this and need to learn, so if anyone with the knowledge to be able to do this please guide me through the steps of what to do to make this work? I'm not asking for someone to do this for me, I'm asking for someone to teach me.
PossieTV #2
Posted 29 August 2012 - 05:00 AM
here this might help

iCount = 0 -- don't want iCount in the loop or it will continually set back to zero
while true do -- loop
event = os.pullEvent()
if event == "redstone" and rs.getInput("back") == true then
iCount = iCount+1
shell.run("clear") --if you want the terminal to have only one thing on it
print("Count: "..iCount)
end
end

make sure you have the "==" or you will get an error report D: