Posted 29 August 2016 - 07:31 PM
This is my program that works by people going up to the turtle and putting in gold in my case you may change this to receive a certain amount of power in my case 1 gold nugget for 10,000 rf again easily changeable. My program should explain the rest through comments.
Note: I'm only a novice at this so it is not the tidiest program and can be improved in many ways i'm sure but I just thought i'd share this program as i'm pretty happy with it.
In order to use it as defaulted you will need to place a turtle in between two chest below and above it, have a bundled cable come out the back and that's really it for the set up hope you enjoy it.
Sorry i couldn't figure out how to get it uploaded to pastebin and find the pastebin code so for now this is
the code:
– Prompting for which color wire the signal will travel through –
write("Which Line?")
local z = read()
z = z+0
write("How much electricty would you like to buy?:")
local x = read()
x = x+0
local y = x
– the power math x being the number of ticks dived this by your power per tick, y is setting the base price Ei 1 unit of pay per how ever many units you divide it by
x = x/20480
x = x/20
y = y/10000
– The money taker in my case I choose it to use gold you may use what ever you want just replace the world gold with what ever you want it to be
print("Please insert ", y ," gold in slot one to continue")
write("Press enter to continue")
local data = turtle.getItemDetail()
print(data.name)
print(data.count)
– replaace minecraft:gold_block with what ever you want yours to be I three gold_block gold_ingot and gold_nuggets
if data.name == "minecraft:gold_block" then
–Multipled by 81 because a gold block is worth 81 of my money units which are based on gold nuggets
local m = data.count*81
turtle.dropDown(m/81, 1)
if m >= y then
print(m-y, " funds remaining")
local h = m-y
write("return remaining funds?, y, n?:")
local t = read()
if t == "y" then
– I got lazy and didn't want to find a way of making it return the exact number of stuff so I just went with the closet number of gold blocks You could find a way for it to return the perfect amount of stuff though
print ("will not be exactly, to the nearest 81 gold be more carful next time!")
turtle.suckUp(h/81)
print("Retrive from slot 2")
end
–Sets the output to z the output color, and then sleeps for x the time now in seconds that it must output a signal to allow power to flow through
rs.setBundledOutput("front", z)
sleep(x)
rs.setBundledOutput("front", 0)
end
elseif data.name == "minecraft:gold_ingot" then
local m = data.count*9
local h = m-y
turtle.dropDown(m/9, 1)
if m >= y then
print(m-y, " funds remaining")
write("return remaining funds?, y, n?:")
local t = read()
if t == "y" then
print ("will not be exactly, to the nearest 81 gold be more carful next time!")
turtle.suckUp(h/81)
print("Retrive from slot 2")
end
rs.setBundledOutput("front", z)
sleep(x)
rs.setBundledOutput("front", 0)
end
if data.name == "minecraft:gold_nugget" then
local m = data.count
local h = m-y
turtle.dropDown(m, 1)
if m >= y then
print(m-y, " funds remaining")
write("return remaining funds?, y, n?:")
local t = read()
if t == "y" then
print ("will not be exactly, to the nearest 81 gold be more carful next time!")
turtle.suckUp(h/81)
print("Retrive from slot 2")
end
rs.setBundledOutput("front", z)
sleep(x)
rs.setBundledOutput("front", 0)
end
end
end
Note: I'm only a novice at this so it is not the tidiest program and can be improved in many ways i'm sure but I just thought i'd share this program as i'm pretty happy with it.
In order to use it as defaulted you will need to place a turtle in between two chest below and above it, have a bundled cable come out the back and that's really it for the set up hope you enjoy it.
Sorry i couldn't figure out how to get it uploaded to pastebin and find the pastebin code so for now this is
the code:
Spoiler
–version 0.5–– Prompting for which color wire the signal will travel through –
write("Which Line?")
local z = read()
z = z+0
write("How much electricty would you like to buy?:")
local x = read()
x = x+0
local y = x
– the power math x being the number of ticks dived this by your power per tick, y is setting the base price Ei 1 unit of pay per how ever many units you divide it by
x = x/20480
x = x/20
y = y/10000
– The money taker in my case I choose it to use gold you may use what ever you want just replace the world gold with what ever you want it to be
print("Please insert ", y ," gold in slot one to continue")
write("Press enter to continue")
local data = turtle.getItemDetail()
print(data.name)
print(data.count)
– replaace minecraft:gold_block with what ever you want yours to be I three gold_block gold_ingot and gold_nuggets
if data.name == "minecraft:gold_block" then
–Multipled by 81 because a gold block is worth 81 of my money units which are based on gold nuggets
local m = data.count*81
turtle.dropDown(m/81, 1)
if m >= y then
print(m-y, " funds remaining")
local h = m-y
write("return remaining funds?, y, n?:")
local t = read()
if t == "y" then
– I got lazy and didn't want to find a way of making it return the exact number of stuff so I just went with the closet number of gold blocks You could find a way for it to return the perfect amount of stuff though
print ("will not be exactly, to the nearest 81 gold be more carful next time!")
turtle.suckUp(h/81)
print("Retrive from slot 2")
end
–Sets the output to z the output color, and then sleeps for x the time now in seconds that it must output a signal to allow power to flow through
rs.setBundledOutput("front", z)
sleep(x)
rs.setBundledOutput("front", 0)
end
elseif data.name == "minecraft:gold_ingot" then
local m = data.count*9
local h = m-y
turtle.dropDown(m/9, 1)
if m >= y then
print(m-y, " funds remaining")
write("return remaining funds?, y, n?:")
local t = read()
if t == "y" then
print ("will not be exactly, to the nearest 81 gold be more carful next time!")
turtle.suckUp(h/81)
print("Retrive from slot 2")
end
rs.setBundledOutput("front", z)
sleep(x)
rs.setBundledOutput("front", 0)
end
if data.name == "minecraft:gold_nugget" then
local m = data.count
local h = m-y
turtle.dropDown(m, 1)
if m >= y then
print(m-y, " funds remaining")
write("return remaining funds?, y, n?:")
local t = read()
if t == "y" then
print ("will not be exactly, to the nearest 81 gold be more carful next time!")
turtle.suckUp(h/81)
print("Retrive from slot 2")
end
rs.setBundledOutput("front", z)
sleep(x)
rs.setBundledOutput("front", 0)
end
end
end