Posted 28 February 2014 - 05:29 AM
Hello all, I am new to the computercraft forums but have recently started to learn how to write programs.
I also have no idea where to post this but I figured I could do the least damage posing it here.
so I'm trying to write a program that uses the Trading Post from the mod Extra Utilties by RWtema to do automatic trading or selected trading.
I only started coding 3 days ago so I know this is very poorly done and probably very bad coding but at least the idea is there.
anyway here is the code, I was hoping for ideas or tips, or if someone wanted to take over the whole idea themselves.
(edit)
(because I'm new I have to wait for a mod to allow replies/posts)
@Bomb Bloke that was incredibly helpful thank you very much.
Also Is it Possible to stop a for loop with a key press?
(/edit)
at the moment using the "trades" command I can see the villager ids and Number of trades, and even perform a trade.
In this setup I have a trading post direct to the "right" and a storage block connected using wired network cables to house the trading materials, so as long as you have the required materials to do the trade in the storage block, "performTrade" should work.
I also have no idea where to post this but I figured I could do the least damage posing it here.
so I'm trying to write a program that uses the Trading Post from the mod Extra Utilties by RWtema to do automatic trading or selected trading.
I only started coding 3 days ago so I know this is very poorly done and probably very bad coding but at least the idea is there.
anyway here is the code, I was hoping for ideas or tips, or if someone wanted to take over the whole idea themselves.
(edit)
(because I'm new I have to wait for a mod to allow replies/posts)
@Bomb Bloke that was incredibly helpful thank you very much.
Also Is it Possible to stop a for loop with a key press?
(/edit)
term.clear()
term.setCursorPos(1,1)
trade = peripheral.wrap("right")
print("commands")
print('trades = Villager Trades")
print("q = quit")
while true do
input = read()
ids = trade.getVillagerIds()
idt = trade.getNearestVillagerId()
if input == "ids" then
term.clear()
term.setCursorPos(1,1)
print(textutils.serialize(ids))
elseif input == "q" then
break
elseif input == "trades" then
term.clear()
term.setCursorPos(1,1)
for key,value in pairs(ids) do
tnum = trade.getNumTrades(value)
tprints = print(textutils.serialize(value..":".."ID".." "..tnum..":".."#Trades"))
end
print("Select Villager Id")
input = read()
var1 = input
print("Select Villager Trade Number 0,1,2,etc.")
input2 = read()
var2 = Iinput2
ts = trade.getItemSold(var1, var2
tb = trade.getItemBought(var1,var2)
tsb = trade.getSecondItemBought(var1,var2)
print(textutils.serialize(ts))
print(textutils.serialize(tb))
print(textutils.serialize(tsb))
print("do you wish to ferform the trade? yes/no")
input3 = read()
if input3 == "yes" then
trade.performTrade(var1,var2)
end
print("Enter new Command or Press Enter to see Commands")
else
term.clear()
term.setCursorPos(1,1)
print("Commands")
print("trades = see Trades")
print("ids = Villager Ids")
print("q = quit")
end
end
term.clear()
term.setCursorPos(1,1)
at the moment using the "trades" command I can see the villager ids and Number of trades, and even perform a trade.
In this setup I have a trading post direct to the "right" and a storage block connected using wired network cables to house the trading materials, so as long as you have the required materials to do the trade in the storage block, "performTrade" should work.
Edited on 28 February 2014 - 04:20 PM