Jump to content

Need Help with Terminal and Linked Quest


Recommended Posts

As it was working before, I have no idea how I managed to break this, but somehow I did, when the quest function is executed a stack overflow happens, and we all know thats just not good for the game, it causes loss of workshop / character / quest data as the pending stacks get dumped.

 

The script on the terminal:

Scriptname calTerminalReturnScript extends ObjectReference Hidden Conditional

	ReferenceAlias Property AliasToForceRefTo Auto Mandatory Const
	{Alias to stick this terminal into on quest}
	CalReturnObjectsQuest Property ReturnObjectsVar Auto Const
	{Return Objects Script attached to quest}
	GlobalVariable Property cnPlayerTokenCount Auto Mandatory
	{Return Token Count}
	MiscObject Property cnReturnToken Auto Const Mandatory
	{Token Object}
	MiscObject Property cnReturnObject Auto Const Mandatory
	{Return Object}

Event OnActivate(ObjectReference akActionRef)
    if (akActionRef == Game.GetPlayer())
    	AliasToForceRefTo.ForceRefTo(Self)
    endif
EndEvent

Function TryToReturnObjects()
	ObjectReference PlayerRef = Game.GetPlayer()
	int ObjPlayerHas = PlayerRef.GetItemCount(DN011OverdueBook)
	if (ObjPlayerHas > 0)
		PlayerRef.AddItem(cnReturnToken, ObjPlayerHas * 5)
		PlayerRef.RemoveItem(cnReturnObject, ObjPlayerHas)
	endif
	UpdateTokens()
EndFunction

Function UpdateTokens()
	ObjectReference PlayerRef = Game.GetPlayer()
	cnPlayerTokenCount.SetValueInt(PlayerRef.GetItemCount(cnReturnToken))
	OverdueBooksVar.UpdateTokenCount()
EndFunction

When the terminal is activated it hooks itself to the quest, this works fine. When the player turns in the objects defined in the variable, they get the proper token given back to them, this works fine too. the problem happens when UpdateTokens is called. Now I've Set the value of it here, then called the script on the book return script to update it, and this is where the stack overflow happens.

 

I've tried both setting the value of the cnPlayerTokenCount global both in the terminal script as well as in the quest script, thinking perhaps that was what was causing the issue, doesn't matter which it is executed in, the problem still persists (SetValueInt)

 

The script on the Quest:


Scriptname CalReturnObjectsQuest extends Quest Hidden

GlobalVariable Property cnPlayerTokenCount Auto Const Mandatory
MiscObject Property cnReturnToken Auto Const Mandatory

Function UpdateTokenCount()
	;ObjectReference PlayerRef = Game.GetPlayer()
	;cnPlayerTokenCount.SetValueInt(PlayerRef.GetItemCount(cnReturnToken))
	UpdateCurrentInstanceGlobal(cnPlayerTokenCount)
EndFunction

I left in the remmed out statements in the quest script, (playerref, setvalueint) just so you could see that i've attempted to set it there as well with no luck.

 

The quest fires off fine, the alias gets setup fine, and if I don't call the updatetokencount on the quest, the stack overflow never happens. Just to see if it was a issue with my global var, I swapped it with the book return token var ( DN011OverdueBooksPlayerTokenCount ) as the global to update, and the stack overflow still happened.

 

I've looked at both the nukaworld prize machine and the bookreturn machine to see how they were handling doing this, and I seem to be doing it the same way as those.

 

There is no alias for the global (this is the same in the two machines mentioned above) and prior to updating it does show whatever value is initially assigned to the global var, after executing UpdateTokenCount() and the stack dump, the value displays on the terminal as [...]

 

As you can see, neither script is really that complicated, and I have no clue how I managed to break this, and I know it has to be something totally simple that I am overlooking, but for the life of me I can't see it, thought maybe someone on here would be kind enough to give me a slap along side the head and say "here's what you did silly boy"

 

The quest has its stages setup with a run on start stage, The main tab is also set the same as the bookreturn quest (DN011OverdueBooks)

 

The alias of the terminal is a empty forced ref which is filled when the terminal (see script above) is activated.

 

Any help would be greatly appreciated.

 

Link to comment
Share on other sites

Derp... see... I think I did need a slap on the head, I don't think the problem now is with the scripting, I believe its a problem with the quest, on the first page (which I totally missed) there is a slot on the right hand side labeled "Text Display Globals" .... derp ... I have nothing in there, and is most likely whats causing the stack overflow I think, I'll go add my vars in and give it a go and see if that fixes the problem n' let you all know :smile:

 

Still open to any advice on this, the reason I'm using global text is I need to be able to update it on the fly on the active terminal, from my understanding reading the wiki AddTextReplacementData won't update the text when actively using the terminal, only at terminal init.

 

Edit in:

Yep, that was my derpy mistake, I forgot to add the global to the text display globals on the main tab and thats what was causing the stack dump. Script is working fine, and the terminals text is now updating on the fly like it should be :)

Edited by caleb68
Link to comment
Share on other sites

  • Recently Browsing   0 members

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