Hey Gang, First time post here. I’m trying to figure out how to get a Lever to activate 5 placeables once used. Below is my script so far. The script is being placed on the lever’s OnUse function currently. Each Placeable has the generic NWN script for OnUse set as well. I can activate the items manually by clicking on them just fine, but this script will not call the OnUse function for them. I know I’m missing something. I just don’t know what it is. Any help would be appreciated!
void main()
{
// * note that nActive == 1 does not necessarily mean the placeable is active
// * that depends on the initial state of the object
object oStone1 = GetObjectByTag(“Gate1Stone1”);
object oStone2 = GetObjectByTag(“Gate1Stone2”);
object oStone3 = GetObjectByTag(“Gate1Stone3”);
object oStone4 = GetObjectByTag(“Gate1Stone4”);
object oStone5 = GetObjectByTag(“Gate1Stone5”);
int nActive = GetLocalInt(OBJECT_SELF ,"X2_L_PLC_ACTIVATED_STATE");
// * Play Appropriate Animation
if (!nActive)
{
ActionPlayAnimation(ANIMATION_PLACEABLE_ACTIVATE);
DoPlaceableObjectAction(oStone1, PLACEABLE_ACTION_USE);
DoPlaceableObjectAction(oStone2, PLACEABLE_ACTION_USE);
DoPlaceableObjectAction(oStone3, PLACEABLE_ACTION_USE);
DoPlaceableObjectAction(oStone4, PLACEABLE_ACTION_USE);
DoPlaceableObjectAction(oStone5, PLACEABLE_ACTION_USE);
}
else
{
ActionPlayAnimation(ANIMATION_PLACEABLE_DEACTIVATE);
DoPlaceableObjectAction(oStone1, PLACEABLE_ACTION_USE);
DoPlaceableObjectAction(oStone2, PLACEABLE_ACTION_USE);
DoPlaceableObjectAction(oStone3, PLACEABLE_ACTION_USE);
DoPlaceableObjectAction(oStone4, PLACEABLE_ACTION_USE);
DoPlaceableObjectAction(oStone5, PLACEABLE_ACTION_USE);
}
// * Store New State
SetLocalInt(OBJECT_SELF,"X2_L_PLC_ACTIVATED_STATE",!nActive);
}
Are you sure they are placeables and not doors?
They are placeable “Crystals” They have an activate/deactive state, activate basically glows and deactivate is dark.
I was attempting to use the DoPlaceableObjectAction command but I’m not sure that i’m using it right in this instance. There isn’t a lot of documentation on it or examples. My assumption was that it would just call the script tied to that Event for the said object. But that doesn’t seem to be the case.
Do you know whether the OnUsed script is actually firing?
SendMessageToPC() as the first line of that script would tell you.
The Lexicon info on DoPlaceableObjectAction is a bit vague - have you tried ExecuteScript instead?
I’m not sure what OnUsed script you’re using - how does it identify the user? Is it expecting a PC, for example?
So I think that is where I’m messing up. I’m never identifying the user at all. Basically the OnUsed scripts I am using are the game’s Generic x2_plc_used_act script . If I use execute script, what script would I be executing? I know that if I go over to the placeable manually and click the “Crystal” it turns on. I just cannot get that to happen remotely/through scripting with a lever,
I will add the sendmessage line and see if I can use that as a bit of troubleshooting.
All you need to do is to replicate the lever’s activation procedure with the plcs. Use
AssignCommand(oStone1, ActionPlayAnimation(ANIMATION_PLACEABLE_ACTIVATE));
Instead of DoPlaceableObjectAction
and it will light up. Repeat for other plcs and ANIMATION_PLACEABLE_DEACTIVATE
.
You could also call ExecuteScript("x2_plc_used_act", oStone1)
instead and it will also work, although it will bind the on/off animation to the state of the placeable rather than the lever, so you risk some loss of sync (without additional code), especially if PC is allowed to switch the individual placeables by using them directly.
GENIUS!! Thank you so much! It worked like a charm!