Jump to content

[REQUEST] [HELP] I need a custom script made


Recommended Posts

Posted

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

Posted
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.

Posted

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

 

Posted
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.

Posted
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.

Posted
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?

Posted
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):

image.png.8aa6ac7e80559d707f9ab0d1ac44769d.png

 

When you have attached the script to it click on properties and this window pops up:
image.png.d8d31a7228297126a54fea19fc469da3.png

 

In this window now click Edit Value and fill in your respective Key/Message form for both properties.

Posted

I'm not getting any in game results.

 

Here is what I've done;

 

Spoiler

Message Box

1303123200_Screenshot2021-12-01100348.png.7c83a7c9ff9907e6bd5dda7cb56c2ef2.png

 

Key

792402877_Screenshot2021-12-01100429.png.b4713b33e5d6a545be07401fee2530cc.png

 

Script applied to door

897521374_Screenshot2021-12-01100206.png.37440b98766af948db0fe21de12a1d82.png

 

Properties set

2103453757_Screenshot2021-12-01100305.png.c71ba832ad13cde798c061602666782d.png

 

But...

 

External editor won't save and compile the script

125264974_Screenshot2021-12-01095433.thumb.png.930b998b762260f58154ad1ab34db6dd.png

 

Where did I go wrong???

Posted

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...?

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...