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

My Over Complex Program

Started by how2doit, 07 October 2015 - 12:40 AM
how2doit #1
Posted 07 October 2015 - 02:40 AM
Can someone help me shrink my program it is very large and I would like it to be more compact. Also can someone help me get bundled outputs to work with it for some reason i can't get it to unset an output for it. This Program is going to be for a build i'm doing the computer is where i will type in an order and then it will go and fetch the order, but the way i have it right now is not ideal so help would be appreciated :D/> here is the program:

Spoiler
local x
write("What's your order?")
read()
read = x
if x == Hearty_Breakfast then
do
turtle.getItemCount(1)
if turtle.getItemCount(1) > 10 then
print("Funds Sufficent")
x = turtle.getItemCount(1) - 10
x = x+0
turtle.transferTo(2, x)
turtle.dropDown(10)
turtle.select(2)
turtle.dropUp()
turtle.select(1)
rs.setAnalogOutput("front", 15)
sleep(3)
rs.setAnalogOutput("front", 0)

if turtle.getItemCount(1) == 10 then
print("Funds Sufficent")
rs.setAnalogOutput("front", 15)
sleep(3)
rs.setAnalogueOutput("front", 0)
end
x = turtle.getItemCount(1) - 10
x = x+0
turtle.transferTo(2, x)
turtle.dropDown(10)
turtle.select(2)
turtle.dropUp()
turtle.select(1)

if turtle.getItemCount(1) < 10 then
print("Insufficent Funds")
end
end
end
end
Edited by
KingofGamesYami #2
Posted 07 October 2015 - 05:46 AM
Well, let's start:


write( "What's your order?" )
local input = read()
--#Notice I didn't forward declare the variable formerly known as x
--#I renamed it to input because it is more descriptive
--#You also must set a value equal to what read() returns, which you did not
--#(although you did delete the function read, by overwriting it with the value of x, which was previously declared as nil)
if input == "Hearty_Breakfast" then
  --#notice I removed the 'do' command.  do is only used in loops, or to change the scope (this relates to local variables)
  --#examples of 'do' would be:
  --#for i = 1, 10 do ... end  --loops 10 times
  --#while true do ... end     --loops infinite times
  local count = turtle.getItemCount( 1 )
  --#I only call turtle.getItemCount once, and store the result in a variable
  if count >= 10 then
    --#which I then use the greater than or equal to operator on, to determine if enough funds are available
    print( "Funds Sufficient" )
    turtle.transferTo( 2, count - 10 )
    --#Notice I didn't declare a separate variable (x) for count - 10.  You can pass values to functions this way
    --#the downside to doing so, is you cannot access that same value in a different part of your code
    --#However, that wasn't necessary here.  Also, x = x+0 is totally redundant, as anything plus 0 equals itself.
    turtle.dropDown( 10 )
    turtle.select( 2 )
    turtle.dropUp()
    turtle.select( 1 )
  else
    print( "Insufficient Funds" )
  end
end

I have left out the redstone part, as you are totally wrong. You'll want to use these commands:

rs.getBundledInput
rs.getBundledOutput
rs.setBundledOutput

For example, let's say I wanted to turn on the 'white' color in front:

rs.setBundledOutput( "front", colors.white )

Now, let's say I want to turn it off:


rs.setBundledOutput( "front", 0 )

Note: The above methods will override all current outputs of the computer to that side. For example, if I turned on red, then white using the method shown, only white would remain on. To avoid doing this, incorporate rs.getBundledOutput and colors.subtract/colors.combine.
how2doit #3
Posted 07 October 2015 - 10:35 PM
I know i switched it from the bundled to the annolog because i couldn't get the bundled ones to work correctly

Thank you though this was very helpful, but is there some way of preventing someone from steeling during the delay to drop the items into the chest?
how2doit #4
Posted 09 October 2015 - 02:05 AM
So far this is what I have for my program the only thing I would like to add to it is to have all of this run from another computer and then having this one actually do all the commands if someone could help me do this it would be much appreciated.

Spoiler
write( "What's your order?" )
local input = read()

if input == "Hearty_Breakfast" then
loops, or to change the scope (this relates to local variables)
local count = turtle.getItemCount( 1 )
if count >= 16 then
print( "Funds Sufficient" )
turtle.transferTo( 2, count - 16 )
turtle.dropDown( 16 )
turtle.select( 2 )
turtle.dropUp()
turtle.select( 1 )
rs.setBundledOutput( "front", colors.white )
sleep(3)
rs.setBundledOutput( "front", 0 )
else
print( "Insufficient Funds" )
end

else
if input == "Apple_Pie" then
local count = turtle.getItemCount( 1 )
if count >= 10 then
print( "Funds Sufficient" )
turtle.transferTo( 2, count - 10)
turtle.dropDown( 10 )
turtle.select( 2 )
turtle.dropUp()
turtle.select( 1 )
rs.setBundledOutput( "front", colors.red )
sleep(3)
rs.setBundledOutput( "front", 0 )
else
print( "Insufficient Funds" )
end

else
if input == "Pancakes" then
local count = turtle.getItemCount( 1 )
if count >= 9 then
print( "Funds Sufficient" )
turtle.transferTo( 2, count - 9)
turtle.dropDown( 9 )
turtle.select( 2 )
turtle.dropUp()
turtle.select( 1 )
rs.setBundledOutput( "front", colors.orange )
sleep(3)
rs.setBundledOutput( "front", 0 )
else
print( "Insufficient Funds" )
end


else
if input == "Citrus_Salad" then
local count = turtle.getItemCount( 1 )
if count >= 7 then
print( "Funds Sufficient" )
turtle.transferTo( 2, count - 7)
turtle.dropDown( 7 )
turtle.select( 2 )
turtle.dropUp()
turtle.select( 1 )
rs.setBundledOutput( "front", colors.magenta )
sleep(3)
rs.setBundledOutput( "front", 0 )
else
print( "Insufficient Funds" )
end


else
if input == "Chocolate_Bacon" then
local count = turtle.getItemCount( 1 )
if count >= 7 then
print( "Funds Sufficient" )
turtle.transferTo( 2, count -7 )
turtle.dropDown( 7 )
turtle.select( 2 )
turtle.dropUp()
turtle.select( 1 )
rs.setBundledOutput( "front", colors.lightblue )
sleep(3)
rs.setBundledOutput( "front", 0 )
else
print( "Insufficient Funds" )
end


else
if input == "Maple_Candied_Bacon" then
local count = turtle.getItemCount( 1 )
if count >= 7 then
print( "Funds Sufficient" )
turtle.transferTo( 2, count - 7)
turtle.dropDown( 7 )
turtle.select( 2 )
turtle.dropUp()
turtle.select( 1 )
rs.setBundledOutput( "front", colors.yellow )
sleep(3)
rs.setBundledOutput( "front", 0 )
else
print( "Insufficient Funds" )
end


else
if input == "Sausage_in_Bread" then
local count = turtle.getItemCount( 1 )
if count >= 6 then
print( "Funds Sufficient" )
turtle.transferTo( 2, count - 6)
turtle.dropDown( 6 )
turtle.select( 2 )
turtle.dropUp()
turtle.select( 1 )
rs.setBundledOutput( "front", colors.lime )
sleep(3)
rs.setBundledOutput( "front", 0 )
else
print( "Insufficient Funds" )
end


else
if input == "Maple_Syrup_Waffles" then
local count = turtle.getItemCount( 1 )
if count >= 6 then
print( "Funds Sufficient" )
turtle.transferTo( 2, count - 6)
turtle.dropDown( 6 )
turtle.select( 2 )
turtle.dropUp()
turtle.select( 1 )
rs.setBundledOutput( "front", colors.pink )
sleep(3)
rs.setBundledOutput( "front", 0 )
else
print( "Insufficient Funds" )
end


else
if input == "McPam" then
local count = turtle.getItemCount( 1 )
if count >= 5 then
print( "Funds Sufficient" )
turtle.transferTo( 2, count - 5)
turtle.dropDown( 5 )
turtle.select( 2 )
turtle.dropUp()
turtle.select( 1 )
rs.setBundledOutput( "front", colors.Gray )
sleep(3)
rs.setBundledOutput( "front", 0 )
else
print( "Insufficient Funds" )
end


else
if input == "Cherry_Yogurt" then
local count = turtle.getItemCount( 1 )
if count >= 5 then
print( "Funds Sufficient" )
turtle.transferTo( 2, count - 5)
turtle.dropDown( 5 )
turtle.select( 2 )
turtle.dropUp()
turtle.select( 1 )
rs.setBundledOutput( "front", colors.lightGray )
sleep(3)
rs.setBundledOutput( "front", 0 )
else
print( "Insufficient Funds" )
end


else
if input == "Strawberry_Yogurt" then
local count = turtle.getItemCount( 1 )
if count >= 5 then
print( "Funds Sufficient" )
turtle.transferTo( 2, count - 5)
turtle.dropDown( 5 )
turtle.select( 2 )
turtle.dropUp()
turtle.select( 1 )
rs.setBundledOutput( "front", colors.cyan )
sleep(3)
rs.setBundledOutput( "front", 0 )
else
print( "Insufficient Funds" )
end


else
if input == "Soft_Pretzel" then
local count = turtle.getItemCount( 1 )
if count >= 4 then
print( "Funds Sufficient" )
turtle.transferTo( 2, count - 4)
turtle.dropDown( 4 )
turtle.select( 2 )
turtle.dropUp()
turtle.select( 1 )
rs.setBundledOutput( "front", colors.purple )
sleep(3)
rs.setBundledOutput( "front", 0 )
else
print( "Insufficient Funds" )
end


else
if input == "Donut" then
local count = turtle.getItemCount( 1 )
if count >= 3 then
print( "Funds Sufficient" )
turtle.transferTo( 2, count - 3)
turtle.dropDown( 3 )
turtle.select( 2 )
turtle.dropUp()
turtle.select( 1 )
rs.setBundledOutput( "front", colors.blue )
sleep(3)
rs.setBundledOutput( "front", 0 )
else
print( "Insufficient Funds" )
end


else
if input == "Orange_Juice" then
local count = turtle.getItemCount( 1 )
if count >= 3 then
print( "Funds Sufficient" )
turtle.transferTo( 2, count - 3)
turtle.dropDown( 3 )
turtle.select( 2 )
turtle.dropUp()
turtle.select( 1 )
rs.setBundledOutput( "front", colors.brown )
sleep(3)
rs.setBundledOutput( "front", 0 )
else
print( "Insufficient Funds" )
end
else
if input == "Milk" then
local count = turtle.getItemCount( 1 )
if count >= 2 then
print( "Funds Sufficient" )
turtle.transferTo( 2, count - 2)
turtle.dropDown( 2 )
turtle.select( 2 )
turtle.dropUp()
turtle.select( 1 )
rs.setBundledOutput( "front", colors.green )
sleep(3)
rs.setBundledOutput( "front", 0 )
else
print( "Insufficient Funds" )
end


else
if input == "Lemonade" then
local count = turtle.getItemCount( 1 )
if count >= 1 then
print( "Funds Sufficient" )
turtle.transferTo( 2, count - 1)
turtle.dropDown( 1 )
turtle.select( 2 )
turtle.dropUp()
turtle.select( 1 )
rs.setBundledOutput( "front", colors.black )
sleep(3)
rs.setBundledOutput( "front", 0 )
else
print( "Insufficient Funds" )
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
Edited by
how2doit #5
Posted 09 October 2015 - 02:23 AM
ignore the <div> s no idea what that's about but i forgot to mention, Many thanks to KingofGamesYami i basically used the program he wrote as a revision to mine.

It's more messed up than i thought the format didn't go quite right but i assure you the program works the weird characters in strange spots aren't normally there.
Bomb Bloke #6
Posted 09 October 2015 - 03:47 AM
They sometimes pop in when switching between the rich/standard text editor. If you edit your prior post and mash the toggle enough times (the light switch icon up the top left of the posting box), the forum software will typically get rid of them again… eventually.
how2doit #7
Posted 09 October 2015 - 09:47 PM
Okay, just a recap i would like to enable another computer to tell the first one the read() value but no more is that possible?
program:

Spoiler
write( "What's your order?" )
local input = read()

if input == "Hearty_Breakfast" then
  loops, or to change the scope (this relates to local variables)
	local count = turtle.getItemCount( 1 )
  if count >= 16 then
		print( "Funds Sufficient" )
	turtle.transferTo( 2, count - 16 )
	 turtle.dropDown( 16 )
	turtle.select( 2 )
	turtle.dropUp()
	turtle.select( 1 )
rs.setBundledOutput( "front", colors.white )
sleep(3)
rs.setBundledOutput( "front", 0 )
  else
	print( "Insufficient Funds" )
  end

else
if input == "Apple_Pie" then
  local count = turtle.getItemCount( 1 )
  if count >= 10 then
		print( "Funds Sufficient" )
	turtle.transferTo( 2, count - 10)
turtle.dropDown( 10 )
	turtle.select( 2 )
	turtle.dropUp()
	turtle.select( 1 )
rs.setBundledOutput( "front", colors.red )
sleep(3)
rs.setBundledOutput( "front", 0 )
  else
	print( "Insufficient Funds" )
  end

else
if input == "Pancakes" then
  local count = turtle.getItemCount( 1 )
  if count >= 9 then
		print( "Funds Sufficient" )
	turtle.transferTo( 2, count - 9)
turtle.dropDown( 9 )
	turtle.select( 2 )
	turtle.dropUp()
	turtle.select( 1 )
rs.setBundledOutput( "front", colors.orange )
sleep(3)
rs.setBundledOutput( "front", 0 )
  else
	print( "Insufficient Funds" )
  end


else
if input == "Citrus_Salad" then
  local count = turtle.getItemCount( 1 )
  if count >= 7 then
		print( "Funds Sufficient" )
	turtle.transferTo( 2, count - 7)
turtle.dropDown( 7 )
	turtle.select( 2 )
	turtle.dropUp()
	turtle.select( 1 )
rs.setBundledOutput( "front", colors.magenta )
sleep(3)
rs.setBundledOutput( "front", 0 )
  else
	print( "Insufficient Funds" )
  end


else
if input == "Chocolate_Bacon" then
  local count = turtle.getItemCount( 1 )
  if count >= 7 then
		print( "Funds Sufficient" )
	turtle.transferTo( 2, count -7 )
turtle.dropDown( 7 )
	turtle.select( 2 )
	turtle.dropUp()
	turtle.select( 1 )
rs.setBundledOutput( "front", colors.lightblue )
sleep(3)
rs.setBundledOutput( "front", 0 )
  else
	print( "Insufficient Funds" )
  end


else
if input == "Maple_Candied_Bacon" then
  local count = turtle.getItemCount( 1 )
  if count >= 7 then
		print( "Funds Sufficient" )
	turtle.transferTo( 2, count - 7)
turtle.dropDown( 7 )
	turtle.select( 2 )
	turtle.dropUp()
	turtle.select( 1 )
rs.setBundledOutput( "front", colors.yellow )
sleep(3)
rs.setBundledOutput( "front", 0 )
  else
	print( "Insufficient Funds" )
  end


else
if input == "Sausage_in_Bread" then
  local count = turtle.getItemCount( 1 )
  if count >= 6 then
		print( "Funds Sufficient" )
	turtle.transferTo( 2, count - 6)
turtle.dropDown( 6 )
	turtle.select( 2 )
	turtle.dropUp()
	turtle.select( 1 )
rs.setBundledOutput( "front", colors.lime )
sleep(3)
rs.setBundledOutput( "front", 0 )
  else
	print( "Insufficient Funds" )
  end


else
if input == "Maple_Syrup_Waffles" then
  local count = turtle.getItemCount( 1 )
  if count >= 6 then
		print( "Funds Sufficient" )
	turtle.transferTo( 2, count - 6)
turtle.dropDown( 6 )
	turtle.select( 2 )
	turtle.dropUp()
	turtle.select( 1 )
rs.setBundledOutput( "front", colors.pink )
sleep(3)
rs.setBundledOutput( "front", 0 )
  else
	print( "Insufficient Funds" )
  end


else
if input == "McPam" then
  local count = turtle.getItemCount( 1 )
  if count >= 5 then
		print( "Funds Sufficient" )
	turtle.transferTo( 2, count - 5)
turtle.dropDown( 5 )
	turtle.select( 2 )
	turtle.dropUp()
	turtle.select( 1 )
rs.setBundledOutput( "front", colors.Gray )
sleep(3)
rs.setBundledOutput( "front", 0 )
  else
	print( "Insufficient Funds" )
  end


else
if input == "Cherry_Yogurt" then
  local count = turtle.getItemCount( 1 )
  if count >= 5 then
		print( "Funds Sufficient" )
	turtle.transferTo( 2, count - 5)
turtle.dropDown( 5 )
	turtle.select( 2 )
	turtle.dropUp()
	turtle.select( 1 )
rs.setBundledOutput( "front", colors.lightGray )
sleep(3)
rs.setBundledOutput( "front", 0 )
  else
	print( "Insufficient Funds" )
  end


else
if input == "Strawberry_Yogurt" then
  local count = turtle.getItemCount( 1 )
  if count >= 5 then
		print( "Funds Sufficient" )
	turtle.transferTo( 2, count - 5)
turtle.dropDown( 5 )
	turtle.select( 2 )
	turtle.dropUp()
	turtle.select( 1 )
rs.setBundledOutput( "front", colors.cyan )
sleep(3)
rs.setBundledOutput( "front", 0 )
  else
	print( "Insufficient Funds" )
  end


else
if input == "Soft_Pretzel" then
  local count = turtle.getItemCount( 1 )
  if count >= 4 then
		print( "Funds Sufficient" )
	turtle.transferTo( 2, count - 4)
turtle.dropDown( 4 )
	turtle.select( 2 )
	turtle.dropUp()
	turtle.select( 1 )
rs.setBundledOutput( "front", colors.purple )
sleep(3)
rs.setBundledOutput( "front", 0 )
  else
	print( "Insufficient Funds" )
  end


else
if input == "Donut" then
  local count = turtle.getItemCount( 1 )
  if count >= 3 then
		print( "Funds Sufficient" )
	turtle.transferTo( 2, count - 3)
turtle.dropDown( 3 )
	turtle.select( 2 )
	turtle.dropUp()
	turtle.select( 1 )
rs.setBundledOutput( "front", colors.blue )
sleep(3)
rs.setBundledOutput( "front", 0 )
  else
	print( "Insufficient Funds" )
  end


else
if input == "Orange_Juice" then
  local count = turtle.getItemCount( 1 )
  if count >= 3 then
		print( "Funds Sufficient" )
	turtle.transferTo( 2, count - 3)
turtle.dropDown( 3 )
	turtle.select( 2 )
	turtle.dropUp()
	turtle.select( 1 )
rs.setBundledOutput( "front", colors.brown )
sleep(3)
rs.setBundledOutput( "front", 0 )
  else
	print( "Insufficient Funds" )
  end
else
if input == "Milk" then
  local count = turtle.getItemCount( 1 )
  if count >= 2 then
		print( "Funds Sufficient" )
	turtle.transferTo( 2, count - 2)
turtle.dropDown( 2 )
	turtle.select( 2 )
	turtle.dropUp()
	turtle.select( 1 )
rs.setBundledOutput( "front", colors.green )
sleep(3)
rs.setBundledOutput( "front", 0 )
  else
	print( "Insufficient Funds" )
  end


else
if input == "Lemonade" then
  local count = turtle.getItemCount( 1 )
  if count >= 1 then
		print( "Funds Sufficient" )
	turtle.transferTo( 2, count - 1)
turtle.dropDown( 1 )
	turtle.select( 2 )
	turtle.dropUp()
	turtle.select( 1 )
rs.setBundledOutput( "front", colors.black )
sleep(3)
rs.setBundledOutput( "front", 0 )
  else
	print( "Insufficient Funds" )
  end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
Edited by
HPWebcamAble #8
Posted 10 October 2015 - 03:50 PM
You can send strings (and tables and numbers) through Rednet.

Place a wireless modem on each computer, and take a look at the Rednet API:
http://www.computercraft.info/wiki/Rednet_(API)


Also, with code that long, you'd be better putting it on www.pastebin.com and posting a link to it.
how2doit #9
Posted 10 October 2015 - 07:19 PM
Okay, will do and thanks!
how2doit #10
Posted 11 October 2015 - 10:42 PM
So i have tried to make my program work with rednet but it's not working properly i can't figure out why can someone help?
program:

Spoiler
rednet.open("left")
while true do
os.pullEvent()
local y
y = os.pullEvent()

write( "What's your order?" )
local input = read()
y = input

if input == "Hearty_Breakfast" then
  --loops, or to change the scope (this relates to local variables)
    local count = turtle.getItemCount( 1 )
  if count >= 16 then
        print( "Funds Sufficient" )
    turtle.transferTo( 2, count - 16 )
     turtle.dropDown( 16 )
    turtle.select( 2 )
    turtle.dropUp()
    turtle.select( 1 )
rs.setBundledOutput( "front", colors.white )
sleep(3)
rs.setBundledOutput( "front", 0 )
  else
    print( "Insufficient Funds" )
  end

else
if input == "Apple_Pie" then
  local count = turtle.getItemCount( 1 )
  if count >= 10 then
        print( "Funds Sufficient" )
    turtle.transferTo( 2, count - 10)
turtle.dropDown( 10 )
    turtle.select( 2 )
    turtle.dropUp()
    turtle.select( 1 )
rs.setBundledOutput( "front", colors.red )
sleep(3)
rs.setBundledOutput( "front", 0 )
  else
    print( "Insufficient Funds" )
  end

else
if input == "Pancakes" then
  local count = turtle.getItemCount( 1 )
  if count >= 9 then
        print( "Funds Sufficient" )
    turtle.transferTo( 2, count - 9)
turtle.dropDown( 9 )
    turtle.select( 2 )
    turtle.dropUp()
    turtle.select( 1 )
rs.setBundledOutput( "front", colors.orange )
sleep(3)
rs.setBundledOutput( "front", 0 )
  else
    print( "Insufficient Funds" )
  end


else
if input == "Citrus_Salad" then
  local count = turtle.getItemCount( 1 )
  if count >= 7 then
        print( "Funds Sufficient" )
    turtle.transferTo( 2, count - 7)
turtle.dropDown( 7 )
    turtle.select( 2 )
    turtle.dropUp()
    turtle.select( 1 )
rs.setBundledOutput( "front", colors.magenta )
sleep(3)
rs.setBundledOutput( "front", 0 )
  else
    print( "Insufficient Funds" )
  end


else
if input == "Chocolate_Bacon" then
  local count = turtle.getItemCount( 1 )
  if count >= 7 then
        print( "Funds Sufficient" )
    turtle.transferTo( 2, count -7 )
turtle.dropDown( 7 )
    turtle.select( 2 )
    turtle.dropUp()
    turtle.select( 1 )
rs.setBundledOutput( "front", colors.lightblue )
sleep(3)
rs.setBundledOutput( "front", 0 )
  else
    print( "Insufficient Funds" )
  end


else
if input == "Maple_Candied_Bacon" then
  local count = turtle.getItemCount( 1 )
  if count >= 7 then
        print( "Funds Sufficient" )
    turtle.transferTo( 2, count - 7)
turtle.dropDown( 7 )
    turtle.select( 2 )
    turtle.dropUp()
    turtle.select( 1 )
rs.setBundledOutput( "front", colors.yellow )
sleep(3)
rs.setBundledOutput( "front", 0 )
  else
    print( "Insufficient Funds" )
  end


else
if input == "Sausage_in_Bread" then
  local count = turtle.getItemCount( 1 )
  if count >= 6 then
        print( "Funds Sufficient" )
    turtle.transferTo( 2, count - 6)
turtle.dropDown( 6 )
    turtle.select( 2 )
    turtle.dropUp()
    turtle.select( 1 )
rs.setBundledOutput( "front", colors.lime )
sleep(3)
rs.setBundledOutput( "front", 0 )
  else
    print( "Insufficient Funds" )
  end


else
if input == "Maple_Syrup_Waffles" then
  local count = turtle.getItemCount( 1 )
  if count >= 6 then
        print( "Funds Sufficient" )
    turtle.transferTo( 2, count - 6)
turtle.dropDown( 6 )
    turtle.select( 2 )
    turtle.dropUp()
    turtle.select( 1 )
rs.setBundledOutput( "front", colors.pink )
sleep(3)
rs.setBundledOutput( "front", 0 )
  else
    print( "Insufficient Funds" )
  end


else
if input == "McPam" then
  local count = turtle.getItemCount( 1 )
  if count >= 5 then
        print( "Funds Sufficient" )
    turtle.transferTo( 2, count - 5)
turtle.dropDown( 5 )
    turtle.select( 2 )
    turtle.dropUp()
    turtle.select( 1 )
rs.setBundledOutput( "front", colors.Gray )
sleep(3)
rs.setBundledOutput( "front", 0 )
  else
    print( "Insufficient Funds" )
  end


else
if input == "Cherry_Yogurt" then
  local count = turtle.getItemCount( 1 )
  if count >= 5 then
        print( "Funds Sufficient" )
    turtle.transferTo( 2, count - 5)
turtle.dropDown( 5 )
    turtle.select( 2 )
    turtle.dropUp()
    turtle.select( 1 )
rs.setBundledOutput( "front", colors.lightGray )
sleep(3)
rs.setBundledOutput( "front", 0 )
  else
    print( "Insufficient Funds" )
  end


else
if input == "Strawberry_Yogurt" then
  local count = turtle.getItemCount( 1 )
  if count >= 5 then
        print( "Funds Sufficient" )
    turtle.transferTo( 2, count - 5)
turtle.dropDown( 5 )
    turtle.select( 2 )
    turtle.dropUp()
    turtle.select( 1 )
rs.setBundledOutput( "front", colors.cyan )
sleep(3)
rs.setBundledOutput( "front", 0 )
  else
    print( "Insufficient Funds" )
  end


else
if input == "Soft_Pretzel" then
  local count = turtle.getItemCount( 1 )
  if count >= 4 then
        print( "Funds Sufficient" )
    turtle.transferTo( 2, count - 4)
turtle.dropDown( 4 )
    turtle.select( 2 )
    turtle.dropUp()
    turtle.select( 1 )
rs.setBundledOutput( "front", colors.purple )
sleep(3)
rs.setBundledOutput( "front", 0 )
  else
    print( "Insufficient Funds" )
  end


else
if input == "Donut" then
  local count = turtle.getItemCount( 1 )
  if count >= 3 then
        print( "Funds Sufficient" )
    turtle.transferTo( 2, count - 3)
turtle.dropDown( 3 )
    turtle.select( 2 )
    turtle.dropUp()
    turtle.select( 1 )
rs.setBundledOutput( "front", colors.blue )
sleep(3)
rs.setBundledOutput( "front", 0 )
  else
    print( "Insufficient Funds" )
  end


else
if input == "Orange_Juice" then
  local count = turtle.getItemCount( 1 )
  if count >= 3 then
        print( "Funds Sufficient" )
    turtle.transferTo( 2, count - 3)
turtle.dropDown( 3 )
    turtle.select( 2 )
    turtle.dropUp()
    turtle.select( 1 )
rs.setBundledOutput( "front", colors.brown )
sleep(3)
rs.setBundledOutput( "front", 0 )
  else
    print( "Insufficient Funds" )
  end
else
if input == "Milk" then
  local count = turtle.getItemCount( 1 )
  if count >= 2 then
        print( "Funds Sufficient" )
    turtle.transferTo( 2, count - 2)
turtle.dropDown( 2 )
    turtle.select( 2 )
    turtle.dropUp()
    turtle.select( 1 )
rs.setBundledOutput( "front", colors.green )
sleep(3)
rs.setBundledOutput( "front", 0 )
  else
    print( "Insufficient Funds" )
  end


else
if input == "Lemonade" then
  local count = turtle.getItemCount( 1 )
  if count >= 1 then
        print( "Funds Sufficient" )
    turtle.transferTo( 2, count - 1)
turtle.dropDown( 1 )
    turtle.select( 2 )
    turtle.dropUp()
    turtle.select( 1 )
rs.setBundledOutput( "front", colors.black )
sleep(3)
rs.setBundledOutput( "front", 0 )
  else
    print( "Insufficient Funds" )
  end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end

end
Edited on 11 October 2015 - 08:49 PM
TYKUHN2 #11
Posted 11 October 2015 - 10:48 PM
[spoiler.][/spoiler.] and [code.][/code.]
Ignore . as they are used to prevent formatting
HPWebcamAble #12
Posted 13 October 2015 - 12:33 AM
Several things here:
  1. This code is really long. Too long to just stick on the forums. In the future, please post it on pastebin.com and leave a link here
  2. I have done this for you, and fixed the formatting (Spacing, turned a bunch of 'else if' into 'elseif', which allowed me to remove a bunch of 'end's). Link: http://pastebin.com/WsC6syrE
  3. 'elseif' is one word, and is different then 'else if'
  4. Your indenting was really weird, though I'd believe you if you blamed the forum software
  5. You say you tried to use rednet, yet the only thing you ever do is call 'rednet.open("left")'. This won't magically make it use rednet. You have to add 'rednet.send' or 'rednet.broadcast'
  6. I don't have time to explain too much, hopefully someone else can

TLDR: I put your code on pastebin ( http://pastebin.com/WsC6syrE ) and fixed formating, hopefully someone else can explain more
Edited on 12 October 2015 - 10:33 PM
how2doit #13
Posted 13 October 2015 - 12:59 AM
Ok i will do that, also i have another computer that has the sending thing it will send a string which i tried to get the other computer to input as the read() value.

I send the information through a computer with this:
rednet.open("back")
local x
x = read()
write("Order?")
read()
rednet.send(15, x)
I want this code http://pastebin.com/WsC6syrE to take the string I send and use it as the read() value.
HPWebcamAble #14
Posted 13 October 2015 - 03:37 AM
I send the information through a computer with this:
rednet.open("back")
local x
x = read()
write("Order?")
read()
rednet.send(15, x)
I want this code http://pastebin.com/WsC6syrE to take the string I send and use it as the read() value.

Lets look at that code for a second:

local x
x = read()
write("Order?")
read()
rednet.send(15, x)

This will kind of do what you want, but it will try to get the user input twice. Because you call 'read()' twice there.

You probably want something like this:

write("Order?") --# Tell the user what you want them to enter

local x = read() --# You can make a variable and set a value at the same time

rednet.send(15,x) --# Send the input to computer 15
Obviously this only executes once. Stick it inside a 'while true do' loop to fix that.
Note that the loop would declare 'local x' every time it ran, so you'd probably want to do 'local x' before the loop, then just 'x = read()'


Regarding the code on the pastebin:
Remove the 'os.pullEvent()' lines (5-7).
They don't do anything.

Replace 'input = read()' with this:
(And remove 'y = input')

local id , input = rednet.receive()
That will simply wait for a rednet message
how2doit #15
Posted 13 October 2015 - 09:49 PM
Sweet thanks , I really don't know what i'm doing with rednet I just started using it a few days ago so I know nothing about it.