ReverendFelix Posted November 30, 2021 Posted November 30, 2021 I need a pair of scripts to place on doors, telling the PC they need a key, and where to possibly find it. So basically (shitty example... I know); Spoiler If has key(revWizardsWellKey) == true then; pass through the door (no message box) elseif has key(revWizardsWellKey) == false then; message box pops up (It seems I need a key for this one. Perhaps it can be found on the other end. Wherever that may be...) press okay, trying again repeats message endif The other script would be identical except the message box would say; It seems I need a key for this one. Perhaps I should search around here. I bet it's close by... All I can say is I really don't know how to do papyrus scripting. Please help
fishburger67 Posted November 30, 2021 Posted November 30, 2021 1 hour ago, ReverendFelix said: I need a pair of scripts to place on doors, telling the PC they need a key, and where to possibly find it. So basically (shitty example... I know); Hide contents If has key(revWizardsWellKey) == true then; pass through the door (no message box) elseif has key(revWizardsWellKey) == false then; message box pops up (It seems I need a key for this one. Perhaps it can be found on the other end. Wherever that may be...) press okay, trying again repeats message endif The other script would be identical except the message box would say; It seems I need a key for this one. Perhaps I should search around here. I bet it's close by... All I can say is I really don't know how to do papyrus scripting. Please help I can help you with this, but it will have to wait till tomorrow if no one else comes to the rescue tonight.
VersuchDrei Posted November 30, 2021 Posted November 30, 2021 I guess you'd probably go with something like this: (haven't had time to test it as I'm currently at work) Scriptname doorMessageScript extends ObjectReference Key Property DoorKey Auto Message Property DoorMessage Auto Event OnActivate(ObjectReference akActorRef) Actor Player = Game.GetPlayer() If akActorRef == Player && Player.getItemCount(DoorKey) == 0 DoorMessage.Show() EndIf EndEvent
ReverendFelix Posted November 30, 2021 Author Posted November 30, 2021 @VersuchDrei Okay so I just need to insert the info to make it work right?
VersuchDrei Posted November 30, 2021 Posted November 30, 2021 15 minutes ago, ReverendFelix said: @VersuchDrei Okay so I just need to insert the info to make it work right? Script should hopefully work as is, all you need to do is to create the key and message in the CK and add them to the properties.
ReverendFelix Posted November 30, 2021 Author Posted November 30, 2021 Yep, that's what I meant. I thank you, and will let you know how it goes?
ReverendFelix Posted November 30, 2021 Author Posted November 30, 2021 Alright, here's what I have so far. It won't save and compile. revRRDoorMessageScript.psc 9 hours ago, VersuchDrei said: Actor Player = Game.GetPlayer() Do I need to add something to the () in this part. I tried typing 'Player', but that didn't work.
VersuchDrei Posted November 30, 2021 Posted November 30, 2021 14 minutes ago, ReverendFelix said: Do I need to add something to the () in this part. I tried typing 'Player', but that didn't work. Script compiled fine for me. Only problem is the change you did. "revWizardsWellKey" is neither defined as a property nor as a variable. So the compiler doesn't know what it is. Properties in the script don't necessarily have to have the same name as the form you apply to them, so you didn't have to edit the script, just attach your revWizardsWellKey to the DoorKey property in the CK.
ReverendFelix Posted November 30, 2021 Author Posted November 30, 2021 Quote All I can say is I really don't know how to do papyrus scripting. 2 hours ago, VersuchDrei said: just attach your revWizardsWellKey to the DoorKey property in the CK Please elaborate. P.S. I really am trying to learn?
VersuchDrei Posted December 1, 2021 Posted December 1, 2021 9 hours ago, ReverendFelix said: Please elaborate. Let's say you have your door form like here (I used a vanilla door for the example, you will probably have to create a new form to not mess up anything): When you have attached the script to it click on properties and this window pops up: In this window now click Edit Value and fill in your respective Key/Message form for both properties.
ReverendFelix Posted December 1, 2021 Author Posted December 1, 2021 Ah I see now, geez. Sorry, this sort of modding is new to me at this point. Back to the CK. Thanks again?
ReverendFelix Posted December 1, 2021 Author Posted December 1, 2021 I'm not getting any in game results. Here is what I've done; Spoiler Message Box Key Script applied to door Properties set But... External editor won't save and compile the script Where did I go wrong???
ReverendFelix Posted December 4, 2021 Author Posted December 4, 2021 I had a friend take a look at the script and he returned this too me. Spoiler Scriptname revDoorMessageScript extends ObjectReference Key Property DoorKey Auto Message Property DoorMessage Auto Actor Player Event OnInit() ; Event fired when the script is initialized (normall on save load or playthrough start) BlockActivation(true) ; Stops the game from using default activation processings, forcing it to go through our script. A place where WE have control! *evil laughter* Player = Game.GetPlayer() ; Gets the player once and once only. Saves on compute time. EndEvent Event OnActivate(ObjectReference akActionRef) ; Since Followers activate doors too, they won't be able to follow the player out of the door. ; Or, on the oppposite side of the coin, it'd create an unimmersive experience ovrall because followers could use the door but nobody else could. ; Therefore, I removed the Player check and moved it to another If statement If akActionRef.getItemCount(DoorKey) == 0 ; Checks anyone for the key, even followers. if akActionRef == Player ; Check if the player is using the door here to prevent message spam DoorMessage.Show() EndIf else ; If the actor (INCLUDING followers, in that rare edge-case) has the key, then open the door Activate(akActionRef, true) ; Activate this door again, this time using normal activation processing ; Adding "true" as the second parameter also prevents sending the OnActivate event, which would create an infinite loop. ; Stop processing events once the door is unlocked BlockActivation(false) GoToState("Unlocked") EndIf EndEvent State Unlocked ; An empty state with no code in it stops the game from using unnecessary compute time. EndState Clean version; Spoiler Scriptname revDoorMessageScript extends ObjectReference Key Property DoorKey Auto Message Property DoorMessage Auto Actor Player Event OnInit() BlockActivation(true) Player = Game.GetPlayer() Event OnActivate(ObjectReference akActionRef) If akActionRef.getItemCount(DoorKey) == 0 if akActionRef == Player DoorMessage.Show() EndIf else Activate(akActionRef, true) BlockActivation(false) GoToState("Unlocked") EndIf EndEvent State Unlocked EndState The only problem is it crashes my CK, and we can't figure out why. Yes, I have the CK fixes...?
Recommended Posts
Archived
This topic is now archived and is closed to further replies.