-
Notifications
You must be signed in to change notification settings - Fork 0
Simple Shops Peripheral
With this peripheral, any computer can get information from the Simple Shop such as stock, cost, gains, even who owns it!
getStockItem() -> table
This method grabs whatever ItemStack is for sale in a Simple Shop, returned as a table with its name, count, and nbt hash
local shop = peripheral.find("shop")
local stock = shop.getStockItem()
print("Item for Sale")
print(stock.name .. " at " .. stock.count .. " per purchase!")
getStockAmount() -> number
This method grabs the amount of stock within a Simple Shop
local shop = peripheral.find("shop")
local stock = shop.getStockAmount()
if (stock == 0) then
print("Out of Stock")
end
getCostItem() -> table
This method grabs whatever ItemStack is put as the price in the Simple Shop, returned as a table with its name, count, and nbt hash
local shop = peripheral.find("shop")
local cost = shop.getCostItem()
print("Price: " .. cost.count .. "x " .. cost.name)
getGainsAmount() -> number
This method grabs the amount of money within a Simple Shop
local shop = peripheral.find("shop")
local gains = shop.getGainsAmount()
if (gains > 0) then
print("You have money to collect!")
end
getBarItem() -> table
This method grabs whatever StockBarItem is being used to display stock amount, returned as a table with its name, count, and nbt hash
local shop = peripheral.find("shop")
local bar = shop.getBarItem()
if not(bar.name == "minecraft:air") then
print("Im using the " .. bar.name .. " item to display stock!")
end
getOwner() -> string, string | table
This method grabs the owner and outputs their display name and UUID as strings
local shop = peripheral.find("shop")
local owner, uuid = shop.getOwner()
print("Shop Owner: " .. owner)
print("Owner UUID: " .. uuid)
With this peripheral, command computers can not only get information from shops but also set new information! All Simple Shop Peripheral methods are available.
setStockItem(table)
This method sets a new stock ItemStack based upon name and amount!
local shop = peripheral.find("shop")
local newItem = {
["name"] = "minecraft:bedrock",
["count"] = 64
}
shop.setStockItem(newItem)
setStockAmount(number)
This method sets the stock amount!
local shop = peripheral.find("shop")
shop.setStockAmount(0)
setCostItem(table)
This method sets a new price ItemStack based upon name and amount!
local shop = peripheral.find("shop")
local newPrice = {
["name"] = "minecraft:diamond_block",
["count"] = 64
}
shop.setCostItem(newItem)
setGainsAmount(table)
This method sets the amount of gains within a Shop!
local shop = peripheral.find("shop")
shop.setGainsAmount(200)
setBarItem(table)
This method sets a new Bar if it is a StockBarItem!
local shop = peripheral.find("shop")
local newBar = {
["name"] = "simpleshops:quartz_stockbar"
}
shop.setBarItem(newBar)
setOwner(string)
This method sets a new owner if the string is a valid UUID!
local shop = peripheral.find("shop")
-- This is my literal UUID!
local techtasticUuid = "4437fbab-c16c-46b8-afe2-0bf7d4d3fb7e"
shop.setOwner(techtasticUuid)