Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local config_path = "shop.config"
- function readConfig(file_path)
- if file_path ~= nil and fs.exists(file_path) then
- print("file found.")
- if string.find(file_path.."",".config") then
- print("reading config...")
- shell.run(file_path)
- print("checking monitor...")
- if monSide == nil or peripheral.getType(monSide) ~= "monitor" then
- print("monitor unavailable.")
- return false
- else
- print("monitor available.")
- print("checking sensor...")
- if senSide == nil or peripheral.getType(senSide) ~= "sensor" or senCoords == nil or senField == nil then
- print("sensor unavailable.")
- return false
- else
- print("sensor available.")
- if bCol == nil then
- print("no backgroundcolor found.")
- bCol = colors.lightGray
- else
- print("backgroundcolor found.")
- end
- print("backgroundcolor set to "..bCol..".")
- print("reading finished")
- return true
- end
- end
- else
- print("wrong format.")
- end
- else
- print("file not found.")
- end
- return false
- end
- function checkSensor()
- local xP1 = senCoords[1]+senField[1][1]
- local xP2 = senCoords[1]+senField[2][1]
- if xP2 > xP1 then
- local temp = xP1
- xP1 = xP2
- xP2 = temp
- end
- local yP1 = senCoords[2]+senField[1][2]
- local yP2 = senCoords[2]+senField[2][2]
- if yP2 > yP1 then
- local temp = yP1
- yP1 = yP2
- yP2 = temp
- end
- local zP1 = senCoords[3]+senField[1][3]
- local zP2 = senCoords[3]+senField[2][3]
- if zP2 > zP1 then
- local temp = zP1
- zP1 = zP2
- zP2 = temp
- end
- local targets = sen.getTargets()
- for k,v in pairs(targets) do
- 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
- local player_name = k
- return k
- end
- end
- return nil
- end
- function JoJa(xP,yP)
- m.setCursorPos(xP,yP)
- m.setBackgroundColor(colors.gray)
- m.setTextColor(colors.cyan)
- m.write("Jo")
- m.setTextColor(colors.orange)
- m.write("Ja ")
- m.setTextColor(colors.lightGray)
- m.write("Productions")
- end
- function Background(col)
- m.setBackgroundColor(col)
- for xP = 1,xMax do
- for yP = 1,yMax do
- m.setCursorPos(xP,yP)
- m.write(" ")
- end
- end
- end
- readConfig(config_path)
- print(checkSensor)
- local user = checkSensor()
- while user == nil do
- delay(.5)
- user = checkSensor()
- end
- print(user)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement