Advertisement
Nike622000

JoJa-Shop

Jun 19th, 2018
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.44 KB | None | 0 0
  1. local config_path = "shop.config"
  2.  
  3. function readConfig(file_path)
  4.     if file_path ~= nil and fs.exists(file_path) then
  5.         print("file found.")
  6.         if string.find(file_path.."",".config") then
  7.             print("reading config...")
  8.             shell.run(file_path)
  9.             print("checking monitor...")
  10.             if monSide == nil or peripheral.getType(monSide) ~= "monitor" then
  11.                 print("monitor unavailable.")
  12.                 return false
  13.             else
  14.                 print("monitor available.")
  15.                 print("checking sensor...")
  16.                 if senSide == nil or peripheral.getType(senSide) ~= "sensor" or senCoords == nil or senField == nil then
  17.                     print("sensor unavailable.")
  18.                     return false
  19.                 else
  20.                     print("sensor available.")
  21.                     if bCol == nil then
  22.                         print("no backgroundcolor found.")
  23.                         bCol = colors.lightGray
  24.                     else
  25.                         print("backgroundcolor found.")
  26.                     end
  27.                     print("backgroundcolor set to "..bCol..".")
  28.                 print("reading finished")
  29.                 return true
  30.                 end
  31.             end
  32.         else
  33.             print("wrong format.")
  34.         end
  35.     else
  36.         print("file not found.")
  37.     end
  38.     return false
  39. end
  40.  
  41. function checkSensor()
  42.     local xP1 = senCoords[1]+senField[1][1]
  43.     local xP2 = senCoords[1]+senField[2][1]
  44.     if xP2 > xP1 then
  45.         local temp = xP1
  46.         xP1 = xP2
  47.         xP2 = temp
  48.     end
  49.     local yP1 = senCoords[2]+senField[1][2]
  50.     local yP2 = senCoords[2]+senField[2][2]
  51.         if yP2 > yP1 then
  52.         local temp = yP1
  53.         yP1 = yP2
  54.         yP2 = temp
  55.     end
  56.     local zP1 = senCoords[3]+senField[1][3]
  57.     local zP2 = senCoords[3]+senField[2][3]
  58.         if zP2 > zP1 then
  59.         local temp = zP1
  60.         zP1 = zP2
  61.         zP2 = temp
  62.     end
  63.     local targets = sen.getTargets()
  64.     for k,v in pairs(targets) do
  65.         if v.Name == "Player" and  v.Position.X <= xP1 and v.Position.X >= xP2 and v.Position.Y <= yP1 and v.Position.Y >= yP2 and v.Position.Z <= zP1 and v.Position.Z >= zP2 then
  66.             local player_name = k
  67.             return k
  68.         end
  69.     end
  70.     return nil
  71. end
  72.  
  73. function JoJa(xP,yP)
  74.   m.setCursorPos(xP,yP)
  75.   m.setBackgroundColor(colors.gray)
  76.   m.setTextColor(colors.cyan)
  77.   m.write("Jo")
  78.   m.setTextColor(colors.orange)
  79.   m.write("Ja ")
  80.   m.setTextColor(colors.lightGray)
  81.   m.write("Productions")
  82. end
  83.  
  84. function Background(col)
  85.   m.setBackgroundColor(col)
  86.   for xP = 1,xMax do
  87.     for yP = 1,yMax do
  88.       m.setCursorPos(xP,yP)
  89.       m.write(" ")
  90.     end
  91.   end
  92. end
  93.  
  94. readConfig(config_path)
  95. print(checkSensor)
  96. local user = checkSensor()
  97. while user == nil do
  98.     delay(.5)
  99.     user = checkSensor()
  100. end
  101. print(user)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement