This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Wojbie's profile picture

Shoppe - Command Computer powered XP shop!

Started by Wojbie, 01 March 2015 - 10:25 AM
Wojbie #1
Posted 01 March 2015 - 11:25 AM
Shoppe - Command Computer powered XP shop!

Shoppe is a simple to use experience shop i made for a friend on the server. Decided to relase it here too.
90% of code uses Lyqyd touchpoint-api. Rest is simple Command Block Magic. Requires 3 high 5 wide advanced monitor screen placed on top of the Command Computer. This program will not work on normal computer.

Download Here: http://pastebin.com/cRTsaYaK
Or ingame using command:
pastebin get cRTsaYaK shoppe 

To add new material to shot simply copy one of table.insert lines and give it name, xp cost and name of item to give followed my amount [ optionally followed by metavalue like in caseof tin gear. ]

Screenshots:

Edited on 02 April 2015 - 06:09 AM
DannySMc #2
Posted 07 April 2015 - 09:43 AM
I like this XD Could be a lot prettier but the idea is wicked, how do you get the colours in the chat bar?:o/> and it sounds like a french shop or a posh one :P/>
Wojbie #3
Posted 07 April 2015 - 10:52 AM
It uses /tellraw command. It was not made to be pretty it was made to sell items that were unobtainable normal way (about 20 of those) cause person who made that servers modpack was idiot.

You can use http://minecraftjson.com/ to help you make nice looking /tellraw commands.
kreezxil #4
Posted 04 January 2018 - 01:18 PM
Would like to point out that this script works in the 1.12.2 ports of ComputerCraft as is, therefore it likely works as on the ones in between too. I'll be making a modified version of this that uses Ender Pay and I'll post the script here when I'm done.

Here is a modified version that Sells levels for EnderPay credits.

https://pastebin.com/23ddYhRi


pastebin get 23ddYhRi epShop

If anyone should modify this please help keep computercraft scripting alive and share your modifications now matter how mundane. It's how we all learn.

The full code:
Spoiler

--# Kreezxil's EnderPay Shop
--# based on the following
--# pastebin: https://pastebin.com/23ddYhRi
--# Wojbie's Xp Shoppe
--# Uses touchpoint api
--# http://pastebin.com/cRTsaYaK
--# Uncomment next line to remove Op message spam
--commands.exec("gamerule commandBlockOutput false")
local Shop={}
--# table.insert(Shop,{["name"]="Stone Brick",["price"]=1,["item"]="minecraft:stonebrick 64"})
--# table.insert(Shop,{["name"]="Tin Gear",["price"]=5,["item"]="Railcraft:part.gear 1 3",}) --3 is damage value for basic tin gear
--# table.insert(Shop,{["name"]="1 Credit", ["price"]=1,["item"]="enderpay:filled_banknote 1 0 {DateIssued:365000L,Amount:1}",})
table.insert(Shop,{["name"]="1 Credit", ["price"]=1,["item"]="1",})
table.insert(Shop,{["name"]="10 Credit", ["price"]=10,["item"]="10",})
table.insert(Shop,{["name"]="100 Credit", ["price"]=100,["item"]="100",})
table.insert(Shop,{["name"]="1000 Credit", ["price"]=1000,["item"]="1000",})
table.insert(Shop,{["name"]="10000 Credit", ["price"]=10000,["item"]="10000",})
table.insert(Shop,{["name"]="100000 Credit", ["price"]=10000,["item"]="100000",})

--# Default shop zone to CommandComputer coords
local range = 5
--# Load touchpoint api
if not fs.exists("/touchpoint") then shell.run("pastebin get pFHeia96 /touchpoint") end
os.loadAPI("touchpoint")
--# Assuming that monitor is on top of commandComputer
local t = touchpoint.new("top")
--# Commands Backup
--# give @p[lm=10,x=-532,y=69,z=1084,r=3] Railcraft:part.gear 1 3
--# xp -10L @p[lm=10,x=-532,y=69,z=1084,r=3]
local jump=false
print("Adding "..#Shop.." Items to shop")
for i,k in pairs(Shop) do
local name = k.name.." = "..k.price.."L"
print(name)
t:add(name, function()
  commands.exec("tellraw @p[l="..(k.price-1)..",r="..range.."] "..'["",{"text":"You don\'t have lvl for '..k.name..'","color":"red"}]')
  commands.exec("playsound minecraft:entity.villager.no player @p[l="..(k.price-1)..",r="..range.."]")
  --wiadomosc masz xp
  commands.exec("tellraw @p[lm="..k.price..",r="..range.."] "..'["",{"text":"Sold '..k.name.." for "..k.price..' lvls","color":"green"}]')
  commands.exec("playsound minecraft:entity.villager.yes player @p[lm="..k.price..",r="..range.."]")
  --# commands.exec("give @p[lm="..k.price..",r="..range.."] "..k.item)
  commands.exec("wallet give @p[lm="..k.price..",r="..range.."] "..k.item)
  commands.exec("xp -"..k.price.."L @p[lm="..k.price..",r="..range.."]")
  t:flash(name)
end , 3+25*(jump and 1 or 0), 2+2*math.floor((i-1)/2), 23+24*(jump and 1 or 0),2+2*math.floor((i-1)/2), colors.red, colors.lime)
jump=not jump
end
t:run()
Edited on 04 January 2018 - 07:39 PM