Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local time = 30
- local rsSide = "top"
- -- below does not matter, auto-detected.
- local esSide = ""
- local function switch()
- rs.setOutput(rsSide, true)
- os.sleep(0.5)
- rs.setOutput(rsSide, false)
- os.sleep(0.5)
- end
- local function canRunEntitySensor()
- for i, periph in ipairs(peripheral.getNames()) do
- if peripheral.getType(periph) == "manipulator" then
- esSide = periph
- if peripheral.call(esSide, "hasModule", "plethora:sensor") then
- return true
- end
- end
- end
- return false
- end
- local function check()
- local ents = peripheral.call(esSide, "sense")
- for i, entity in ipairs(ents) do
- if entity.x > 0 and entity.x < 2 and entity.z > 0 and entity.z < 2 then
- return true
- end
- end
- return false
- end
- local function main()
- local entityCheck = canRunEntitySensor()
- while true do
- if entityCheck then
- print("Checking entities...")
- if check() then
- print("Shooting.")
- switch()
- print("Done.")
- end
- os.sleep(3)
- else
- print("Shooting.")
- switch()
- print("Done. Waiting 30 seconds.")
- os.sleep(30)
- end
- end
- end
- main()
Add Comment
Please, Sign In to add comment