Jump to content

How do you make a script that overwrites global variables?


bonkbonk9

Recommended Posts

Hi, I'm new to modding and I need some help. I can't figure out how to fix my script that overwrites global variables in the Creation Kit.

 

This is my .psc file.

Scriptname settlementattacksfrequency
GlobalVariable Property WSFW_Workshop_minDaysSinceLastAttack Auto
GlobalVariable Property WSFW_Workshop_attackChanceSafetyMult Auto
GlobalVariable Property WSFW_Workshop_attackChanceResourceMult Auto
GlobalVariable Property WSFW_Workshop_attackChancePopulationMult Auto
GlobalVariable Property WSFW_Workshop_attackChanceBase Auto


Event OnInit()
WSFW_Workshop_minDaysSinceLastAttack.SetValue(3.0)
WSFW_Workshop_attackChanceSafetyMult.SetValue(0.01)
WSFW_Workshop_attackChanceResourceMult.SetValue(0.03)
WSFW_Workshop_attackChancePopulationMult.SetValue(0.03)
WSFW_Workshop_attackChanceBase.SetValue(0.05)
EndEvent
Edited by ParseOfficial
Link to comment
Share on other sites

If those variables are not locked as CONST (constant) you can change them from the console: set GLOBAL to VALUE

 

set WSFW_Workshop_minDaysSinceLastAttack to 3

 

If the variables are locked CONST they need to be unlocked in FO4EDIT

 

If you want to use the CK you need to create a start game enabled quest and attach a script that sets the globals.

Link to comment
Share on other sites

GlobalVariable Property WSFW_Workshop_minDaysSinceLastAttack Auto
GlobalVariable Property WSFW_Workshop_attackChanceSafetyMult Auto
GlobalVariable Property WSFW_Workshop_attackChanceResourceMult Auto
GlobalVariable Property WSFW_Workshop_attackChancePopulationMult Auto
GlobalVariable Property WSFW_Workshop_attackChanceBase Auto

Event OnInit()
	WSFW_Workshop_minDaysSinceLastAttack.SetValue(3.0)
	WSFW_Workshop_attackChanceSafetyMult.SetValue(0.01)
	WSFW_Workshop_attackChanceResourceMult.SetValue(0.03)
	WSFW_Workshop_attackChancePopulationMult.SetValue(0.03)
	WSFW_Workshop_attackChanceBase.SetValue(0.05)
EndEvent

But I can't find those Global Variables in the vanilla game, so its more likely this is not going to work unless they are from a mod that you are loading as master for your plugin, or that you created them in your plugin.

I guess this works like that by running them in the console but, like some of the functions, they are not accesible from plugins, probably because those are hardcoded.

Link to comment
Share on other sites

Create a new quest, set an ID, check "Start Game Enabled", click OK and save the plugin. Then edit your quest, go to the scripts tab, add a script [new script], name it whatever you want, edit the script (Edit Source), paste the code (do not remove the header that CK created "Scriptname yourScriptName extends quest" must be there), save it so CK will compile the code, then edit the properties of the script, click on each of the properties, then on "Edit Value", and fill it with the actual Global Variable.

 

PS: Since you are going to use it in a quest, I would use OnQuestInit instead of OnInit for the event. There are many ways to run a script, but as quest script is the simpler one.

Edited by DieFeM
Link to comment
Share on other sites

  • Recently Browsing   0 members

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