I have a program that is not written by me.
I use it as Item Counter.
Now I would like to have the following changes in the program.
At the moment I start the program as follows:
Monitor top counter
I would like to save the program as startup and it should still appear on the top screen.
Problem 2:
I would like to have a function in the program that will be deducted for a Redstone signal from behind the computer.
The variable for this I have created above already but I do not know exactly where in the loop the query must be inserted.
And lastly, the problem is that the value should be stored. Because if I restart the server, the value is reset to 0
I know this is a bit much but I would be glad if someone could help me here!
Here is the code:
-- ItemCounter by redled72 5/2012
cdel = ("right") -- Reset Counter (Button, Switch...)
cin = ("left") -- Input Counter (RP-Signal, Redstonepipe...)
cout = ("back") -- Input Counter (RP-Signal, Redstonepipe...)
local s = 0
local inp = false
local z = 0
local stack = 0
local stueck = 0
local count = 0
function _latch(inp) -- Counter
if inp == true then
count = count + 1
while rs.getInput(cin) == inp do
sleep(0.05)
end
end
if rs.getInput(cdel) == true then
count = 0
end
sleep(0.05)
return count
end
function _str(z) -- Stack/Stueckrechnung
sta = math.floor(z / 64)
stu = math.fmod(z, 64)
return sta, stu
end
function _ascii()
out = string.char(98,121,32,82,101,100,108,101,100,55,50)
return out
end
while s == 0 do -- Loop Hauptschleife
inp = rs.getInput(cin)
z = _latch(inp)
stack, stueck = _str(z)
shell.run("clear")
print("Samen Stueckzahl: " ..z.. " ")
print("Anzahl in Stack : " ..stack.." & " ..stueck.. " Stueck")
end
print(newline)
print(""CC-ItemCounter" " .._ascii().. "")
Sincerely yours
Fussel01