Jump to content

Attaching scripts to dialogue - HOW? Please help me.


Syntia13

Recommended Posts

I've been trying to do this for days now and at this point I just want to scream in frustration.

I don't understand script fragments, they are mean and evil and are out to destroy my soul. Please help me before I set something of fire.

 

Dramatic preface aside, here's my problem:

 

I've recently made a very simple ferry mod. Someone asked to add a 'pay for the ride' feature. So, I added a family of ferrymen, and tried to make them activate the ferry through dialogue. Tried. I searched far and wide, but I couldn't find a script command that would tell the game: when this dialogue fires, do this'

 

I gave up, and instead created an activator with this script:

 

Scriptname SNT_Ferry_pay_in_the_mug extends ObjectReference

MiscObject Property payment Auto
Actor Property PlayerREF Auto
ObjectReference Property xMarker Auto
GlobalVariable Property howmuch Auto

Event OnActivate(ObjectReference akActionRef)
PlayerREF.removeitem(payment, howmuch.value as int)
xMarker.Enable()

EndEvent

 

Short and simple - I put some money in a moneybox, a ferry activator appears. It compiles, it works, it's great.

 

But then I decided to try to make the dialogue work as well, and I just can't.

I watched few hours' worth of tutorials on youtube, read through relevant tutorials at www.creationkit.com, and I got exactly nowhere.

 

So apparently there is no equivalent of

Event OnActivate(ObjectReference akActionRef)

for a dialogue, I must use the script fragments instead... except they don't work.

So far the only line of script that compiled for me was GetOwningQuest().SetCurrentStageID(10), which would be great if I wanted the game to set a quest stage. But I don't. I just want the game to shut up and take my money (and to enable one object).

It doesn't wan't to do that. At all. Various tutorials give slightly different versions of the relevant line:

 

Game.GetPlayer().RemoveItem(Gold001, 5)
Game.GetPlayer().RemoveItem(GoldBase, 5)
Game.GetPlayer().RemoveItem(Gold, 5)

 

- none of those work for me. Even if it did, it wouldn't be enough, as I want to actually get something in return for the money, but I figured I'd start small. As it is, I didn't start, I'm stuck.

 

 

tl;dr: Please for the love of Talos, what do I have to type in the script fragment window to get a script that would have the same functionality as the pay_in_the_mug script above?

 

Sincerly

(very frustrated) Syntia

 

Link to comment
Share on other sites

As you have discovered, script fragments do not behave like regular scripts.

 

A script fragment is a function. Each script fragment function associated with a particular record is added to a script that the Creation Kit creates. The script name is broken down into a four letter prefix (if any) followed by the type of fragment script (TIF - Topic Info, PF - Package, QF - Quest Stage, etc) followed by the Editor ID name (if there is one) and the Editor ID number of the record as local to the associated plugin and finally the extension (PEX or PSC).

Example:

BYOH_TIF__000CCD5A.psc

 

On to your question...

To have gold taken from the player within dialog. You will need to use the RemoveItem function as the tutorials indicated. What you may have missed is that you cannot compile any function that uses a variable without first defining it. In this scenario, you will need a property variable. Properties cannot be written within the script fragment window. Properties have to be added via the "properties window" in the Creation Kit. Unfortunately, you cannot access this window until the script exists. Therefore, you will need to do the following first.

 

  1. Open the Topic Info record in question
  2. In the Script Fragment box, if new record, make sure there is no code there and type a single semi-colon ";" If existing record with existing code, skip to step 6
  3. Compile the script
  4. Close the Topic Info record as a precaution to ensure that the CK recognizes any changes made
  5. Re-open the Topic Info record
  6. In the Script Fragment section there should be an Advanced tab, switch to it.
  7. You should now see a Properties button, click it.
  8. Use the window that appears to add a property.
  9. If you name the property Gold001, you can use the Auto-Fill option to have the property associated with the object that represents gold in-game.
  10. Close that window
  11. Switch the tab back to the Script Fragment box
  12. Enter the function you wish to use. Example: Game.GetPlayer().RemoveItem(Gold001,100)
  13. Then compile, save your plugin and test in-game.

To have something given to the player, you will use the AddItem function. Example: Game.GetPlayer().AddItem(Gold001,1000)

This example gives 1000 gold to the player. Provided of course that the variable Gold001 is a property with the appropriate gold object assigned to it.

 

If you know both what you want to give to the player and take from the player, you can create both properties at the same time, add the respective function calls to the script fragment and compile at the same time. The trick to remember is that the script must exist before you can add a property. Thus always compile a single semi-colon ";" prior to adding code to any script fragment box.

Link to comment
Share on other sites

YES!

Ahem. I mean, yes, that worked for me on the first try, thank you ever so much. I'm fairly positive that this little quirk of CK was not mentioned in the official tutorials, and I would never figure it out on my own.

The fragments compile, and it is beautiful. :laugh:

Thank you again.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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