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

direwolf20 uberminer code

Started by paz, 28 December 2014 - 08:42 PM
paz #1
Posted 28 December 2014 - 09:42 PM
I've got an uberminer based pretty much exactly on direwolf20's uberminer in his server play series forgecraft2 S5E10.

Now I got most of my programming to work, but he never did the part where it would be continuously run by a lever input, so I've been trying to cobble together that part of the programming since I havent been able to find a copy of what I need anywhere. I've got a very limited understanding of how computercraft coding works so far, and haven't been able to nail down the error so far.

Here's a screen cap of my setup
http://gyazo.com/394...6f36550daebe31d

And my code
http://gyazo.com/117...f25c8e8476e28d5


I want it to run when the lever on the right is on.
The power monitor on the bottom is set to emit a redstone signal when the capacitor gets low on power in order to pause the program.
The output on the top moves the uberminer frame
and the output on the left turns the tesseract on so that the mining wells aren't continuously draining power.

Currently the program will run, but I have to stand there and toggle the switch on and off to get it to work. I'd like to just flip the switch and be able to leave it run.

Thanks!
KingofGamesYami #2
Posted 28 December 2014 - 10:26 PM
First: Lets clean up that code a little.


while true do
  os.pullEvent( "redstone" )
  if rs.getInput( "right" ) then
    function moveFrame()
      rs.setOutput( "top", true )
      sleep( 0.5 )
      rs.setOutput( "top", false )
    end

    function mine()
      --if not rs.getInput( 'bottom' ) then
        rs.setOutput( "left", true )
        sleep( 10 )
        rs.setOutput( "left", false )
      --end
    end

    if not rs.getInput( "bottom" ) then
      moveFrame()
      mine()
    end
    while not rs.getInput( "right" ) do
       sleep( 1 )
    end
  end
end

Now, a step by step process of what your code IS doing:

1 - waits for a change in the redstone state

2 - checks if there is an input on the right

if so, the program will define two global functions: moveFrame and mine.

3 - checks if there is not an input on to bottom

if this is true, it calls the global functions moveFrame and mine

4 - it sleeps repeatedly for one second, eating all the redstone events, until there is an input on the right

5 - when it detects an input, it goes back to waiting for a redstone change (eg. a redstone event)

——————

Now, I haven't discussed what mine() and moveFrame() are doing.

mine sets and output to the left for ten seconds

moveFrame sets and output to the top for half a second

While either of these are running, the entire computer is waiting for them to stop, and is essentially "frozen".


I don't mean to sound harsh about any of your programming, but I hope this gives you an understanding of the changes you should make.
paz #3
Posted 29 December 2014 - 05:22 PM
Thanks for the help, that seems to have cleared up most of the issues.

However, I can only get the program to loop if I stand there and flip a lever manually. I've tried the project red timer as well as the extra utilities redstone clock to get it to run continuously, neither of which work past the first run of the program.
Help?
Dustmuz #4
Posted 29 December 2014 - 06:04 PM
what i usually do when using the projectred timer with a computer, is place it 1 block away, and put a piece of redstone between the comp and timer, that usually makes my programs work
paz #5
Posted 29 December 2014 - 06:07 PM
Thanks for the suggestion, I tried it, still wont run past the first cycle

all right, with the project red timer set at 0.25 seconds it seems to be working most of the time, wont immediately run the program after it completes, but within 10 seconds or so it will run again.