34 posts
Posted 20 October 2012 - 11:18 PM
Ok so today i made a cobble stone generator i could turn on and off by a computer the code was about 10 lines long and i was very happy with myself so i thought i could go 1 step furthur and use a monitor to display the amount of cobblestone going through i am using RP2 to wire it all and if there is anyone out there that could tell me some code and tell me what machines in RP2 to use i would greatly appreciate it
Thanks in Advance
Lewanator1
521 posts
Location
Stockholm, Sweden
Posted 20 October 2012 - 11:20 PM
A great choice is the item detector
34 posts
Posted 20 October 2012 - 11:24 PM
Ok thanks Il check the item detector out
Now to find some code :)/>/>
34 posts
Posted 20 October 2012 - 11:39 PM
Hmm i built the item detector and it just seems to pulse the pipe as the cobblestone goes through the item detector
521 posts
Location
Stockholm, Sweden
Posted 20 October 2012 - 11:49 PM
The item detector got some options:
- Item Mode: Will emit a redstone pulse for every item, e.g. 64 pulses for a stack of dirt.
- Stack Mode: Will emit a single pulse for every stack of items passing through it, e.g. a single pulse for a stack of cobblestone.
- Stuffed Mode: Will emit a constant redstone signal whenever there is an item stuffed back into it, which happens if there are no available destinations left for the item.
Now the code should be really easy to make!
It could be a bit advanced for some users, but I think events would fit the option best!
So something like this:
Spoiler
local event,param1,param2,param3
local monitorSide = "left"
local redstoneInputSide = "right"
local itemCount = 0
monitor = peripheral.wrap(monitorSide)
monitor.clear()
monitor.setCursorPos(1,1)
monitor.write("Items passed: "..itemCount)
while true do
event,param1,param2,param3 = os.pullEvent()
if event == "redstone" then
if rs.getInput(redstoneInputSide) == true then
itemCount = itemCount + 1
end
monitor.clearLine()
monitor.setCursorPos(1,1)
monitor.write("Items passed: "..itemCount)
end
end
Or you know, if you want the value to be stored in a file so that you can reboot the computer and it still works:
Spoiler
local event,param1,param2,param3
local monitorSide = "left"
local redstoneInputSide = "right"
local itemCount = 0
if not fs.exists(".itemCount") then
file = fs.open(".itemCount","w")
file.write(itemCount)
file.close()
else
file = fs.open(".itemCount","r")
itemCount = tonumber(file.readLine())
file.close()
end
monitor = peripheral.wrap(monitorSide)
monitor.clear()
monitor.setCursorPos(1,1)
monitor.write("Items passed: "..itemCount)
while true do
event,param1,param2,param3 = os.pullEvent()
if event == "redstone" then
if rs.getInput(redstoneInputSide) == true then
itemCount = itemCount + 1
end
monitor.clearLine()
monitor.setCursorPos(1,1)
monitor.write("Items passed: "..itemCount)
end
end
521 posts
Location
Stockholm, Sweden
Posted 20 October 2012 - 11:51 PM
Hmm i built the item detector and it just seems to pulse the pipe as the cobblestone goes through the item detector
If you got a redstone pipe then yes it will pulse the pipe.
And if you got the item detector right next to the block breaker it will pulse the block breaker.
Simply: the item detector will pulse in every direction and towards any source.
34 posts
Posted 20 October 2012 - 11:56 PM
OH MY GOD! thanks soo much dude you just saved me hours of messing!!
THANK YOU SO MUCH!
521 posts
Location
Stockholm, Sweden
Posted 21 October 2012 - 12:01 AM
OH MY GOD! thanks soo much dude you just saved me hours of messing!!
THANK YOU SO MUCH!
You're welcome! :)/>/>
I'm glad that I could help you out!
34 posts
Posted 21 October 2012 - 12:03 AM
whats the code to change text size >.< sorry just want to make it huge so i can read it becase its too small for where it is atm :)/>/>
521 posts
Location
Stockholm, Sweden
Posted 21 October 2012 - 12:13 AM
In this case it's:
monitor.setTextScale(int size)
Textscale can be between 1.0 and 5.0, with increments of 0.5.
Read the wiki:
http://computercraft.info/wiki/index.php?title=Peripheral_(API)Be very careful with the sizes! The maximum size is bigger then you think!!