Jump to content

How to print variables from a perk's "Add Activate Choice"?


Cogneter

Recommended Posts

This is starting to drive me crazy, and I'm really hoping one of the scripting gurus can help me.

 

I'm creating a mod that adds a perk. The entry point of that perk is "Activate", and the function is "Add Activate Choice". This allows me to run a script whenever the player character interacts with another NPC.

 

And all was going well, until I tried outputting a variable ("player.GetAV Strength" in my case) for debugging purposes. This is when things turned ugly - I could not.

 

After a couple hours of researching, this is the code I have come up with:

int iValue
set iValue to 42
MessageEx "MessageEx: The value of iValue is %g" iValue
PrintToConsole "PrintToConsole: The value of iValue is %g" iValue
ShowMessage STUNuTest iValue

The message inside "STUNuTest" is "Test %g".

 

So I start the game, activate the perk, and here are the results I get:

1) MessageEx doesn't show up.

2) PrintToConsole doesn't output anything in the console.

3) ShowMessage displays the following: "Test 0".

 

"Ok", I thought to myself, "perhaps my G.E.C.K or FNV are broken, or my NVSE is installed incorrectly".

 

Then I tried the exact same code from above, but put it in the script of a quest, like this:

scn STUNuQuestScript

begin gamemode
    int iValue
    set iValue to 42
    MessageEx "MessageEx: The value of iValue is %g" iValue
    PrintToConsole "PrintToConsole: The value of iValue is: %g" iValue
    ShowMessage STUNuTest iValue
end

When I start the game, this is what I get:

1) MessageEx outputs "MessageEx: The value of iValue is 42" on the screen.

2) PrintToConsole outputs "PrintToConsole: The value of iValue is 42" in the console.

3) ShowMessage displays the following: "Test 42".

 

:mellow:

 

My questions are:

  1. Is there something wrong with the scripts inside the perk's "Add Activate Choice" that prevents them from passing variables and calling NVSE functions?
  2. If yes, is there any workaround that would allow me to output variables from there?
  3. If no, is there a perk-less alternative that would allow me to assign an "Activate" event to all NPCs?

 

I'm launching both FNV and G.E.C.K with nvse_loader.exe.

Link to comment
Share on other sites

I don't think you can declare variables in the Perk activation box. So no Ref or Int allowed. You can still do everything else in a script, using globals instead of variables would probably work.

Yup, you're right. I declared some temporary variables in a quest and was able to use them. Less than optimal, but I can work with that.

 

For the reference, I changed the code in my perk to:

set STUNuQuest.tmpTest to 42
MessageEx "MessageEx: The value of iValue is %g" STUNuQuest.tmpTest
PrintToConsole "PrintToConsole: The value of iValue is %g" STUNuQuest.tmpTest
ShowMessage STUNuTest STUNuQuest.tmpTest

When activating the perk, the output was as expected:

1) MessageEx outputs "MessageEx: The value of iValue is 42" on the screen.

2) PrintToConsole outputs "PrintToConsole: The value of iValue is 42" in the console.

3) ShowMessage displays the following: "Test 42".

 

Apparently, MessageEx and PrintToConsole weren't showing up because they didn't receive a matching number of parameters (iValue being null).

 

Thanks senterpat, you really helped!

Link to comment
Share on other sites

  • Recently Browsing   0 members

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