Nextbot Opening door

Im having trouble with my nextbot and it wont open doors heres the code

function ENT:Use( func_door_rotating, ent )
if self.InteractionRange == func_door_rotating then
self:Use(func_door_rotating)
end
end

ENT:Use is a hook called when YOU “+use” the nextbot.

For your idea to work, you will have to do a trace from the bot to the door in his path and then fire Open input on the door.

then what should I use

I would do the trace in a think hook (I would have suggest the onstuck hook, but I don’t know when it’s called, I’ll need another dev to elaborate on that).

how do I use the trace hook

There is no trace hook?

NEXTBOT/Think

util.TraceLine

ok but how do I make the open the door

You fire the input that opens it. The input would be “Open”

Entity:Fire

thx for helping me Ive been looking to solve this forever

For more information on inputs, the valve website is the place to go. https://developer.valvesoftware.com/wiki/Func_door

nvm the nextbot wont open the door it just freezes in the door

Can you post your code? And are you getting any errors?

function ENT:Think()
local ents = ents.FindInSphere(self:GetPos(), 25)
for k,v in pairs(ents) do
if v:GetClass() == “func_door_rotating” then
v:Fire(“Open”)
end
end
end

no errors

My friend sean sent me the for in pairs do version

[lua]
hook.Add( “Think”, “BlahThinking”, function()
for k,_ in pairs( player.GetAll() ) do
local ents = ents.FindInSphere(_:GetPos(), 100)
for k,v in pairs(ents) do
if v:GetClass() == “prop_door_rotating” then
v:Fire(“Open”)
end
end
end

end)
[/lua]

Tested this on a half life map (changed the name of the entity to work with the entities in that map), and didn’t have a problem.

when I get close to a door it opens

I modified it to work on a player instead of a Nextbot because you didn’t post your entire code, but this is a proof of concept that it works.

You could also try this, v:Fire("OpenAwayFrom "…_)

So that the door doesn’t swing into the Bot.

Wow, now that is useful!

I didn’t want to post that cause it seemed out of place, but I completely agree, I had no idea there was such an input. I guess when helping someone, both people can learn something :eng101:

what do I put after the … do I put self or what