Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement