Wojbie

Xp Shoppe

Feb 20th, 2015 (edited)
1,459
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.10 KB | None | 0 0
  1. --# Wojbie's Xp Shoppe
  2. --# Uses touchpoint api
  3. --# http://pastebin.com/cRTsaYaK
  4.  
  5. --   Copyright (c) 2015-2021 Wojbie (wojbie@wojbie.net)
  6. --   Redistribution and use in source and binary forms, with or without modification, are permitted (subject to the limitations in the disclaimer below) provided that the following conditions are met:
  7. --   1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  8. --   2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  9. --   3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
  10. --   4. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
  11. --   5. The origin of this software must not be misrepresented; you must not claim that you wrote the original software.
  12. --   NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. YOU ACKNOWLEDGE THAT THIS SOFTWARE IS NOT DESIGNED, LICENSED OR INTENDED FOR USE IN THE DESIGN, CONSTRUCTION, OPERATION OR MAINTENANCE OF ANY NUCLEAR FACILITY.
  13.  
  14. --# Uncomment next line to remove Op message spam
  15. --commands.exec("gamerule commandBlockOutput false")
  16.  
  17. local Shop={}
  18.  
  19. --# table.insert(Shop,{["name"]="Stone Brick",["price"]=1,["item"]="minecraft:stonebrick 64"})
  20. table.insert(Shop,{["name"]="Tin Gear",["price"]=5,["item"]="Railcraft:part.gear 1 3",}) --3 is damage value for basic tin gear
  21. table.insert(Shop,{["name"]="Tarma Root",["price"]=2,["item"]="arsmagica2:TarmaRoot 1"})
  22. table.insert(Shop,{["name"]="Stone Brick",["price"]=1,["item"]="minecraft:stonebrick 64"})
  23. table.insert(Shop,{["name"]="Stone",["price"]=100,["item"]="minecraft:stone 64"})
  24.  
  25.  
  26.  
  27. --# Default shop zone to CommandComputer coords
  28. local range = 5
  29.  
  30. --# Load touchpoint api
  31. if not fs.exists("/touchpoint") then shell.run("pastebin get pFHeia96 /touchpoint") end
  32. os.loadAPI("touchpoint")
  33.  
  34. --# Assuming that monitor is on top of commandComputer
  35. local t = touchpoint.new("top")
  36.  
  37. --# Commands Backup
  38. --# give @p[lm=10,x=-532,y=69,z=1084,r=3] Railcraft:part.gear 1 3
  39. --# xp -10L @p[lm=10,x=-532,y=69,z=1084,r=3]
  40.  
  41. local jump=false
  42.  
  43. print("Adding "..#Shop.." Items to shop")
  44.  
  45. for i,k in pairs(Shop) do
  46.     local name = k.name.." = "..k.price.."L"
  47.     print(name)
  48.  
  49.     t:add(name, function()
  50.         --wiadomosc nie masz xp
  51.         commands.exec("tellraw @p[l="..(k.price-1)..",r="..range.."] "..'["",{"text":"You don\'t have lvl for '..k.name..'","color":"red"}]')
  52.         commands.exec("playsound mob.villager.no @p[l="..(k.price-1)..",r="..range.."]")
  53.         --wiadomosc masz xp
  54.         commands.exec("tellraw @p[lm="..k.price..",r="..range.."] "..'["",{"text":"Sold '..k.name.." for "..k.price..' lvl","color":"green"}]')
  55.         commands.exec("playsound mob.villager.yes @p[lm="..k.price..",r="..range.."]")
  56.         commands.exec("give @p[lm="..k.price..",r="..range.."] "..k.item)
  57.         commands.exec("xp -"..k.price.."L @p[lm="..k.price..",r="..range.."]")
  58.         t:flash(name)
  59.     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)
  60.  
  61.     jump=not jump
  62. end
  63.  
  64. t:run()
Add Comment
Please, Sign In to add comment