This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
cochise57's profile picture

Problem: Sort mob with OpenCCSensors

Started by cochise57, 25 August 2015 - 06:03 PM
cochise57 #1
Posted 25 August 2015 - 08:03 PM
Hello,
I built a mob tower and I would like to sort the mobs with OpenCCSensor but at the moment the empty minecart goes in front of sensor , the system stops and does not sort.

My program:


os.loadAPI("ocs/apis/sensor")
  prox = sensor.wrap("back")


while true do
local target = prox.getTargets()
for tarName, _ in pairs(target) do
    local details = prox.getTargetDetails(tarName)
    if details ~= nil then
    if details.Riding ~= nil then
	 if details.Riding.Name == "Creeper" then
	   while rs.testBundledInput("left", colors.green) == false do
		 rs.setBundledOutput("right", colors.white)
		 os.sleep(1)
	   end
	  rs.setBundledOutput("right",0)
	  break
	 elseif details.Riding.Name == "Spider" then
	   while rs.testBundledInput("left", colors.green) == false do
		 rs.setBundledOutput("right", colors.black)
		 os.sleep(1)
	   end
	  rs.setBundledOutput("right",0)
	  break
	 elseif details.Riding.Name == "Skeleton" then
	   while rs.testBundledInput("left", colors.green) == false do
		 rs.setBundledOutput("right", colors.gray)
		  os.sleep(1)
	   end
	  rs.setBundledOutput("right",0)
	  break
	 elseif details.Riding.Name == "Zombie" then
	   while rs.testBundledInput("left", colors.green) == false do
		 rs.setBundledOutput("right", colors.green)
		 os.sleep(1)
	   end
	  rs.setBundledOutput("right",0)
	  break
	 else
	   rs.setBundledOutput("right", 0)
	   break
	 end
    else
	 break   
    end
    else
    break
    end
  
end
os.sleep(1.2)
end

Best regards,
Lyqyd #2
Posted 25 August 2015 - 08:06 PM
What is the value of details.Riding for an empty minecart? You will need to set the appropriate redstone output for that case.
cochise57 #3
Posted 25 August 2015 - 09:24 PM
The details.Riding is empty but not nil.

You will need to set the appropriate redstone output for that case.

I don't understand

Best regards,
Lyqyd #4
Posted 26 August 2015 - 01:08 AM
The other cases (for each mob) set a bundled cable signal (to direct the cart where to go?), but you don't set a bundled cable signal for any other case. Do you need to set something to make the empty cart go away, so another cart can come along to be sorted? Perhaps we could help you more if you gave a lot more information on how the system is supposed to work, so we can more clearly see what isn't working.
cochise57 #5
Posted 26 August 2015 - 05:15 PM
Sorry, I'm french and I don't all understand your answer but I make two scheme for you:

1)




2)
cochise57 #6
Posted 27 August 2015 - 04:32 PM
up please
HPWebcamAble #7
Posted 28 August 2015 - 12:07 AM

local details = prox.getTargetDetails(tarName)
if details ~= nil then
  if details.Riding ~= nil then

    if details.Riding.Name == "Creeper" then
      ...
    end

  else
    --# No mob in the cart
  end
end

Add some code that sends the minecraft to try and get another mod if the cart shows up empty
cochise57 #8
Posted 28 August 2015 - 02:23 PM
I make this:

else
	   while rs.testBundledInput("left", colors.green) == false do
	   --  print("Wait")
		 rs.setBundledOutput("right", colors.brown)
		 --os.reboot()
		 os.sleep(1)
	   end
	  rs.setBundledOutput("right",0)
	  break
cochise57 #9
Posted 29 August 2015 - 12:15 AM
The problem is resolved, due to the Bundled Connector block.