Advertisement
kreezxil

ComputerCraft EnderPay Item Shop 1.12.2

Jan 4th, 2018
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.04 KB | None | 0 0
  1. --# Kreezxil's EnderPay Shop
  2. --# based on the following
  3. --# pastebin:
  4. --# Wojbie's Xp Shoppe
  5. --# Uses touchpoint api
  6. --# http://pastebin.com/cRTsaYaK
  7.  
  8. --# Uncomment next line to remove Op message spam
  9. --commands.exec("gamerule commandBlockOutput false")
  10.  
  11. local Shop={}
  12.  
  13. --# table.insert(Shop,{["name"]="Stone Brick",["price"]=1,["item"]="minecraft:stonebrick 64"})
  14. --# table.insert(Shop,{["name"]="Tin Gear",["price"]=5,["item"]="Railcraft:part.gear 1 3",}) --3 is damage value for basic tin gear
  15.  
  16. table.insert(Shop,{["name"]="Diamond", ["price"]=100,["item"]="minecraft:diamond 1"})
  17.  
  18.  
  19. --# Default shop zone to CommandComputer coords
  20. local range = 5
  21.  
  22. --# Load touchpoint api
  23. if not fs.exists("/touchpoint") then shell.run("pastebin get pFHeia96 /touchpoint") end
  24. os.loadAPI("touchpoint")
  25.  
  26. --# Assuming that monitor is on top of commandComputer
  27. local t = touchpoint.new("top")
  28.  
  29. --# Commands Backup
  30. --# give @p[lm=10,x=-532,y=69,z=1084,r=3] Railcraft:part.gear 1 3
  31. --# xp -10L @p[lm=10,x=-532,y=69,z=1084,r=3]
  32.  
  33. local jump=false
  34.  
  35. print("Adding "..#Shop.." Items to shop")
  36.  
  37. for i,k in pairs(Shop) do
  38.     local name = k.name.." = "..k.price.."L"
  39.     print(name)
  40.  
  41.     t:add(name, function()
  42.         --wiadomosc nie masz xp
  43.         commands.exec("tellraw @p[l="..(k.price-1)..",r="..range.."] "..'["",{"text":"You don\'t have enough credits for '..k.name..'","color":"red"}]')
  44.         commands.exec("playsound minecraft:entity.villager.no player @p[l="..(k.price-1)..",r="..range.."]")
  45.         --wiadomosc masz xp
  46.         commands.exec("tellraw @p[lm="..k.price..",r="..range.."] "..'["",{"text":"Sold '..k.name.." for "..k.price..' lvl","color":"green"}]')
  47.         commands.exec("playsound minecraft:entity.villager.yes player @p[lm="..k.price..",r="..range.."]")
  48.         commands.exec("give @p[lm="..k.price..",r="..range.."] "..k.item)
  49.         commands.exec("wallet take @p[lm='..k.price..',r='..range..'] '..k.price..' ")
  50.         t:flash(name)
  51.     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)
  52.  
  53.     jump=not jump
  54. end
  55.  
  56. t:run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement