Jump to content

Problem with Papyrus script...


DanielUA

Recommended Posts

I want to edit LoveInterestFINScript. Here it is

 

 

ScriptName LoveInterestFINScript extends ReferenceAlias

LocationAlias Property CurrentMarriageHouse Auto
Spell Property MarriageSleepAbility Auto
Faction Property JobMerchantFaction Auto
MiscObject Property Gold001 Auto
GlobalVariable Property MarriageGoldEarned Auto

;how much gold spouse earns each day
Int GoldEarnedAmount = 100

Event OnSleepStop(bool abInterrupted)
	if (abInterrupted == False) && (CurrentMarriageHouse.GetLocation() == Game.GetPlayer().GetCurrentLocation())
; 	    Debug.Trace(self + "Player has slept in the same location as the spouse. Apply Bonus.")
		MarriageSleepAbility.Cast(Game.GetPlayer(), Game.GetPlayer())
	Else
; 		Debug.Trace(self + "Player is married, but hasn't slept in the same location as the spouse, or was woken up by something.")
	EndIf
endEvent


Event OnUpdateGameTime()

; 	debug.trace(self + "OnUpdate event to calculate spouse store gold")
	If Self.GetActorRef().IsInFaction(JobMerchantFaction)
; 		debug.trace(self + "Adding gold to spouse for store")
		MarriageGoldEarned.SetValue(MarriageGoldEarned.Value + GoldEarnedAmount)
	EndIf

EndEvent

Function GiveGold()

; 	debug.trace(self + "spouse gives gold")
	Game.GetPlayer().AddItem(Gold001, MarriageGoldEarned.GetValueInt())
	MarriageGoldEarned.SetValue(0)

EndFunction

 

 

What I want to do is to change line

Int GoldEarnedAmount = 100

to

Int GoldEarnedAmount = Utility.RandomInt(15, 35)

But when I try to compile it I have a mistake


C:\Program Files\steam\steamapps\common\skyrim\Data\Scripts\Source\LoveInterestFINScript.psc(10,23): no viable alternative at input 'Utility'
C:\Program Files\steam\steamapps\common\skyrim\Data\Scripts\Source\LoveInterestFINScript.psc(10,30): required (...)+ loop did not match anything at input '.'
C:\Program Files\steam\steamapps\common\skyrim\Data\Scripts\Source\LoveInterestFINScript.psc(10,4): Unknown user flag Utility

 

Can anyone fix it to me?


 

Link to comment
Share on other sites

You can't call a function--like Utility.RandomInt--outside of another function or event. So in this case you'd need to do what you want inside the OnUpdateGameTime() event block. The simplest way would be remove the line about GoldEarnedAmount from the top of the script and move it down to just above the line where it gets used...

 

MarriageGoldEarned.SetValue(MarriageGoldEarned.Value + GoldEarnedAmount)
...like so...

 

Int GoldEarnedAmount = Utility.RandomInt(15, 35)
MarriageGoldEarned.SetValue(MarriageGoldEarned.Value + GoldEarnedAmount)
Or even just combine them and do

 

MarriageGoldEarned.SetValue(MarriageGoldEarned.Value + Utility.RandomInt(15, 35))
Link to comment
Share on other sites

  • Recently Browsing   0 members

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