I feel the current problem will be solved a lot quicker if I show you what I am using to get the rod machine to work properly. I'll try to explain exactly what needs to be in the script and what needs to be in the level editor; I'll also attach my script that works properly (which you have my permission to use
)
First, I named my rods: rod_1, rod_2, and rod_3. The rods inside the machine (which are inactive) are named: rod_1_static, rod_2_static, and rod_3_static. The name of the machine where you put the rods is irrelevant. Make a script area that is roughly the same size as the rod machine, and make sure it is completely covering it. Click the "area" tab for the script area, and make 100% sure "ItemInteraction" is checked. Name the script area "InteractMachine". That concludes what you need for the level editor.
Note: This is the bare minimum script required to get this to properly function in the game; feel free to add particle and sound effects as you see necessary!
void OnStart()
{
SetLocalVarInt("RodVar", 0);
AddUseItemCallback("", "rod_1", "InteractMachine", "use_rod_1", true);
AddUseItemCallback("", "rod_2", "InteractMachine", "use_rod_2", true);
AddUseItemCallback("", "rod_3", "InteractMachine", "use_rod_3", true);
SetEntityInteractionDisabled("rod_1_static", true);
SetEntityInteractionDisabled("rod_2_static", true);
SetEntityInteractionDisabled("rod_3_static", true);
}
void use_rod_1(string &in asItem, string &in asEntity)
{
RemoveItem("rod_1");
SetEntityActive("rod_1_static", true);
AddLocalVarInt("RodVar", 1);
All3Rods();
}
void use_rod_2(string &in asItem, string &in asEntity)
{
RemoveItem("rod_2");
SetEntityActive("rod_2_static", true);
AddLocalVarInt("RodVar", 1);
All3Rods();
}
void use_rod_3(string &in asItem, string &in asEntity)
{
RemoveItem("rod_3");
SetEntityActive("rod_3_static", true);
AddLocalVarInt("RodVar", 1);
All3Rods();
}
void All3Rods()
{
if (GetLocalVarInt("RodVar") == 3)
{
PlayGuiSound("move_gate.snt", 1.0f); ///this function was to test if it actually worked
}
}
Hope that helped! This works 100% in game, just make sure you copied the script correctly and that all parts in the level editor have the correct names.
I rate it 3 memes.