Jump to content

Having issues with global variables and papyrus


YaBoyChrisB

Recommended Posts

Hi,

 

So I'm working on some test scripts for a new mod project and I've run into some scripting issues. Now, I'm definitely not the best when it comes to scripting so I could use some help here. Basically, I'm trying to use global variables in an esm to connect choices made in different esp files. The test I have setup is simply kill npc in first esp>enable table in second esp. There's a script connected to the npc that's a simple OnDeath event that changes the global variables' value on death, then the table has a script that's meant to enable the table when it reads that the global variable value has changed.

 

Here's the npc's script that (at least to my knowledge) works fine:

 

 

Scriptname NPCTestScript extends Actor Const
GlobalVariable Property GlobalTest Auto Const
Actor Property TestNPC Auto Const
Event OnDeath(Actor akKiller)
if (akKiller == Game.GetPlayer())
GlobalTest.SetValue(1)
endif
EndEvent

 

Here's the table script. It gives me an error saying "missing EndOfFile at 'if'" when I compile:

 

 

Scriptname TableTestScript extends ObjectReference Const
ObjectReference Property TestTable Auto Const
GlobalVariable Property GlobalTest Auto Const
if GlobalTest.GetValue()==1
TestTable.enable()
endif
Like I said, I'm not the best with scripting so any help would be much appreciated!
Link to comment
Share on other sites

You need to wrap the TableTestScript If .. Endif test in a Function that is called by a trigger event, or a trigger event.

 

Consider what should trigger the TableTestScript to run the if test ?

 

Also to avoid having a hard master relationship between esp files, using GetFormFormFile() on the GlobalTest variable is best.

Link to comment
Share on other sites

You need to wrap the TableTestScript If .. Endif test in a Function that is called by a trigger event, or a trigger event.

 

Consider what should trigger the TableTestScript to run the if test ?

 

Also to avoid having a hard master relationship between esp files, using GetFormFormFile() on the GlobalTest variable is best.

 

Could you show me an example? I've tried triggering with an event but it says that it can't be defined because the script isn't native. Thanks for the reply though!

Link to comment
Share on other sites

Standard static tables are not "Furniture" in Creation Engine terms. Furniture is (generally) interactable, tables are statics. You need to tell us what "record type" your object is of, a 4-letter-all-caps short handle. Furniture objects are FURNs, pickable plants are FLORs, statics are STATs, ... this is what SKK50 wants to know.

Edited by payl0ad
Link to comment
Share on other sites

Thats it, you see different base objects have different script events that can be used as triggers to run your evaluation.

 

Lets simplfy to break through the confiusion, getting stuck into code at this level of comprehension is doomed to frustration.

 

Talk us through the sequence of events and interactions between the actors and objects that shuld cause your script to trigger.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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