Skip to content

Set/Get Local Int

ZephiriusZephirius Member Posts: 419
edited December 2022 in Builders - Scripting
Ok...

1. The PC first reads a book (uses the placeable) and sets a local int on the PC.
SetLocalInt(oPC, "council_six", 1);
At this point the PC should be wandering the desolate tomb with a giant "1" on her forehead!
2. Travel to the door where the Local Int script is placed - OK. "Door code" -
void main()
{
    object oPC = GetLastOpenedBy();
    if (!GetIsPC(oPC)) return;

    if (GetLocked(OBJECT_SELF) == TRUE)
    {
        if (GetLocalInt(oPC, "council_six") == 1)
        {
        SetLocked(OBJECT_SELF, FALSE);
        AssignCommand(OBJECT_SELF, ActionPlayAnimation(ANIMATION_DOOR_OPEN1));
        }
    }
}

Nothing is doing. :( Door still locked.
I'm uncertain which handler to use at this point. I've tried all of the pertinent ones that I can think of.

Note: The door is marked as having a key required to open. Purposefully no key exists. I just wanted it to be locked absolutely. I don't think a key is required as the code should supersede the lock flags. At least that is the way I understand it... :):*

This is where I bow out...
Post edited by Zephirius on

Comments

  • TarotRedhandTarotRedhand Member Posts: 1,481
    edited December 2022
    Just a guess but if the door is locked, the door can't be opened therefore GetLastOpenedBy() will probably not return anything meaningful. Try using the OnUsed event for your code and GetLastUsedBy() instead.

    TR
  • ZephiriusZephirius Member Posts: 419
    The problem is, a door has no OnUsed handler, so I'm miffed as to the choices I have . I wonder if OnAreaTransistionClick() might bear some fruit???

    Thanks for the help TarortRedhand.
  • ZephiriusZephirius Member Posts: 419
    OnAreaTransistion is a no go. Kinda makes sense... You know, I think I've seemed to have had this problem before and eventually solved it. Gonna go through my posts. Will check back if I find the answer...
  • TarotRedhandTarotRedhand Member Posts: 1,481
    edited December 2022
    Just looked in the lexicon. As, when encountered, the door is locked try the OnFailToOpen event and replace GetLastOpenedBy() with GetClickingObject().

    TR
  • ZephiriusZephirius Member Posts: 419
    edited December 2022
    https://forums.beamdog.com/discussion/84164/door-wont-open#latest. - the solution...

    Proleric had the answer all along in this thread. OnFailToOpen tells us that GetClickingObject() is the function to use. "Proleric"

    In case there are still novices out there - I very much consider myself a novice-Using the OnFailToOpenhandler with GetClickingObject(), the final code should read:
    void main()
    {
        object oPC = GetClickingObject();
        if (!GetIsPC(oPC)) return;
    
        if (GetLocked(OBJECT_SELF) == TRUE)
        {
            if (GetLocalInt(oPC, "council_six") == 1)
            {
            SetLocked(OBJECT_SELF, FALSE);
            AssignCommand(OBJECT_SELF, ActionPlayAnimation(ANIMATION_DOOR_OPEN1));
            }
        }
    }
    

    So everything is copasetic as it stands. Thank guys!
    Post edited by Zephirius on
  • ProlericProleric Member Posts: 1,316
    Utter my true name and I shall appear...

    wtf copasetic?

    ... disappears ...
  • ZephiriusZephirius Member Posts: 419
    edited December 2022
    Proleric wrote: »
    Utter my true name and I shall appear...

    wtf copasetic?

    ... disappears ...

    ...and with no one immediately in distress, like a phantom - he's gone. "Whoosh"
Sign In or Register to comment.