Jump to content




Openccsensors help redstone pulse when crouching


  • You cannot reply to this topic
7 replies to this topic

#1 tvc

  • Members
  • 35 posts

Posted 27 May 2013 - 01:03 AM

I am wondering what i would need to do to set a redstone pulse when a is crouching

something like

prox.getTargetDetails(digger191)
if is crouching == true then
rs.setOutput("right", true)

or something like that

#2 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 27 May 2013 - 01:12 AM

Something vaguely like that. Try this:

os.loadAPI("ocs/apis/sensor")
local prox = sensor.wrap("top")
while true do
  local details = prox.getTargetDetails("digger191")
  if details.isCrouching then
    rs.setOutput("right", true)
  else
    rs.setOutput("right", false)
  end
  sleep(0.5)
end


#3 tvc

  • Members
  • 35 posts

Posted 27 May 2013 - 01:19 AM

View PostLyqyd, on 27 May 2013 - 01:12 AM, said:

Something vaguely like that. Try this:

os.loadAPI("ocs/apis/sensor")
local prox = sensor.wrap("top")
while true do
  local details = prox.getTargetDetails("digger191")
  if details.isCrouching then
	rs.setOutput("right", true)
  else
	rs.setOutput("right", false)
  end
  sleep(0.5)
end

the programs run with no errors but does not output redstone signal when i crouch

#4 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 27 May 2013 - 01:51 AM

Is your minecraft name "digger191"?

Try running the ocs/programs/sensorview program to see what the information is, especially the correct key name for isCrouching (may be isSneaking). Use the arrow keys and page-up and page-down to look around at the information. Disable NEI temporarily by hitting O in your inventory to make page-up and page-down work.

#5 tvc

  • Members
  • 35 posts

Posted 27 May 2013 - 02:04 AM

my name is digger191 and it is isSneaking but it didnt more i even tried to set it to == true then

that also didnt work =[ lol

#6 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 27 May 2013 - 02:11 AM

It's apparently IsSneaking, with a capital I. Try this, make sure your sensor is on top:

os.loadAPI("ocs/apis/sensor")
local prox = sensor.wrap("top")
while true do
  local details = prox.getTargetDetails("digger191")
  if details and details.IsSneaking then
	    rs.setOutput("right", true)
  else
	    rs.setOutput("right", false)
  end
  sleep(0.5)
end


#7 tvc

  • Members
  • 35 posts

Posted 27 May 2013 - 02:14 AM

I love you lol thank you so much

one more question tho

when i leave the are it breaks the program say nil target because it cant find me how to i fix this?

#8 LordIkol

  • Members
  • 197 posts
  • LocationSwitzerland

Posted 27 May 2013 - 06:15 AM

you have to use a loop insteadt of directly pointing at you as target.

sth like this:

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

while true do
local targets = prox.getTargets()
for name, basicDetails in pairs(targets) do
  if name == "digger191" then  --not sure if name is the minecraftname yould be sth else
   local details = prox.getTargetDetails(name)
	if details and details.IsSneaking then
	  rs.setOutput("right", true)
	else
	  rs.setOutput("right", false)
	end
  else
   rs.setOutput("right", false)
  end
end
  sleep(0.5)
end

greets Loki





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users