Lightman's Currency x CC:Tweaked Compat
This modification provides seamless integration of the Lightman's Currency module with the CC:Tweaked computer system through Lua programming language. To get started, simply place a computer near Lightman's Currency trade blocks and connect them as peripheral devices.
Main Functions
When connecting a trade terminal to a computer, the following Lua functions become available:
getName(trader)- returns the custom name of the tradergetOwnerName(trader)- shows the name of the trade point ownergetTrades()- provides a complete list of available deals with detailed information:items- list of goods indicating item type and quantitytransactionType- operation type (sale, purchase, or exchange)price- cost in currency for buy/sell transactionsitemsCost- required items for exchange operations
Example Program Code
local p = peripheral.wrap("back") -- specify the peripheral connection side
local traders = p.getTrades()
for , trader in ipairs(traders) do
print("Trader:", trader.name, "(ID:", trader.id .. ")")
if #trader.trades == 0 then
print(" No available deals.")
else
for i, trade in ipairs(trader.trades) do
print(" Deal " .. i .. ":")
print(" Type:", trade.transactionType)
if trade.price then
print(" Price:", trade.price)
end
if trade.items then
print(" Goods:")
for , item in ipairs(trade.items) do
print(" -", item.count, item.item)
end
end
if trade.itemsCost then
print(" Exchange Cost:")
for _, item in ipairs(trade.itemsCost) do
print(" -", item.count, item.item)
end
end
end
end
print()
end