Jump to content

Recommended Posts

Hello all! I'm trying to make a client-side admin-only mod which would allow me to manually set aggro for mobs by selecting them and then pressing a button that would access the combat component of a selected entity to change the target. However, I've run into a roadblock; the game recognizes that the selected entities have been selected, and that they have components, but apparently is unable to access/change/tell-that-specific-components are there. Is there any way for me to modify the components of individual, selected entities in-game?

Additionally, this is the problem code (v.components.combat returns nil, regardless of whether or not the entity has a combat component.) I am capable of using v.components.combat:SetTarget(tar) in the in-game console once I've defined the variables, so I'm somewhat confused on how I might get this working. If there's some way to call commands through the console from the modmain, that might also work, but I'm unsure if such a function exists.

for k,v in pairs(Ents) do
	
		if v:HasTag("honey_mob") then
		
			if v.components.combat ~= nil then -- this returns nil, regardless of whether or not the entity has a combat component.
				
				v.components.combat:SetTarget(tar);
			
			end
			
		end
		
	end

Attached is my full modmain.lua if a comprehensive look at the file would help you.

modmain.lua

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...