I'm working on my first multi-function script, so I'm not very familiar with common logic problems. Basically, around this function, the button is following the player around. I'm trying to make it so that if the button is pressed while it is 64 units or less away from a texture toggle, it increments the texture. I have a static variable called antiline that holds the closest texutretoggle. Here is one of the if statements i've tried:
if (antiline_detector() == true && button_pressed == true){
antiline = Entities.FindByClassnameNearest("env_texturetoggle",self.GetOrigin(),64);
local name = antiline.GetName();
ShowMessage(name);
self.ConnectOutput("OnPressed","DoEntFire(\""+name+"\",\"incrementtextureindex\",\"\",0,null,null)");
button_pressed = false;
}
Another one I've tried is this:
if (antiline_detector() == true && button_pressed == true){
antiline = Entities.FindByClassnameNearest("env_texturetoggle",self.GetOrigin(),64);
self.ConnectOutput("OnPressed","EntFire(antiline,\"incrementtextureindex\",\"\",0,null)");
button_pressed = false
}
I've also tried a varient of the second one where the second perameter of the commectoutput function was seperated into it's own function. I doubt this will all work the way I want it to, and I'll be happy to run into those mistakes as I go, but my problem now is that when I press the button over the texture toggle entity, the console says the it fireing whenever I press the button, but the texture doesn't toggle. So, my problem is with the EntFire and DoEntFire functions. Does anyone see my problem with that?
Edit: I also tried this:
if (antiline_detector() == true && button_pressed == true){
antiline = Entities.FindByClassnameNearest("env_texturetoggle",self.GetOrigin(),64);
self.ConnectOutput("OnPressed","EntFireByHandle(antiline,\"IncrementTextureIndex\",\"\",0,null,null)");
button_pressed = false
}
