Jump to content


Willibilly19's Content

There have been 48 items by Willibilly19 (Search limited from 10-February 22)


By content type

See this member's


Sort by                Order  

#95332 [halp?] missing programs

Posted by Willibilly19 on 10 March 2013 - 03:43 AM in Ask a Pro

turtle.getFuelLevel() isn't a program, go into the Lua interpreter to use it, or use the refuel program. The pastebin program is missing because you haven't enabled the HTTP API in your config file. Just change false to true next to the HTTP API option, it'll show up.



#84618 [Error] attempt to compare __le on nil and number

Posted by Willibilly19 on 07 February 2013 - 12:35 AM in Ask a Pro

I don't know exactly what caused it, but adding in an additional sleep fixed it:P

while true do
  event, button, x, y = os.pullEvent(monitor_touch)

  if x <= 12 and x >= 2 and y <= 4 and y >= 2 then
        rs.setOutput("back", true)
        sleep(1)
        rs.setOutput("back", false)
  end
  sleep(0.5) --This sleep here
end

Just add that one in:P I'm sure someone would be able to explain the issue or something... But it's working xD



#80898 Auto Start computers and turtles

Posted by Willibilly19 on 27 January 2013 - 11:06 AM in Ask a Pro

That's just how the computers work. I don't think there is a way around it in the code(I could be wrong)...but you could always get a chunk loader and keep the chunk loaded while away.



#79868 [Lua][Question] Countdown Timer on Loop?

Posted by Willibilly19 on 24 January 2013 - 12:38 PM in Ask a Pro

Oh wow, My internet was bugging out for a while....don't know how that happened lol but I fixed my post as well.

And You are quite welcome. Glad I could help out.



#79849 [Lua][Question] Countdown Timer on Loop?

Posted by Willibilly19 on 24 January 2013 - 11:40 AM in Ask a Pro

<p>The problem was the line not clearing before it printed the single digit numbers. The 0 you were seeing was actually the 0 from the 10. Here is a working code for ya.(There might be a better way to do it....but this works.)


function info()
  term.clear()

  term.setCursorPos(3,2)
  print("Estimated Travel Times: ETT")

  term.setCursorPos(3,4)
  print("Dorfanos <-> SquareSky City")

  term.setCursorPos(3,5)
  print("Fourty-Two Seconds")

  term.setCursorPos(3,7)
  print("Train arriving in..")

  term.setCursorPos(5,8)
end

seconds = 42
wait = 63 

i = seconds

while true do
  while i <= seconds and i > 0 do
	i = i - 1
	info()
	print(i)
	sleep (1)
  end
  if i == 0 then
    i = seconds
    info()
    print("Arrived")
  end
  sleep(wait)
end




#79644 computer controled prision

Posted by Willibilly19 on 23 January 2013 - 10:04 PM in Ask a Pro

That could be accomplished easily with Wireless Redstone. I'd say put 2 wireless receivers under each door. One Frequency set to the room number, and one Frequency set to a number that you won't be using(1000 or so). Then when you run the code on your computer, have it either open a single door by telling it the room number, or to open all the doors by giving it that master frequency.

Having it so you can open each door individually from the cell, you could either have a computer at each cell...or you could carry a remote around with you to turn that frequency on. If you need help with it, I'd be glad to help you.



#79324 Is it possible to refuel this way?

Posted by Willibilly19 on 23 January 2013 - 09:24 AM in Ask a Pro

Yea it's possible. if you know how many moves it's going to make (Or write in a function to do the math for you) and how many moves each piece of fuel will give you, then you could just tell it to select it's fuel slot and refuel x times.

An alternative is doing something like this.

function refuel()
  if turtle.getFuelLevel() < x then
    turtle.select(1)
    turtle.refuel(1)
  end
end

just change the "x" to the fuel level you want it to refuel at and tell it which slot to select/how many time to refuel. Put that function into your movement loop and it won't use more fuel than it needs.



#79310 Help please. Simple tunnel script not working properly

Posted by Willibilly19 on 23 January 2013 - 09:05 AM in Ask a Pro

I'd be happy to explain. got skype or something? just so we aren't littering the forums here.



#79309 Help please. Simple tunnel script not working properly

Posted by Willibilly19 on 23 January 2013 - 09:04 AM in Ask a Pro

I think this is how I'd do something like that.

tArgs = {...}
length = tArgs[1]

if #tArgs ~= 1 then
  print("Usage: branch <length>")
end


local function forward()
  while not turtle.forward() do
    turtle.dig()
    turtle.digUp()
    turtle.attack()
  end
end


local function tunnel()
  forward()
  if not turtle.detectDown() then
    turtle.select(1)
    turtle.placeDown()
  end
end


for i = 1,length do 
  tunnel()
end
turtle.digUp()

for i = 1,length do
  turtle.back()
end



I'd probably add some more to it, but that would be the basic code.



#79295 Help please. Simple tunnel script not working properly

Posted by Willibilly19 on 23 January 2013 - 08:46 AM in Ask a Pro

I have not written a program to do that actually. I have a link to my programs in my signature. I'm still new to Lua as well(only a couple months)....so my work isn't exactly great:P



#79277 Help please. Simple tunnel script not working properly

Posted by Willibilly19 on 23 January 2013 - 08:24 AM in Ask a Pro

View Postle nub, on 23 January 2013 - 08:17 AM, said:

AH, i suspected i was calling it twice, that explains why he was skipping those fillers below too. I really appreciate your help dude, and everybody else.
Next time i ask for help ill try to find my own spelling errors... :P sorry for that

No problem. I just threw the code onto my turtle and checked it for you. Glad I could be of help. btw, it's a decent script for just starting:P



#79267 too long w/o yeilding fix?

Posted by Willibilly19 on 23 January 2013 - 08:11 AM in Ask a Pro

Don't need os.sleep(), just sleep() will work for ya.....so like add in sleep(1) in every now and then.



#79260 Help please. Simple tunnel script not working properly

Posted by Willibilly19 on 23 January 2013 - 08:05 AM in Ask a Pro

I got it working. Took out the "end" on line 9, you have elseif there, so if you don't end it...just let it move on. Fixed a spelling error on line 4 and 7. also removed the turtle.forward() from line 20. ( the "if not turtle.forward() do" line will actually move the turtle forward, so in your original code, he was moving twice for each space.

--[[   Go   ]]--
function checkBlocks()
if turtle.detectUp() then
turtle.digUp()
end

if turtle.detectDown() then
return true


elseif not turtle.detectDown() then
turtle.select(1)
sleep(0.375)
turtle.placeDown()
end
end

function moveForward()
checkBlocks()
sleep(0.375)
if not turtle.forward() then
turtle.dig()
turtle.forward()
end
end


function tunnel()

	  input = read()
	  print("tunneling "..input.." blocks deep...")

for moved = 1, tonumber(input) do
moveForward()
	end
moved = 0
print("Finished!!")
sleep(3)

end

print("How many spaces? ")
tunnel()
-- i know i suck at this...




#79242 'Then' Expected

Posted by Willibilly19 on 23 January 2013 - 07:46 AM in Ask a Pro

I'm not getting any errors when I run the program...but if I type in "English", the German menu still comes up.



Edit* Nevermind, changing the code as remiX said fixed that



#79239 Turtle has to move input steps

Posted by Willibilly19 on 23 January 2013 - 07:40 AM in Ask a Pro

There is a program included on turtles already called go. type "go forward 5" it goes forward 5....same for back, up, and down. another called turn, so "turn left" or "turn right"


tArgs = {...}
length = tArgs[1]

for i = 1, length do
 turtle.forward()
end



Here's the code you asked for though. If you name the file "forward" or whatever....type "forward 5"...it'll go 5.



#78895 [lua] Dispenser Program Only Dispenses One?

Posted by Willibilly19 on 22 January 2013 - 02:02 PM in Ask a Pro

Hmm, I was just looking over your code and I couldn't figure out why it's not working for you. I did however add it to notepad++ and work out the spacing while I was reading it, so maybe it will help someone more advanced see the issue.

inside = "back"
outside = "bottom"
p = 0
pstat = 0
b = 0
bstat = 0
c = 0
cstat = 0
term.clear()
term.setCursorPos(1,1)
print("Order Calculations")
print("Porkchops: "..p)
print("Beef: "..B)/>
print("Chicken: "..c)


while true do	
  os.pullEvent("redstone")
  if rs.testBundledInput(inside, colours.white) then
	p = p + 1
	pstat = pstat + 1
  elseif rs.testBundledInput(inside, colours.orange) then
	b = b + 1
	bstat = bstat + 1
  elseif rs.testBundledInput(inside, colours.magenta) then
	c = c + 1
	cstat = cstat + 1
  elseif rs.testBundledInput(inside, colours.yellow) then
	p = 0
	b = 0
	c = 0
  elseif rs.testBundledInput(inside, colours.lightBlue) then
	repeat
	  if pstat > 0 then
		p = 0
		for i=1, pstat do
		  rs.setBundledOutput(outside, 1)
		  sleep(1)
		  rs.setBundledOutput(outside, 0)
		end
		pstat = 0
	   elseif bstat > 0 then
		b = 0
		for i=1, bstat do
		  rs.setBundledOutput(outside, 2)
		  sleep(1)
		  rs.setBundledOutput(outside, 0)
		end
		bstat = 0
	  elseif cstat > 0 then
		c = 0
		for i=1, cstat do
		  rs.setBundledOutput(outside, 4)
		  sleep(1)
		  rs.setBundledOutput(outside, 0)
		end
		cstat = 0
	  elseif cstat == 0 and bstat == 0 and pstat == 0 then
		print("Finished Order. New Order may be made.")
		sleep(1)
	  end
	until pstat == 0 and bstat == 0 and cstat == 0
  else
	term.clear()
	term.setCursorPos(1,1)
	print("Order Calculations")
	print("Porkchops: "..p)
	print("Beef: "..B)/>
	print("Chicken: "..c)
  end
end


Also, wasn't sure about this bit. it obviously prints, but the variable should be lowercase (to match your variable above.) What is the /> at the end for?


print("Beef: "..B)/>

Edit* (nevermind...seems the /> is something the forum is adding...don't know why though)



#78863 rednet help

Posted by Willibilly19 on 22 January 2013 - 11:55 AM in Ask a Pro

I don't know much about rednet...but try adding quotes around back.....so like

rednet.open("back")

other than that, I'm not sure. I haven't used it much.



#78689 [lua] blocking programs until....

Posted by Willibilly19 on 22 January 2013 - 06:52 AM in Ask a Pro

Not sure if this will work, but time how long it takes for your elevator to run, then add sleep into your code. That seems as if it would work.

while true do
  os.pullEvent("redstone")
  if rs.getInput("left") then -- check the LEFT input
	    -- do something
        sleep(5) --adjust to how long your elevator takes...+ a few seconds if you want
  end
  if rs.getInput("right") then -- check the RIGHT input
	    -- do something
        sleep(5) -- same thing here
  end
end



#78631 [Lua] Need help making a program work

Posted by Willibilly19 on 22 January 2013 - 04:59 AM in Ask a Pro

If you are going to tell it to continue, you can do this.

print("Continue?")
read()

To continue with that, you just hit enter.

You don't have to print if you don't want to.



#78622 Working with Railcraft

Posted by Willibilly19 on 22 January 2013 - 04:41 AM in Ask a Pro

If your trains took exactly the same amount of time to arrive at the station each and every time, you could hard code in the times. The best bet for this would be from the last point on the track you can detect the train, time them from that point (signal...or whatever you have that could detect them) and start the timer as soon as the train passes over that point.



#78615 [Lua] Need help making a program work

Posted by Willibilly19 on 22 January 2013 - 04:26 AM in Ask a Pro

Yea, it's literally printing "senderId" though because you have quotes around it. take the quotes off to print the Id of the sender.



#78538 [Lua] [Question] Need help with my quarry program.

Posted by Willibilly19 on 21 January 2013 - 11:38 PM in Ask a Pro

Thanks a lot for your reply. I think I might place this code on hold for a while and try to work on a couple API's myself. I think that would be very beneficial to my learning :)
I really like how your code looks, and judging just by that, I have a lot to learn(I knew this already...and even though I understand what your code does, I'm not sure I could implement it all.)



#78537 Print screen

Posted by Willibilly19 on 21 January 2013 - 11:34 PM in Ask a Pro

I think for simplicity's sake, it all works the same, and it seems to look more organized this way. It's also a little easier to understand for someone new to Lua and the API's from ComputerCraft. I haven't used most of these commands myself (before this), but I understand they are all going to the monitor. With the redirect, I now know that you can print to a monitor, which is very nice. I like how this one looks how it is.



#78528 Print screen

Posted by Willibilly19 on 21 January 2013 - 10:52 PM in Ask a Pro

I tried it with term.'s there, but I was getting an attempt to call nil. I changed it to mon. and it stopped throwing up that error.



#78524 Lua question

Posted by Willibilly19 on 21 January 2013 - 10:46 PM in Ask a Pro

Sorry for the really noobish reply. When I asked, I didn't know what the shell was, but I have since looked it up and do understand the reasoning behind your statement.